1.1 --- a/epoc32/include/bmpansrv.h Tue Mar 16 16:12:26 2010 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,328 +0,0 @@
1.4 -// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 -// All rights reserved.
1.6 -// This component and the accompanying materials are made available
1.7 -// under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.8 -// which accompanies this distribution, and is available
1.9 -// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 -//
1.11 -// Initial Contributors:
1.12 -// Nokia Corporation - initial contribution.
1.13 -//
1.14 -// Contributors:
1.15 -//
1.16 -// Description:
1.17 -//
1.18 -
1.19 -
1.20 -
1.21 -/**
1.22 - @file
1.23 - @internalComponent
1.24 -*/
1.25 -
1.26 -#if !defined(__BMPANSRV_H__)
1.27 -#define __BMPANSRV_H__
1.28 -
1.29 -#include <e32std.h>
1.30 -#include <w32adll.h>
1.31 -#include <bmpanconsts.h>
1.32 -#include "bmpancli.h"
1.33 -#include <e32math.h>
1.34 -
1.35 -
1.36 -
1.37 -enum TBitmapAnimServerPanic
1.38 - {
1.39 - EAnimationServerPanicIndexOutOfRange,
1.40 - EAnimationServerPanicFrameIntervalNegative
1.41 - };
1.42 -
1.43 -// For packaging the new animation position offset
1.44 -struct SBitmapAnimNewPosition
1.45 - {
1.46 - TPoint iPosition;
1.47 - };
1.48 -
1.49 -// For packaging the new animation index
1.50 -struct SBitmapAnimIndexFrame
1.51 - {
1.52 - TInt iIndex;
1.53 - };
1.54 -
1.55 -// For packaging the number of cycles
1.56 -struct SBitmapAnimNumberOfCycles
1.57 - {
1.58 - TInt iCycles;
1.59 - };
1.60 -
1.61 -
1.62 -
1.63 -/**
1.64 - TFrameData
1.65 -
1.66 - This class is used for packaging the data of one frame.
1.67 -*/
1.68 -class TFrameData
1.69 - {
1.70 -public:
1.71 - TInt iBitmapHandle;
1.72 - TInt iMaskBitmapHandle;
1.73 - TPoint iPosition;
1.74 - TInt iIntervalInMilliSeconds; // the time is expressed in ms
1.75 - };
1.76 -
1.77 -
1.78 -
1.79 -/**
1.80 - TBmpAnimAttributes
1.81 -
1.82 - This class is used for packaging the attriutes of the animation.
1.83 -*/
1.84 -class TBmpAnimAttributes
1.85 - {
1.86 -public:
1.87 - TBool iFlash;
1.88 - TInt iFrameIntervalInMilliSeconds;
1.89 - CBitmapAnimClientData::TPlayMode iPlayMode;
1.90 - };
1.91 -
1.92 -
1.93 -
1.94 -
1.95 -/**
1.96 - class MBitmapAnimTimerObserver
1.97 -*/
1.98 -class MBitmapAnimTimerObserver
1.99 - {
1.100 -public:
1.101 - virtual void DisplayNextFrameL()=0;
1.102 - };
1.103 -
1.104 -
1.105 -
1.106 -/**
1.107 - class CBitmapAnimTimer
1.108 -
1.109 - This class is used to determine when to swap the current frame with the next one.
1.110 -*/
1.111 -class CBitmapAnimTimer : public CTimer
1.112 - {
1.113 -public:
1.114 - ~CBitmapAnimTimer();
1.115 - static CBitmapAnimTimer* NewL(MBitmapAnimTimerObserver* aObserver);
1.116 - void RunL();
1.117 -private:
1.118 - CBitmapAnimTimer(MBitmapAnimTimerObserver* aObserver);
1.119 - void ConstructL();
1.120 -private:
1.121 - MBitmapAnimTimerObserver* iAnimate;
1.122 - };
1.123 -
1.124 -
1.125 -
1.126 -/**
1.127 - class MBitmapAnimFlashTimerObserver
1.128 -*/
1.129 -
1.130 -class MBitmapAnimFlashTimerObserver
1.131 - {
1.132 -public:
1.133 - virtual void FlashFrame(TBool aFlash)=0;
1.134 - };
1.135 -
1.136 -
1.137 -
1.138 -/**
1.139 - class CBitmapAnimFlashTimer
1.140 -*/
1.141 -
1.142 -class CBitmapAnimFlashTimer : public CTimer
1.143 - {
1.144 -public:
1.145 - ~CBitmapAnimFlashTimer();
1.146 - static CBitmapAnimFlashTimer* NewL(MBitmapAnimFlashTimerObserver* aObserver);
1.147 - void DoCancel();
1.148 - void RunL();
1.149 -private:
1.150 - CBitmapAnimFlashTimer(MBitmapAnimFlashTimerObserver* aObserver);
1.151 - void ConstructL();
1.152 -private:
1.153 - MBitmapAnimFlashTimerObserver* iAnimate;
1.154 - TBool iFlash;
1.155 - };
1.156 -
1.157 -
1.158 -
1.159 -/**
1.160 - class CBitmapAnimFrameData
1.161 -
1.162 - This class encapsulates the information of one frame.
1.163 -*/
1.164 -
1.165 -class CBitmapAnimFrameData : public CBase
1.166 - {
1.167 -public:
1.168 - static CBitmapAnimFrameData* NewL();
1.169 - static CBitmapAnimFrameData* NewLC();
1.170 - ~CBitmapAnimFrameData();
1.171 - void FillFrameDataL(const TFrameData& aFrameDataArg);
1.172 - void CheckAndCreateBitmapsL();
1.173 -
1.174 -private:
1.175 - CBitmapAnimFrameData();
1.176 - void InitialiseMembers();
1.177 -
1.178 -public:
1.179 - CFbsBitmap* iBitmap;
1.180 - CFbsBitmap* iMaskBitmap;
1.181 - TPoint iPosition;
1.182 - TTimeIntervalMicroSeconds32 iInterval;
1.183 - };
1.184 -
1.185 -
1.186 -
1.187 -/**
1.188 - class CBitmapAnim
1.189 -
1.190 - This class encapsulates the enire animation: attributes and frames.
1.191 -*/
1.192 -
1.193 -class CBitmapAnim : public CFreeTimerWindowAnim, MBitmapAnimTimerObserver//, MBitmapAnimFlashTimerObserver
1.194 - {
1.195 -public:
1.196 - ~CBitmapAnim();
1.197 - static CBitmapAnim* NewL();
1.198 -private:
1.199 - CBitmapAnim();
1.200 -private:
1.201 - enum TAnimateFlags
1.202 - {
1.203 -// State
1.204 - ERunning = 0x0001,
1.205 - EFlashing = 0x0002,
1.206 - EFrozen = 0x0004,
1.207 -// Play mode
1.208 - EPlayModeCycle = 0x0010,
1.209 - EPlayModeBounce = 0x0020,
1.210 - EPlayForwards = 0x0040,
1.211 - EPlayBackwards = 0x0080,
1.212 -// General
1.213 - EFlash = 0x0100,
1.214 - EBackgroundBitmapProvided = 0x0200,
1.215 - EWindowContentsInitialized = 0x0400,
1.216 - ENoBitmapWindowRestoring = 0x0800,
1.217 - EChangedBackgroundFramePending = 0x1000,
1.218 - EBackgroundShouldIncludeWindowContents = 0x2000,
1.219 - EDisplayLastFrameWhenFinished = 0x4000,
1.220 - EBackgroundMaskProvided = 0x8000
1.221 - };
1.222 -
1.223 -private: //Pure Virtual function from CAnim
1.224 - virtual void ConstructL(TAny *aArgs, TBool aHasFocus);
1.225 - virtual void Command(TInt aOpcode, TAny* aArgs);
1.226 - virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs);
1.227 - virtual void Animate(TDateTime* aDateTime);
1.228 - virtual void Redraw();
1.229 - virtual void FocusChanged(TBool aState);
1.230 -private: //Pure Virtual function from MEventHandler
1.231 - virtual TBool OfferRawEvent(const TRawEvent &aRawEvent);
1.232 -private: //Pure Virtual function from MBitmapAnimTimerObserver
1.233 - virtual void DisplayNextFrameL();
1.234 -private: //Pure Virtual function from MBitmapAnimFlashTimerObserver
1.235 - virtual void FlashFrame(TBool aFlash);
1.236 -private:
1.237 - void AppendFrameL(const TFrameData& aFrameData);
1.238 - inline TInt Count() const;
1.239 - void DisplayFrame(TInt aPreviousIndex=-1);
1.240 - void DrawBitmap(TInt aPreviousIndex=-1, TBool aRedraw=EFalse);
1.241 - inline TBool IsFrameDisplayable() const;
1.242 - inline TBool IsRunning() const;
1.243 - inline TBool IsFrozen() const;
1.244 - void ResetAnimation();
1.245 - void ClearFrame(TInt aIndex);
1.246 - void ClearFrameNow(TInt aIndex);
1.247 - void RenderFrameBackground(TInt aIndex);
1.248 - TRect CalcFrameRect(TInt aIndex);
1.249 - void SetBackgroundFrameL(TFrameData aFrameDataArg);
1.250 - void SetFlash(TBmpAnimAttributes aFlash);
1.251 - void SetFrameInterval(TBmpAnimAttributes aFrameInterval);
1.252 - TInt SetIndexFrame(SBitmapAnimIndexFrame aIndexFrame);
1.253 - void SetNumberOfCycles(SBitmapAnimNumberOfCycles aNumberOfCycles);
1.254 - void SetPlayMode(TBmpAnimAttributes aPlayMode);
1.255 - void SetPosition(SBitmapAnimNewPosition aNewPosition);
1.256 - void StartAnimationL();
1.257 - void StopAnimation();
1.258 - void StoreWindowContentsToBackgroundBitmapL(const TRegion* aRegion);
1.259 - void UpdateCurrentIndex();
1.260 - inline TRect WindowRect() const;
1.261 - CFbsBitmap* CreateRestoringBitmapL(TPoint& aPosition, TInt aPreviousIndex);
1.262 - void UpdateBackgroundBitmapIfNeeded(const TRegion* aRegion, TRect aBackgroundBitmapScreenRect);
1.263 - static TBool FrameNeedsRedrawing(const TRegion* aRedrawRegion, TRect aFrameScreenRect);
1.264 - void ResetFrameArray();
1.265 - void ClearFrameData();
1.266 - TBool CanDrawNextFrameWithoutErasingPreviousFrameL(TInt aPreviousIndex);
1.267 - TBool CompareBitmapsL(CFbsBitmap* aBmp1, CFbsBitmap* aBmp2);
1.268 -
1.269 -private:
1.270 - RPointerArray<CBitmapAnimFrameData> iBitmapAnimFrameDataArray;
1.271 - CBitmapAnimTimer* iAnimTimer;
1.272 - CBitmapAnimFlashTimer* iFlashTimer;
1.273 - CBitmapAnimFrameData* iBackgroundFrame;
1.274 - CFbsBitmap* iBackgroundBitmap;
1.275 - CFbsBitmapDevice* iBackgroundbitmapDevice;
1.276 - CFbsBitGc* iBackgroundbitmapGc;
1.277 -
1.278 -//
1.279 - TInt iDummy;
1.280 - TInt iFlags;
1.281 - TInt iIndex;
1.282 - TInt iNumberOfCycles;
1.283 - TPoint iPosition;
1.284 - TInt iWindowConfig;
1.285 - TTimeIntervalMicroSeconds32 iFrameInterval;
1.286 -//
1.287 - CFbsBitGc* iRestoringGc;
1.288 - };
1.289 -
1.290 -// Returns the number of frames store in the frame array.
1.291 -inline TInt CBitmapAnim::Count() const
1.292 - { return iBitmapAnimFrameDataArray.Count(); }
1.293 -
1.294 -// Returns ETrue every time the index frame is valid, otherwise it returns EFalse.
1.295 -inline TBool CBitmapAnim::IsFrameDisplayable() const
1.296 - { return ( (iIndex >= 0) && iBitmapAnimFrameDataArray[iIndex]->iBitmap ); }
1.297 -
1.298 -// Returns ETrue if the animation is running, otherwise it returns EFalse.
1.299 -inline TBool CBitmapAnim::IsRunning() const
1.300 - { return iFlags&ERunning; }
1.301 -
1.302 -//Returns ETrue if the animation is frozen (app is not in the foreground)
1.303 -inline TBool CBitmapAnim::IsFrozen() const
1.304 -{ return iFlags&EFrozen; }
1.305 -
1.306 -// Returns the available window rect.
1.307 -inline TRect CBitmapAnim::WindowRect() const
1.308 - { return TRect(TPoint(0, 0), iWindowFunctions->WindowSize()); }
1.309 -
1.310 -
1.311 -
1.312 -
1.313 -/**
1.314 - CBitmapAnimDll class
1.315 -*/
1.316 -
1.317 -class CBitmapAnimDll : public CAnimDll
1.318 - {
1.319 -public:
1.320 - CBitmapAnimDll();
1.321 - virtual CAnim* CreateInstanceL(TInt aType);
1.322 - };
1.323 -
1.324 -
1.325 -/**
1.326 - global functions
1.327 -*/
1.328 -GLREF_C void Panic(TBitmapAnimServerPanic aReason);
1.329 -
1.330 -
1.331 -#endif