1 // Copyright (c) 2004-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.
16 #ifndef __BASICANIMATION_H__
17 #define __BASICANIMATION_H__
19 #include <animation.h>
26 class CFbsBitmapDevice;
28 class CAnimationDataProvider;
30 class TAnimationConfig;
32 class CAnimationTicker;
33 class CBasicAnimationExt;
37 Implementation of CAnimation for purely client side animations.
39 A basic animation accepts a data provider during construction, loads the
40 appropriate animator plugin, and implements the interface defined in
43 A basic animation must be associated with an RWindow. Redraw events will be
44 received by the client application whenever the animation needs to draw a new
45 frame, and it is the applications responsibility to call Draw() while handling
46 these events. It is also the client applications responsibility to handle
47 visibility events and place the animation on hold when it isn't visible. This
48 saves on CPU usage and ultimately prolongs battery life.
50 @see CAnimationDataProvider
54 class CBasicAnimation : public CAnimation, public MAnimationDrawer, public MAnimationDataProviderObserver
59 EAnimationInitialised = 0x0001,
62 IMPORT_C static CBasicAnimation* NewL(CAnimationDataProvider* aDataProvider, const TPoint& aPoint, RWsSession& aWs, RWindow& aWindow, MAnimationObserver* aObserver = 0);
63 IMPORT_C static CBasicAnimation* NewL(CAnimationDataProvider* aDataProvider, const TPoint& aPoint, RWsSession& aWs, RWindow& aWindow, const TDesC8& aDataType, MAnimationObserver* aObserver = 0);
64 IMPORT_C static CBasicAnimation* NewL(CAnimationDataProvider* aDataProvider, const TPoint& aPoint, MAnimationObserver* aObserver, const CCoeControl* aHost);
65 IMPORT_C static CBasicAnimation* NewL(CAnimationDataProvider* aDataProvider, const TPoint& aPoint, const TDesC8& aDataType, MAnimationObserver* aObserver, const CCoeControl* aHost);
66 IMPORT_C ~CBasicAnimation();
68 IMPORT_C void Draw(CWindowGc& aGc) const;
70 /** Provides an CAnimationDataProvider interface to the client application.
71 @return iDataProvider A CAnimationDataProvider */
72 inline CAnimationDataProvider* DataProvider() { return iDataProvider; }
74 /** Returns the current drawing position.
75 @return ipoint const Tpoint& */
76 inline const TPoint& Position() const { return iPoint; }
78 /** Gets the size of the smallest bounding rectangle that will be required to render the animation.
80 This function is called when the animator is ready to begin animating. The animator cannot be started
81 until it has called this function.
82 @return iSize The size of the smallest bounding rectangle */
83 inline const TSize& Size() const { return iSize; }
85 virtual void Start(const TAnimationConfig& aConfig);
88 virtual void Resume();
90 virtual void Unhold();
91 virtual void SetPosition(const TPoint& aPoint);
92 virtual void Freeze();
93 virtual void Unfreeze();
95 IMPORT_C void SetHostL(const CCoeControl* aHost);
97 CBasicAnimation(CAnimationDataProvider* aDataProvider, const TPoint& aPoint, RWsSession* aWs, RWindow* aWindow, MAnimationObserver* aObserver);
99 CBasicAnimation(CAnimationDataProvider* aDataProvider, const TPoint& aPoint, MAnimationObserver* aObserver);
100 void ConstructL(const TDesC8& aDataType);
101 IMPORT_C virtual void CBasicAnimation_Reserved1();
102 IMPORT_C virtual void CBasicAnimation_Reserved2();
103 void ConstructL(const TDesC8& aDataType,const CCoeControl* aHost);
105 CBasicAnimation(const CBasicAnimation&); // no implementation
106 CBasicAnimation& operator=(const CBasicAnimation&); // no implementation
107 // from MAnimationDataProviderObserver
108 virtual void DataProviderEventL(TInt aEvent, TAny* aData, TInt aDataSize);
109 // From MAnimatorDrawer
110 virtual void AnimatorDraw();
111 virtual void AnimatorInitialisedL(const TSize& aSize);
112 virtual void AnimatorResetL();
113 virtual const TPtrC8 AnimatorDataType() const;
114 virtual CAnimationTicker& AnimatorTicker();
116 CBasicAnimationExt* iBasicAnimationExt;
117 MAnimationObserver* iObserver;
118 CAnimationDataProvider* iDataProvider;
127 CAnimator* iAnimator;
130 CFbsBitmapDevice* iBitmapDevice;
131 CFbsBitmapDevice* iMaskDevice;
132 CFbsBitGc* iRenderGc;