1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
21 #if !defined(__BMPANSRV_H__)
22 #define __BMPANSRV_H__
26 #include "bmpanconsts.h"
32 enum TBitmapAnimServerPanic
34 EAnimationServerPanicIndexOutOfRange,
35 EAnimationServerPanicFrameIntervalNegative
38 // For packaging the new animation position offset
39 struct SBitmapAnimNewPosition
44 // For packaging the new animation index
45 struct SBitmapAnimIndexFrame
50 // For packaging the number of cycles
51 struct SBitmapAnimNumberOfCycles
61 This class is used for packaging the data of one frame.
67 TInt iMaskBitmapHandle;
69 TInt iIntervalInMilliSeconds; // the time is expressed in ms
77 This class is used for packaging the attriutes of the animation.
79 class TBmpAnimAttributes
83 TInt iFrameIntervalInMilliSeconds;
84 CBitmapAnimClientData::TPlayMode iPlayMode;
91 class MBitmapAnimTimerObserver
93 class MBitmapAnimTimerObserver
96 virtual void DisplayNextFrameL()=0;
102 class CBitmapAnimTimer
104 This class is used to determine when to swap the current frame with the next one.
106 class CBitmapAnimTimer : public CTimer
110 static CBitmapAnimTimer* NewL(MBitmapAnimTimerObserver* aObserver);
113 CBitmapAnimTimer(MBitmapAnimTimerObserver* aObserver);
116 MBitmapAnimTimerObserver* iAnimate;
122 class MBitmapAnimFlashTimerObserver
125 class MBitmapAnimFlashTimerObserver
128 virtual void FlashFrame(TBool aFlash)=0;
134 class CBitmapAnimFlashTimer
137 class CBitmapAnimFlashTimer : public CTimer
140 ~CBitmapAnimFlashTimer();
141 static CBitmapAnimFlashTimer* NewL(MBitmapAnimFlashTimerObserver* aObserver);
145 CBitmapAnimFlashTimer(MBitmapAnimFlashTimerObserver* aObserver);
148 MBitmapAnimFlashTimerObserver* iAnimate;
155 class CBitmapAnimFrameData
157 This class encapsulates the information of one frame.
160 class CBitmapAnimFrameData : public CBase
163 static CBitmapAnimFrameData* NewL();
164 static CBitmapAnimFrameData* NewLC();
165 ~CBitmapAnimFrameData();
166 void FillFrameDataL(const TFrameData& aFrameDataArg);
167 void CheckAndCreateBitmapsL();
170 CBitmapAnimFrameData();
171 void InitialiseMembers();
175 CFbsBitmap* iMaskBitmap;
177 TTimeIntervalMicroSeconds32 iInterval;
185 This class encapsulates the enire animation: attributes and frames.
188 class CBitmapAnim : public CFreeTimerWindowAnim, MBitmapAnimTimerObserver//, MBitmapAnimFlashTimerObserver
192 static CBitmapAnim* NewL();
203 EPlayModeCycle = 0x0010,
204 EPlayModeBounce = 0x0020,
205 EPlayForwards = 0x0040,
206 EPlayBackwards = 0x0080,
209 ENoBitmapWindowRestoring = 0x0800,
210 EDisplayLastFrameWhenFinished = 0x4000,
213 private: //Pure Virtual function from CAnim
214 virtual void ConstructL(TAny *aArgs, TBool aHasFocus);
215 virtual void Command(TInt aOpcode, TAny* aArgs);
216 virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs);
217 virtual void Animate(TDateTime* aDateTime);
218 virtual void Redraw();
219 virtual void FocusChanged(TBool aState);
220 private: //Pure Virtual function from MEventHandler
221 virtual TBool OfferRawEvent(const TRawEvent &aRawEvent);
222 private: //Pure Virtual function from MBitmapAnimTimerObserver
223 virtual void DisplayNextFrameL();
224 private: //Pure Virtual function from MBitmapAnimFlashTimerObserver
225 virtual void FlashFrame(TBool aFlash);
227 void AppendFrameL(const TFrameData& aFrameData);
228 inline TInt Count() const;
229 void DisplayFrame(TInt aPreviousIndex=-1);
230 void DrawBitmap(TInt aPreviousIndex=-1, TBool aRedraw=EFalse);
231 inline TBool IsFrameDisplayable() const;
232 inline TBool IsRunning() const;
233 inline TBool IsFrozen() const;
234 void ResetAnimation();
235 void ClearFrameNow(TInt aIndex);
236 void RenderFrameBackground(TInt aIndex);
237 TRect CalcFrameRect(TInt aIndex);
238 void SetBackgroundFrameL(TFrameData aFrameDataArg);
239 void SetFlash(TBmpAnimAttributes aFlash);
240 void SetFrameInterval(TBmpAnimAttributes aFrameInterval);
241 TInt SetIndexFrame(SBitmapAnimIndexFrame aIndexFrame);
242 void SetNumberOfCycles(SBitmapAnimNumberOfCycles aNumberOfCycles);
243 void SetPlayMode(TBmpAnimAttributes aPlayMode);
244 void SetPosition(SBitmapAnimNewPosition aNewPosition);
245 void StartAnimationL();
246 void StopAnimation();
247 void UpdateCurrentIndex();
248 inline TRect WindowRect() const;
249 static TBool FrameNeedsRedrawing(const TRegion* aRedrawRegion, TRect aFrameScreenRect);
250 void ResetFrameArray();
251 void ClearFrameData();
254 RPointerArray<CBitmapAnimFrameData> iBitmapAnimFrameDataArray;
255 CBitmapAnimTimer* iAnimTimer;
256 CBitmapAnimFlashTimer* iFlashTimer;
257 CBitmapAnimFrameData* iBackgroundFrame;
263 TInt iNumberOfCycles;
266 TTimeIntervalMicroSeconds32 iFrameInterval;
269 // Returns the number of frames store in the frame array.
270 inline TInt CBitmapAnim::Count() const
271 { return iBitmapAnimFrameDataArray.Count(); }
273 // Returns ETrue every time the index frame is valid, otherwise it returns EFalse.
274 inline TBool CBitmapAnim::IsFrameDisplayable() const
275 { return ( (iIndex >= 0) && iBitmapAnimFrameDataArray[iIndex]->iBitmap ); }
277 // Returns ETrue if the animation is running, otherwise it returns EFalse.
278 inline TBool CBitmapAnim::IsRunning() const
279 { return iFlags&ERunning; }
281 //Returns ETrue if the animation is frozen (app is not in the foreground)
282 inline TBool CBitmapAnim::IsFrozen() const
283 { return iFlags&EFrozen; }
285 // Returns the available window rect.
286 inline TRect CBitmapAnim::WindowRect() const
287 { return TRect(TPoint(0, 0), iWindowFunctions->WindowSize()); }
296 class CBitmapAnimDll : public CAnimDll
300 virtual CAnim* CreateInstanceL(TInt aType);
307 GLREF_C void Panic(TBitmapAnimServerPanic aReason);