www.pudn.com > Animation.rar > AnimationContainer.cpp
/** * * @brief Definition of CAnimationContainer * * Copyright (c) EMCC Software Ltd 2003 * @version 1.0 */ // INCLUDES // Class include #include "AnimationContainer.h" // System includes #include#include #include #include // User include // CONSTANTS // ================= MEMBER FUNCTIONS ======================= /** * Symbian OS 2 phase constructor. * Constructs the CAnimationContainer using the NewLC method, popping * the constructed object from the CleanupStack before returning it. * * @param aRect The rectangle for this window * @return The newly constructed CAnimationContainer */ CAnimationContainer* CAnimationContainer::NewL(const TRect& aRect) { CAnimationContainer* self = CAnimationContainer::NewLC(aRect); CleanupStack::Pop(self); return self; } /** * Symbian OS 2 phase constructor. * Constructs the CAnimationContainer using the constructor and ConstructL * method, leaving the constructed object on the CleanupStack before returning it. * * @param aRect The rectangle for this window * @return The newly constructed CAnimationContainer */ CAnimationContainer* CAnimationContainer::NewLC(const TRect& aRect) { CAnimationContainer* self = new (ELeave) CAnimationContainer; CleanupStack::PushL(self); self->ConstructL(aRect); return self; } /** * Symbian OS 2nd phase constructor. Creates a Window for the controls, which it contains. * Constructs a label and adds it to the window, which it then activates. * @param aRect The rectangle for this window */ void CAnimationContainer::ConstructL(const TRect& aRect) { CreateWindowL(); SetRect(aRect); ActivateL(); StartAnimationL(); } /** * Destructor. */ CAnimationContainer::~CAnimationContainer() { CancelAnimation(); } /** * Create CAknBitmapAnimation object via resource file mechanism and * starts animation. * */ void CAnimationContainer::StartAnimationL() { //delete iAnimation; //iAnimation = 0; iAnimation = CAknBitmapAnimation::NewL(); // instantiate CAknBitmapAnimation TResourceReader reader; iCoeEnv->CreateResourceReaderLC(reader, R_ANIMATION_EXAMPLE_DATA); // map resource to resource reader iAnimation->ConstructFromResourceL(reader); // provide animation control with animation data iAnimation->SetContainerWindowL(*this); // animation control needs a window iAnimation->StartAnimationL(); // start animation CleanupStack::PopAndDestroy();//reader } /** * Cancels and deletes CAknBitmapAnimation object */ void CAnimationContainer::CancelAnimation() { if(iAnimation) { iAnimation->CancelAnimation(); delete iAnimation; iAnimation = 0; } } // End of File