|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : animationappui.cpp 00004 * Part of : Animation example 00005 * Interface : 00006 * Description : 00007 * Version : 00008 * 00009 * Copyright (c) 2004 - 2006 Nokia Corporation. 00010 * This material, including documentation and any related 00011 * computer programs, is protected by copyright controlled by 00012 * Nokia Corporation. 00013 * ============================================================================== 00014 */ 00015 00016 // INCLUDE FILES 00017 #include <eiktbar.h> 00018 #include <eikenv.h> 00019 #include <w32adll.h> 00020 #include <avkon.hrh> 00021 00022 #include "animation.pan" 00023 #include "animationdocument.h" 00024 #include "AnimationAppUi.h" 00025 #include "AnimationAppView.h" 00026 #include "animation.hrh" 00027 #include "clientdll.h" 00028 #include "clientimagecommander.h" 00029 00030 // ============================ MEMBER FUNCTIONS =============================== 00031 00032 // ----------------------------------------------------------------------------- 00033 // CAnimationAppUi::CAnimationAppUi() 00034 // C++ default constructor can NOT contain any code, that might leave. 00035 // ----------------------------------------------------------------------------- 00036 // 00037 CAnimationAppUi::CAnimationAppUi( RWsSession& aSession ) 00038 : CAknAppUi(), // Base class constructor 00039 iClientDll( aSession ), // Animation client dll 00040 iClientCommander( iClientDll ) // Animation client object 00041 { 00042 // No implementation required 00043 } 00044 00045 // ----------------------------------------------------------------------------- 00046 // CAnimationAppUi::ConstructL() 00047 // Symbian 2nd phase constructor can leave. 00048 // ----------------------------------------------------------------------------- 00049 // 00050 void CAnimationAppUi::ConstructL() 00051 { 00052 // Perform the base class construction 00053 BaseConstructL(EAknEnableSkin); 00054 00055 // Create an application view 00056 iAppView = CAnimationAppView::NewL( ClientRect() ); 00057 00058 // Allow the appview to receive keyboard input 00059 AddToStackL( iAppView ); 00060 00061 // Initialise the RClientDll class 00062 SetupClientDllL(); 00063 00064 // Initialise the RImageCommander class 00065 SetupImageCommanderL(); 00066 } 00067 00068 // ----------------------------------------------------------------------------- 00069 // CAnimationAppUi::SetupClientDllL() 00070 // Setup the animation client Dll. 00071 // ----------------------------------------------------------------------------- 00072 // 00073 void CAnimationAppUi::SetupClientDllL() 00074 { 00075 // Create the server dll filename 00076 TFileName serverDllFilename( KServerDllFilename ); 00077 00078 // Load the animation server, if an error occurs then 00079 // let higher level handle the problem 00080 User::LeaveIfError( iClientDll.Load( serverDllFilename ) ); 00081 } 00082 00083 // ----------------------------------------------------------------------------- 00084 // CAnimationAppUi::SetupImageCommanderL() 00085 // Setup the animation image commander. 00086 // ----------------------------------------------------------------------------- 00087 // 00088 void CAnimationAppUi::SetupImageCommanderL() 00089 { 00090 // Tell client to construct a server side object 00091 TBuf8<1> params( TInt8( 0 ) ); 00092 RWindowBase* windowBase = iAppView->DrawableWindow(); 00093 iClientCommander.ImageConstruct( *windowBase, 00094 RImageCommander::KAnimationSquare, 00095 params ); 00096 } 00097 00098 // ----------------------------------------------------------------------------- 00099 // CAnimationAppUi::~CAnimationAppUi() 00100 // Destructor. 00101 // ----------------------------------------------------------------------------- 00102 // 00103 CAnimationAppUi::~CAnimationAppUi() 00104 { 00105 // remove the application view from the stack 00106 RemoveFromStack( iAppView ); 00107 00108 // Close the animation object 00109 iClientCommander.Close (); 00110 00111 // Close the animation server 00112 iClientDll.Close(); 00113 00114 // Delete and NULL the application view 00115 delete iAppView; 00116 iAppView = NULL; 00117 } 00118 00119 // ----------------------------------------------------------------------------- 00120 // CAnimationAppUi::HandleCommandL() 00121 // Takes care of key event handling. 00122 // ----------------------------------------------------------------------------- 00123 // 00124 void CAnimationAppUi::HandleCommandL( TInt aCommand ) 00125 { 00126 switch( aCommand ) 00127 { 00128 // Exit the application 00129 case EEikCmdExit: 00130 case EAknSoftkeyExit: 00131 Exit(); 00132 break; 00133 00134 // Ask the animation to do something, in this case, reset 00135 case EEikCmdReset: 00136 iClientCommander.ImageCommand( RImageCommander::KAnimationReset ); 00137 break; 00138 00139 default: 00140 break; 00141 } 00142 } 00143 00144 // ---------------------------------------------------------------------------- 00145 // void CAnimationAppUi::HandleResourceChangeL() 00146 // Handles a resource change 00147 // ---------------------------------------------------------------------------- 00148 // 00149 00150 void CAnimationAppUi::HandleResourceChangeL( TInt aType ) 00151 { 00152 CAknAppUi::HandleResourceChangeL( aType ); 00153 if ( aType == KEikDynamicLayoutVariantSwitch ) 00154 { 00155 iAppView->HandleResolutionChange( ClientRect() ); 00156 iClientCommander.ImageCommand( RImageCommander::KResolutionChange ); 00157 } 00158 } 00159 00160 // End of File
|
© Nokia 2009 |