Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


Animation example

Found in examples\Appframework\AnimExample\.

[Top]


Example code

AnimExample.hrh

// AnimExample.hrh
//
//  Copyright ©) 2006 Symbian Software Ltd.  All rights reserved.
//


enum TExampleMenuCommands
    {
    EExampleItem0 = 200,
    EExampleItem1,
    EExampleItem2
    };
enum TExampleSubMenuCommands
    {
    ESprite = 400,
    EBasic
    };
#define ECidFileNameLabel          0x11c6


#define EAnimToDo0             0x1150
#define EAnimToDo1             0x1151
#define EAnimToDo2             0x1152
#define EAnimToDo3             0x1153
#define EAnimToDo4             0x1124
#define EAnimToDo5             0x1155             
#define EAnimToDo6             0x1156
#define EAnimToDo7             0x1157
#define EAnimToDo8             0x1158
#define EAnimToDo9             0x1159


//  Common view controls

#define ETimewCidToolLabel         0x1301
#define ETimewCidToolSpacer            0x1302

AnimExample.h

// AnimExample.h
//
//  Copyright ©) 2006 Symbian Software Ltd.  All rights reserved.
//


#ifndef __ANIMEXAMPLE_H
#define __ANIMEXAMPLE_H

#include <coeccntx.h>

#include <eikenv.h>
#include <eikappui.h>
#include <eikapp.h>
#include <eikdoc.h>
#include <eikmenup.h>
#include <eikstart.h> 
#include <eikon.hrh>
#include <gdi.h>

#include <SpriteAnimation.h>
#include <ICLAnimationDataProvider.h>
#include <BasicAnimation.h>
#include "AnimMover.h"
#include <AnimExample.rsg>
#include "AnimExample.hrh"

_LIT(KAnimExGuitarPlayer,"Z:\\resource\\apps\\AnimExample\\GuitarPlayer.gif");

_LIT( KAnimExSpriteLabel, "Sprite Animation" );
_LIT( KAnimExBasicLabel, "Basic Animation" );

const TInt KBasicOffset = 135;
const TInt KSpriteOffset = 25;

const TInt KspriteInterval = 10000;  //Microseconds
const TInt KBasicInterval = 99999; //Microseconds

const TInt KAnimExBasicPositionX = 300;
const TInt KAnimExBasicPositionY = 100;
const TInt KAnimExSpritePositionX = 60;
const TInt KAnimExSpritePositionY = 70; 


enum TAnimOperation
    {
    EAnimPause,
    EAnimResume,    
    EAnimHold,
    EAnimUnhold,
    EAnimFreeze,
    EAnimUnfreeze,
    EAnimStart,
    EAnimStop       
    };


class CAnimationApplication : public CEikApplication
    {
private: 
    // Inherited from class CApaApplication
    CApaDocument* CreateDocumentL();
    TUid AppDllUid() const;
    };

class CAnimationAppView : public CCoeControl
    {
public:
    static CAnimationAppView* NewL( const TRect& aRect );
    CAnimationAppView();
    ~CAnimationAppView();
    void ConstructL( const TRect& aRect );
    
    void ProduceSpriteAnimL();
    void ProduceBasicAnimL();
    void MoveAnimsL();
    void DoSpriteAnimOperationL( TAnimOperation aOperation );
    void DoBasicAnimOperationL( TAnimOperation aOperation );
    void ResetSpriteAnimAndMover();
    void ResetBasicAnimAndMover();

    CSpriteAnimation* iSpriteAnim;
    CBasicAnimation* iBasicAnim;
    
private:
    // From CCoeControl
    void Draw(const TRect& /*aRect*/) const;

private:
    HBufC*  iAnimTestText;
    CSpriteAnimMover* iSpriteAnimMover;
    CBasicAnimMover* iBasicAnimMover;
    
    };

class CAnimationAppUi : public CEikAppUi
    {
public:
    void ConstructL();
    ~CAnimationAppUi();

private:
    // Inherited from class CEikAppUi
    void HandleCommandL(TInt aCommand);

private:
    CAnimationAppView* iAppView;
    };


class CAnimationDocument : public CEikDocument
    {
public:
    static CAnimationDocument* NewL(CEikApplication& aApp);
    CAnimationDocument(CEikApplication& aApp);
    void ConstructL();

private: 
    // Inherited from CEikDocument
    CEikAppUi* CreateAppUiL();
    };


#endif

AnimMover.h

// AnimMover.h
//
//  Copyright ©) 2006 Symbian Software Ltd.  All rights reserved.
//


#ifndef __ANIMMOVER_H__
#define __ANIMMOVER_H__

#include <e32std.h>
#include <SpriteAnimation.h>
#include <BasicAnimation.h>
#include <math.h>

const TInt KXDeflectionIncrement = 5;
const TInt KXDeflectionTerminalValue = 475;
const TInt KYDeflectionOffset = 125;
const TInt KYDeflectionMultiplier = 12;

const TInt KAnimExBasicInitPosX = 300;
const TInt KAnimExBasicInitPosY = 100;
const TInt KAnimExSpriteInitPosX = 60;
const TInt KAnimExSpriteInitPosY = 70;  
    

// Basic Animation Mover
class CSpriteAnimMover : public CActive
    {
public:
    CSpriteAnimMover( TInt aPriority, TInt aMicroSeconds, CSpriteAnimation* aSpriteAnim );
    ~CSpriteAnimMover();
    
    
    
protected:      
    void DoCancel();   
    void RunL();
        
private:
    RTimer iTimer;
    TInt iMicroSeconds;
    CSpriteAnimation* iSpriteAnim; // Caller owns.
    TInt iX;
    TInt iY;   
    
    };


// Sprite Animation Mover
class CBasicAnimMover : public CActive
    {
public:
    CBasicAnimMover( TInt aPriority, TInt aMicroSeconds, CBasicAnimation* aBasicAnim );
    ~CBasicAnimMover();
        
protected:      
    void DoCancel();   
    void RunL();
        
private:
    RTimer iTimer;
    TInt iMicroSeconds;
    CBasicAnimation* iBasicAnim; // Caller owns.
    TInt iX;
    TInt iY;
    };
    
#endif // __ANIMMOVER_H__

Anim_AppUi.cpp

// Anim_AppUi.cpp
//
//  Copyright ©) 2006 Symbian Software Ltd.  All rights reserved.
//

#include "AnimExample.h"

// Second phase constructor of the application UI class.
// It creates and owns a single view.
void CAnimationAppUi::ConstructL()
    {
    
    // Complete the UI framework's construction of the App UI.
    BaseConstructL();
    // Create the appview.
    iAppView = CAnimationAppView::NewL(ClientRect());
    }

// The application UI class owns one view, and is responsible
// for destroying it
CAnimationAppUi::~CAnimationAppUi()
    {
    delete iAppView;
    }

// Called by the UI framework when a command has been issued.
void CAnimationAppUi::HandleCommandL(TInt aCommand)
    {
    
    CEikonEnv* eikEnv = CEikonEnv::Static();
    
    switch (aCommand)
        {
    case EAnimToDo0:
        
        iAppView->ResetSpriteAnimAndMover();
        iAppView->ProduceSpriteAnimL();
        break;               
    
    case EAnimToDo1:
    
        iAppView->ResetBasicAnimAndMover();
        iAppView->ProduceBasicAnimL();
        break;
    
    case EAnimToDo2:

        iAppView->DoSpriteAnimOperationL( EAnimPause );
        break;
        
    case EAnimToDo3:   

        iAppView->DoSpriteAnimOperationL( EAnimResume );
        break;
        
        case EAnimToDo4:
        iAppView->DoSpriteAnimOperationL( EAnimStop );
                
        break;
        
    case EAnimToDo5:

        iAppView->MoveAnimsL();
        break;               
    
    case EAnimToDo6:

        iAppView->DoBasicAnimOperationL( EAnimPause );
        break;

    case EAnimToDo7:

        iAppView->DoBasicAnimOperationL( EAnimResume );
        break;
        
    case EAnimToDo8:
    
        iAppView->DoBasicAnimOperationL( EAnimStop );
        break;
            
    case EAnimToDo9:   
    case EEikCmdExit:
    
        Exit();
        break;
        }
        
    }

Anim_AppView.cpp

// Anim_AppView.cpp
//
//  Copyright ©) 2006 Symbian Software Ltd.  All rights reserved.
//

#include "AnimExample.h"

CAnimationAppView::CAnimationAppView()
    {
    }

CAnimationAppView* CAnimationAppView::NewL(const TRect& aRect)
    {
    CAnimationAppView* self = new(ELeave) CAnimationAppView();
    CleanupStack::PushL(self);
    self->ConstructL(aRect);
    CleanupStack::Pop();
    return self;
    }

CAnimationAppView::~CAnimationAppView()
    {
    delete iAnimTestText;
    delete iSpriteAnim;
    delete iBasicAnim;
    
    if( iSpriteAnimMover )
        {
        iSpriteAnimMover->Cancel();  
        delete iSpriteAnimMover;
        }
            
    if( iBasicAnimMover )
        {
        iBasicAnimMover->Cancel();   
        delete iBasicAnimMover;
        }       
    }

// Standard initialisation for a window-owning control.
void CAnimationAppView::ConstructL( const TRect& aRect )
    {
    
    // Fetch the text from the resource file.
    iAnimTestText = iEikonEnv->AllocReadResourceL( R_EXAMPLE_TEXT_BASICANIM );
    
    // The control is window-owning.
    CreateWindowL();
   
   // Extent of the control.
    SetRect(aRect);
   
    // The control is ready to draw, so notify the UI framework.
    ActivateL();
    }


void CAnimationAppView::ProduceSpriteAnimL()
    {
    
    //ResetAnimsAndMovers();

    // Simple sprite animation
    CICLAnimationDataProvider* spriteDataProvider = new (ELeave)CICLAnimationDataProvider;
    CleanupStack::PushL( spriteDataProvider );
    spriteDataProvider->SetFileL( iEikonEnv->FsSession(), KAnimExGuitarPlayer() );
    CleanupStack::Pop( spriteDataProvider );
    
    iSpriteAnim = CSpriteAnimation::NewL( spriteDataProvider,TPoint(KAnimExSpritePositionX, KAnimExSpritePositionY), iEikonEnv->WsSession(), Window() );
    
    TAnimationConfig config;
    config.iFlags = TAnimationConfig::ELoop;
    config.iData = -1;
    
    iSpriteAnim->Start( config );
    }

    void CAnimationAppView::ProduceBasicAnimL()
    {

    TAnimationConfig config;
    config.iFlags = TAnimationConfig::ELoop;
    config.iData = -1;

    
    // The basic animation. Drawn in ::Draw()
    CICLAnimationDataProvider* basicDataProvider = new (ELeave)CICLAnimationDataProvider;
    CleanupStack::PushL( basicDataProvider );
    basicDataProvider->SetFileL( iEikonEnv->FsSession(), KAnimExGuitarPlayer() );

    CleanupStack::Pop( basicDataProvider );
    
    iBasicAnim = CBasicAnimation::NewL( basicDataProvider,TPoint( KAnimExBasicPositionX, KAnimExBasicPositionY ), iEikonEnv->WsSession(), Window() );
        
    iBasicAnim->Start( config );   
    }


// AO timer interval in microseconds.
const TInt KPositionInterval = 10000;

void CAnimationAppView::MoveAnimsL()
    {
    
    if( iSpriteAnimMover )
        {
        iSpriteAnimMover->Cancel();  
        delete iSpriteAnimMover;
        iSpriteAnimMover = NULL;  
        }
            
    iSpriteAnimMover = new (ELeave) CSpriteAnimMover( EPriorityNormal, KspriteInterval, iSpriteAnim );
    

    if( iBasicAnimMover )
        {
        iBasicAnimMover->Cancel();   
        delete iBasicAnimMover;
        iBasicAnimMover = NULL;   
        }
            
    iBasicAnimMover = new (ELeave) CBasicAnimMover( EPriorityNormal, KBasicInterval, iBasicAnim );

    }


void CAnimationAppView::DoSpriteAnimOperationL( TAnimOperation aOperation )
    {
    
    if( !iSpriteAnim )
        {   
        iEikonEnv->InfoMsg( _L("Not Initialised") );
        return;
        }
        
                
    switch( aOperation )
        {
        
        case EAnimPause:
            iSpriteAnim->Pause();
            break;
        
        case EAnimResume:
            iSpriteAnim->Resume();
            break;
    
        case EAnimStop:    
            iSpriteAnim->Stop();
            break;
        
        default:
            break;
            
        }
        
    }
    
    

void CAnimationAppView::DoBasicAnimOperationL( TAnimOperation aOperation )
    {
    
    if( !iBasicAnim )
        {   
        iEikonEnv->InfoMsg( _L("Not Initialised") );
        return;
        }
        
        
    switch( aOperation )
        {
        case EAnimPause:
            iBasicAnim->Pause();
            break;
        
        case EAnimResume:
            iBasicAnim->Resume();
            break;
        
        case EAnimStop:    
            iBasicAnim->Stop();
            break;
        
        default:
            break;  
        }
        
    }


 // Delete the current anims and movers, if instantiated. 
 // Redraw the window after deleting a CBasicAnimation and call Invalidate()
      
void CAnimationAppView::ResetSpriteAnimAndMover()
    {
    
    if( iSpriteAnimMover )
        {
        iSpriteAnimMover->Cancel();  
        delete iSpriteAnimMover;
        iSpriteAnimMover = NULL;  
        }
            
    if( iSpriteAnim )
        {
        iSpriteAnim->Stop();
        delete iSpriteAnim;    
        iSpriteAnim = NULL;
        }
    }
    
    void CAnimationAppView::ResetBasicAnimAndMover()
    {
    if( iBasicAnimMover )
        {
        iBasicAnimMover->Cancel();   
        delete iBasicAnimMover;
        iBasicAnimMover = NULL;   
        }
                    
    if( iBasicAnim )
        {
        iBasicAnim->Stop();
        delete iBasicAnim; 
        iBasicAnim = NULL;
        
        Window().Invalidate();
        }
        
    }
    
    
//Draw the view
void CAnimationAppView::Draw(const TRect& /*aRect*/) const
    {
    
    // Window graphics context
    CWindowGc& gc = SystemGc();
    
    // Area in which we shall draw
    TRect drawRect = Rect();
    
    // Font used for drawing text
    const CFont*  fontUsed;
    
    // Clear the screen
    gc.Clear();
    
    // Use the title font supplied by the UI
    fontUsed = iEikonEnv->TitleFont();
    gc.UseFont( fontUsed );

    // Draw the text in the rectangle    
    TInt   baselineOffset=( drawRect.Height() - fontUsed->HeightInPixels() ); 
    gc.DrawText( *iAnimTestText,drawRect,0 + fontUsed->HeightInPixels(),CGraphicsContext::ECenter, 0 );
    
    gc.DrawText(  KAnimExBasicLabel, drawRect, baselineOffset - KBasicOffset, CGraphicsContext::ECenter, 0 );
    


    // CBasicAnimations need to be drawn by us.
    if( iBasicAnim )
        {
        iBasicAnim->Draw( gc );    
        }

    gc.DrawText( KAnimExSpriteLabel, drawRect, baselineOffset - KSpriteOffset, CGraphicsContext::ELeft, 0 );    
    
    
    // Discard the font.
    gc.DiscardFont();
    }

Anim_Document.cpp

// Anim_Document.cpp
//
// Copyright ©) 2006 Symbian Software Ltd.  All rights reserved.
//


#include "AnimExample.h"

CAnimationDocument::CAnimationDocument(CEikApplication& aApp)
        : CEikDocument(aApp)
    {}

// Called by the UI framework to construct
// the application UI class. Note that the app UI's
// ConstructL() is called by the UI framework.

CEikAppUi* CAnimationDocument::CreateAppUiL()
    {
    return new(ELeave) CAnimationAppUi;
    }

Anim_Application.cpp

// Anim_Application.cpp
//
// Copyright ©) 2006 Symbian Software Ltd.  All rights reserved.
//

#include "AnimExample.h"

const TUid KUidAnimation = { 0xE80000A5 }; 

// Called by the UI framework to get the application's UID 
TUid CAnimationApplication::AppDllUid() const
    {
    return KUidAnimation;
    }

// Called by the UI framework at application start-up to
// create an instance of the document class.
CApaDocument* CAnimationApplication::CreateDocumentL()
    {
    return new (ELeave) CAnimationDocument(*this);
    }

Anim_Main.cpp

// Anim_Main.cpp
//
// Copyright ©) 2006 Symbian Software Ltd.  All rights reserved.
//

#include "AnimExample.h"

//             The entry point for the application code. It creates
//             an instance of the CApaApplication derived
//             class, CAnimationApplication.
//

static CApaApplication* NewApplication()
    {
    return new CAnimationApplication;
    }

 TInt E32Main()
    {
    return EikStart::RunApplication( NewApplication );
    }
// BLD.INF
//
// Copyright ©) 2006 Symbian Software Ltd.  All rights reserved.
//


PRJ_MMPFILES

AnimExample.mmp

PRJ_EXPORTS
GuitarPlayer.gif   \epoc32\RELEASE\WINSCW\UDEB\Z\Resource\Apps\AnimExample\GuitarPlayer.gif

AnimExample.mmp

// AnimExample.mmp
//
// Copyright ©) 2006 Symbian Software Ltd.  All rights reserved.
//

epocstacksize      0x5000

TARGETPATH          \sys\bin

TARGET              AnimExample.exe
TARGETTYPE          exe

UID                  0x100039CE 0xE80000A5

VENDORID           0x70000001

SOURCEPATH          .

SOURCE              Anim_Main.cpp
SOURCE              Anim_Application.cpp
SOURCE              Anim_Document.cpp
SOURCE              Anim_AppUi.cpp
SOURCE              Anim_AppView.cpp
SOURCE              AnimMover.cpp

USERINCLUDE          .

SYSTEMINCLUDE      \epoc32\include
SYSTEMINCLUDE      \epoc32\include\techview
SYSTEMINCLUDE      \epoc32\include\libc

LIBRARY              euser.lib apparc.lib cone.lib eikcore.lib
LIBRARY             eikdlg.lib eikcoctl.lib gdi.lib
LIBRARY             eikctl.lib smlClient.lib bafl.lib charconv.lib
LIBRARY             efsrv.lib estor.lib eikfile.lib
LIBRARY             TechViewCtl.lib
LIBRARY             animation.lib 
LIBRARY             ws32.lib


START RESOURCE      AnimExample.rss
HEADER
TARGETPATH          \resource\apps
END

START RESOURCE     AnimExample_reg.rss
TARGETPATH          \private\10003a3f\apps
END

START BITMAP      AnimExample_icon.mbm
HEADER
TARGETPATH            \resource\apps
SOURCE                 c8 AnimExample_24.BMP AnimExample_2M.BMP
SOURCE                 c8 AnimExample_32.BMP AnimExample_3M.BMP
SOURCE                 c8 AnimExample_48.BMP AnimExample_4M.BMP
END

Animation.RSS

// Animation.RSS
//
// Copyright (c) 2006 Symbian Software Ltd.  All rights reserved.
//

NAME ANIM

#include <eikon.rh>
#include <appinfo.rh>
#include <eikon.rsg>
#include <eikcore.rsg>

#include <fontids.h>
#include <gulfont.hrh>

#include "AnimExample.hrh"

RESOURCE RSS_SIGNATURE { }

RESOURCE TBUF { buf=""; }

RESOURCE EIK_APP_INFO
    {
    toolbar=r_AnimExample_toolbar;
    menubar=r_menubar;
    }

RESOURCE MENU_BAR r_menubar
    {
    titles=
        {
         MENU_TITLE { menu_pane=r_Animation_first_menu; txt="AnimExample"; }
        };
    } 

RESOURCE MENU_PANE r_Animation_first_menu
    {
    items=
        {
    
        MENU_ITEM { command=EExampleItem0;cascade=r_Sprite_menu; txt="Sprite"; },
        MENU_ITEM { command=EExampleItem1;cascade=r_Basic_menu; txt="Basic"; },
        MENU_ITEM { command=EEikCmdExit; txt= "Close "; }
        };
    }
RESOURCE MENU_PANE r_Sprite_menu
{
items=
        {
        
        MENU_ITEM { command=EAnimToDo0; txt="S.Start"; },
        MENU_ITEM { command=EAnimToDo1; txt="B.Start"; },
        MENU_ITEM { command=EAnimToDo2; txt="Pause"; },
        MENU_ITEM { command=EAnimToDo3; txt="Resume"; },
        MENU_ITEM { command=EAnimToDo4; txt="Stop"; }
        
        };
    }
RESOURCE MENU_PANE r_Basic_menu
    {
    items=
        {

        MENU_ITEM { command=EAnimToDo5; txt="MoveBoth"; },
        MENU_ITEM { command=EAnimToDo6; txt="Pause"; },
        MENU_ITEM { command=EAnimToDo7; txt="Resume"; },
        MENU_ITEM { command=EAnimToDo8; txt="Stop"; }
        
        };
    }

RESOURCE TBUF r_appname_default_file
    {
    buf="AnimExample";
    }


RESOURCE LOCALISABLE_APP_INFO r_lai
    {
    short_caption="ThribbetV2";
    
    caption_and_icon=   
        {
        CAPTION_AND_ICON_INFO
            {
            caption="AnimExample";
            number_of_icons=3;
            icon_file="\\resource\\apps\\AnimExample_icon.mbm";
            icon_file="z:\\resource\\apps\\AnimExample_icon.mbm";
            }
        };

    }
    
    
rls_string STRING_r_test_toolbar0 "S.Start"
rls_string STRING_r_test_toolbar1 "B.Start" 
rls_string STRING_r_test_toolbar2 "S.Pause" 
rls_string STRING_r_test_toolbar3 "S.Resume" 
rls_string STRING_r_test_toolbar4 "S.Stop"
rls_string STRING_r_test_toolbar5 "MoveBoth"
rls_string STRING_r_test_toolbar6 "B.Pause" 
rls_string STRING_r_test_toolbar7 "B.Resume" 
rls_string STRING_r_test_toolbar8 "B.Stop" 
rls_string STRING_r_test_toolbar9 "Close" 
    

RESOURCE EIK_APP_INFO 
    {

    }   

#define KDenseToolBarButtonHeight 23
#define KDenseToolBarWidth 30


RESOURCE TOOLBAR r_AnimExample_toolbar
    {
    breadth=KTechViewToolbarWidth;
    
    controls=
        {
        TBAR_BUTTON 
            { 
            id=EAnimToDo0;  
            length=KDenseToolBarButtonHeight;
            flags=EEikToolBarCtrlHasSetMinLength; 
            txt=STRING_r_test_toolbar0; 
            layout=EEikCmdButTextRightPictureLeft|EEikCmdButShareExcess|EEikCmdButDenseFont;
            },
        TBAR_BUTTON 
            { 
            id=EAnimToDo1; 
            length=KDenseToolBarButtonHeight;
            flags=EEikToolBarCtrlHasSetMinLength; 
            txt=STRING_r_test_toolbar1;
            layout=EEikCmdButTextRightPictureLeft|EEikCmdButShareExcess|EEikCmdButDenseFont;
            },
        TBAR_BUTTON 
            { 
            id=EAnimToDo2; 
            flags=EEikToolBarCtrlHasSetMinLength; 
            length=KDenseToolBarButtonHeight;
            txt=STRING_r_test_toolbar2; 
            layout=EEikCmdButTextRightPictureLeft|EEikCmdButShareExcess|EEikCmdButDenseFont;
            },
        TBAR_BUTTON 
            { 
            id=EAnimToDo3; 
            flags=EEikToolBarCtrlHasSetMinLength; 
            length=KDenseToolBarButtonHeight;
            txt=STRING_r_test_toolbar3; 
            layout=EEikCmdButTextRightPictureLeft|EEikCmdButShareExcess|EEikCmdButDenseFont;
            },
        TBAR_BUTTON 
            { 
            id=EAnimToDo4; 
            flags=EEikToolBarCtrlHasSetMinLength; 
            length=KDenseToolBarButtonHeight;
            txt=STRING_r_test_toolbar4; 
            layout=EEikCmdButTextRightPictureLeft|EEikCmdButShareExcess|EEikCmdButDenseFont;
            },
        TBAR_BUTTON 
            { 
            id=EAnimToDo5; 
            flags=EEikToolBarCtrlHasSetMinLength; 
            length=KDenseToolBarButtonHeight;
            txt=STRING_r_test_toolbar5; 
            layout=EEikCmdButTextRightPictureLeft|EEikCmdButShareExcess|EEikCmdButDenseFont;
            },
        TBAR_BUTTON 
            { 
            id=EAnimToDo6; 
            flags=EEikToolBarCtrlHasSetMinLength; 
            length=KDenseToolBarButtonHeight;
            txt=STRING_r_test_toolbar6; 
            layout=EEikCmdButTextRightPictureLeft|EEikCmdButShareExcess|EEikCmdButDenseFont;
            }, 
        TBAR_BUTTON 
            { 
            id=EAnimToDo7; 
            flags=EEikToolBarCtrlHasSetMinLength; 
            length=KDenseToolBarButtonHeight;
            txt=STRING_r_test_toolbar7; 
            layout=EEikCmdButTextRightPictureLeft|EEikCmdButShareExcess|EEikCmdButDenseFont;
            },
        TBAR_BUTTON 
            { 
            id=EAnimToDo8; 
            flags=EEikToolBarCtrlHasSetMinLength; 
            length=KDenseToolBarButtonHeight;
            txt=STRING_r_test_toolbar8; 
            layout=EEikCmdButTextRightPictureLeft|EEikCmdButShareExcess|EEikCmdButDenseFont;
            },
            TBAR_BUTTON 
            { 
            id=EAnimToDo9; 
            flags=EEikToolBarCtrlHasSetMinLength; 
            length=KDenseToolBarButtonHeight;
            txt=STRING_r_test_toolbar9; 
            layout=EEikCmdButTextRightPictureLeft|EEikCmdButShareExcess|EEikCmdButDenseFont;
            }
            
        };  
    }


RESOURCE TBUF r_example_text_BasicAnim { buf="Welcome to the Animation example "; }

AnimExample_reg.rss

#include <appinfo.rh>
#include <AnimExample.rsg>

UID2 KUidAppRegistrationResourceFile

UID3 0xE80000A5 // App UID

RESOURCE APP_REGISTRATION_INFO
    {
    app_file="AnimExample";
    localisable_resource_file="\\resource\\apps\\AnimExample";
    localisable_resource_id=R_LAI;
    }

[Top]


Description

This example is a UI application, which demonstrates how to create and play basic and sprite animations. It implements all the standard classes required by any application using UI controls such as an application, a document, an application UI and a view.

The application provides UI controls to create a sprite animation and a basic client-side animation. It also provides UI controls to control the behaviour of an animation such as, start, stop, pause, resume and move.

The application plays an animated .gif file both as a basic client-side animation and a server-side sprite animation. It performs the following tasks in the order they are listed to create the basic and sprite animations:

  1. Creates an object of the CICLAnimationDataProvider class.

  2. Loads the animated .gif file into the object.

  3. Configures the animation to play in an infinite loop using TAnimationConfig.

  4. Creates objects of CBasicAnimation and CSpriteAnimation classes by passing the data provider object as an argument.

  5. Starts animations with the TAnimationConfig object as an argument.

Once both the animations are started, the window server will automatically draw the animations onto the window by calling the Draw() method.

[Top]


Class summary

Related APIs

[Top]


Build

The Symbian OS build process describes how to build an application. But, use abld export command before abld build to copy the animated .gif file to RAM (C:\ drive) of the target platform.

The AnimExample builds an executable called AnimExample.exe in the standard location (\epoc32\release\winscw\<build_variant> for CodeWarrior). Either launch the executable or launch the emulator and then select the AnimExample application from the Emulator's extras bar.

[Top]


See also

Using Animation