epoc32/include/spriteanimation.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 spriteanimation.h
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __SPRITEANIMATION_H__
       
    17 #define __SPRITEANIMATION_H__
       
    18 
       
    19 #include <animation.h>
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <w32std.h>
       
    23 
       
    24 #include <animationconfig.h>
       
    25 #include <spriteanimationclient.h>
       
    26 
       
    27 class CAnimationDataProvider;
       
    28 class CCoeControl;
       
    29 class CSpriteAnimationExt;
       
    30 
       
    31 /**
       
    32 Implementation of CAnimation for sprite based animations.
       
    33 
       
    34 A sprite animation displays the image using a sprite, which is a server side
       
    35 graphic object.  This is likely to be more efficient than a basic animation,
       
    36 and requires slightly less work in the client application.  However, it also
       
    37 provides less control over the actual rendering of the image.
       
    38 
       
    39 A sprite animation must be associated with an RWindow.  However, no redraw
       
    40 events will be generated for it by the animation, and the client application
       
    41 does not need to take any action once the animation has started.  Holding the
       
    42 animation when the sprite is not visible is handled automatically on the server
       
    43 side.
       
    44 
       
    45 @see CAnimationDataProvider
       
    46 @publishedAll
       
    47 @released
       
    48 */
       
    49 class CSpriteAnimation : public CAnimation, public MAnimationDataProviderObserver
       
    50 	{
       
    51 public:
       
    52 	IMPORT_C static CSpriteAnimation* NewL(CAnimationDataProvider* aDataProvider, const TPoint& aPoint, RWsSession& aWsSession, RWindow& aWindow, MAnimationObserver* aObserver = 0);
       
    53 	IMPORT_C static CSpriteAnimation* NewL(CAnimationDataProvider* aDataProvider, const TPoint& aPoint, RWsSession& aWsSession, RWindow& aWindow, const TDesC8& aDataType, MAnimationObserver* aObserver = 0);
       
    54 	IMPORT_C static CSpriteAnimation* NewL(CAnimationDataProvider* aDataProvider, const TPoint& aPoint, MAnimationObserver* aObserver = NULL, const CCoeControl* aHost = NULL);
       
    55 	IMPORT_C static CSpriteAnimation* NewL(CAnimationDataProvider* aDataProvider, const TPoint& aPoint, const TDesC8& aDataType, MAnimationObserver* aObserver = NULL, const CCoeControl* aHost = NULL);
       
    56 	IMPORT_C ~CSpriteAnimation();
       
    57 	IMPORT_C TSize Size() const;
       
    58 
       
    59 	/** Provides an CSpriteAnimation DataProvider interface to the client application.
       
    60 	@return iDataProvider A CAnimationDataProvider */
       
    61 	inline CAnimationDataProvider* DataProvider() { return iDataProvider; }
       
    62 	// From CAnimationBase:
       
    63 	virtual void Start(const TAnimationConfig& aConfig);
       
    64 	virtual void Stop();
       
    65 	virtual void Pause();
       
    66 	virtual void Resume();
       
    67 	virtual void Hold();
       
    68 	virtual void Unhold();
       
    69 	virtual void SetPosition(const TPoint& aPoint);
       
    70 	virtual void Freeze();
       
    71 	virtual void Unfreeze();	
       
    72 public:
       
    73 	IMPORT_C virtual void SetHostL(const CCoeControl* aHost);
       
    74 		
       
    75 protected:
       
    76 	CSpriteAnimation();
       
    77 	CSpriteAnimation(CAnimationDataProvider* aDataProvider, RWsSession& aWsSession);
       
    78 	CSpriteAnimation(CAnimationDataProvider* aDataProvider, MAnimationObserver* aObserver, const CCoeControl* aHost);
       
    79 	void ConstructL(const TPoint& aPoint, RWindow& aWindow, const TDesC8& aDataType, MAnimationObserver* aObserver);
       
    80 	virtual void CSpriteAnimation_Reserved2();
       
    81 	void ConstructL(const TPoint& aPoint, const TDesC8& aDataType);
       
    82 	void ConstructL();
       
    83 private:
       
    84 	CSpriteAnimation(const CSpriteAnimation&);	// no implementation
       
    85 	CSpriteAnimation& operator=(const CSpriteAnimation&);			// no implementation
       
    86 	void InitializeL();
       
    87 	void Reset();
       
    88 	// from MAnimationDataProviderObserver
       
    89 	virtual void DataProviderEventL(TInt aEvent, TAny* aData, TInt aDataSize);
       
    90 
       
    91 private:
       
    92 	enum TFlags 
       
    93 		{
       
    94 		EAnimationInitialized = 0x1	// Is the animation initialized?
       
    95 		};
       
    96 private:
       
    97 	CSpriteAnimationExt* iSpriteAnimationExt;
       
    98 	MAnimationObserver* iObserver;
       
    99 //note the following data member is accessed via an inline function!
       
   100 	CAnimationDataProvider* iDataProvider;
       
   101 	RWsSession* iWsSession;
       
   102 	RWsSprite* iWsSprite;
       
   103 	RAnimDll iAnimDll;
       
   104 	RSpriteAnimationClient* iClient;
       
   105 	const CCoeControl* iHost;
       
   106 	TInt iFlags;
       
   107 	};
       
   108 
       
   109 #endif