Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



How to create an animation object


Implementing CreateInstanceL()

The pure virtual factory function CAnimDll::CreateInstanceL() must be provided in the derived class to create new instances of animation objects of type CAnim contained in the DLL

Declare your CAnimDll derived class in a header file as follows:

class CExampleAnimDll : public CAnimDll
 {
public:
 virtual CAnim* CreateInstanceL(TInt aType);
 };

A convenient way to implement CreateInstanceL() is to switch on the TInt aType argument, with each switch constructing a different CAnim derived animation class identified by an aType enum, for example if CShapesAnims is one of those classes:

switch(aType)
 {
 // cases
 case EShapesAnims:
  return new(ELeave) CShapesAnims;
 ...
 default:
  iFunctions -> Panic();
  return NULL; // dummy return to prevent compiler error
  }
 }

It is up to the implementer to decide whether receiving a bad parameter should cause a panic, as here, or a leave. The approach shown is recommended.

The Panic() function is an MAnimGeneralFunctions helper function, to which CAnim provides the iFunctions pointer. These functions are implemented by the window server and are available to any CAnim derived class.

The animation class's ConstructL() function is called after CreateInstanceL().