examples/ForumNokia/ThreadExample/src/threadanimation.cpp

00001 /*
00002 * ============================================================================
00003 *  Name     : CThreadAnimation from CThreadAnimation.h
00004 *  Part of  : Thread
00005 *  Created  : 04.02.2005 by Forum Nokia
00006 *  Version  : 1.0
00007 *  Copyright: Nokia Corporation
00008 * ============================================================================
00009 */
00010 
00011 // INCLUDES
00012 #include <AknBitmapAnimation.h>
00013 #include <barsread.h> // TResourceReader
00014 #include "ThreadAnimation.h"
00015 
00016 // ----------------------------------------------------------------------------
00017 //CThreadAnimation::CThreadAnimation(void)
00018 //
00019 // constructor
00020 // ----------------------------------------------------------------------------
00021 CThreadAnimation::CThreadAnimation(void): iAnimation(0), iRunning(EFalse)
00022         {
00023         }
00024 
00025 // ----------------------------------------------------------------------------
00026 //CThreadAnimation::~CThreadAnimation(void)
00027 //
00028 // destructor
00029 // ----------------------------------------------------------------------------
00030 CThreadAnimation::~CThreadAnimation(void)
00031         {
00032         delete iAnimation;
00033         }
00034 
00035 CThreadAnimation* CThreadAnimation::NewL(TResourceReader& aReader, RWindow& aWindow)
00036         {
00037         CThreadAnimation* self = CThreadAnimation::NewLC(aReader,aWindow);
00038         CleanupStack::Pop(self);
00039         return self;
00040         }
00041 
00042 CThreadAnimation* CThreadAnimation::NewLC(TResourceReader& aReader, RWindow& aWindow)
00043         {
00044         CThreadAnimation* self = new (ELeave) CThreadAnimation;
00045         CleanupStack::PushL(self);
00046         self->ConstructL(aReader, aWindow);
00047         return self;
00048         }
00049 
00050 // Standard EPOC 2nd phase constructor
00051 void CThreadAnimation::ConstructL(TResourceReader& aReader, RWindow& aWindow)
00052         {
00053         // Instantiate CAknBitmapAnimation
00054         iAnimation = CAknBitmapAnimation::NewL(); 
00055         // Provide animation control with animation data
00056         iAnimation->ConstructFromResourceL(aReader); 
00057         // Animation control needs a window
00058         iAnimation->SetContainerWindowL(aWindow); 
00059         }
00060 
00061 // ----------------------------------------------------------------------------
00062 // CThreadAnimation::StopAnimation()
00063 //
00064 // Stops the animation.
00065 // ----------------------------------------------------------------------------
00066 void CThreadAnimation::StopAnimation()
00067         {
00068         if( iAnimation )
00069                 {
00070                 iRunning = EFalse;
00071                 iAnimation->CancelAnimation();
00072                 }
00073         }
00074 
00075 // ----------------------------------------------------------------------------
00076 // CThreadAnimation::StartAnimationL()
00077 //
00078 // Start the animation only if it is not yet running.
00079 // ----------------------------------------------------------------------------
00080 void CThreadAnimation::StartAnimationL()
00081         {       
00082         // No need to start already running animation
00083         if ( iRunning )
00084                 {
00085                 return;
00086                 }
00087 
00088         // Start thread animation
00089         iAnimation->StartAnimationL(); 
00090         iRunning = ETrue;
00091         }

Generated by  doxygen 1.6.2