|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : EnvMappingAppUi.cpp 00004 * Part of : OpenGLEx / EnvMapping 00005 * 00006 * Copyright (c) 2004-2006 Nokia Corporation. 00007 * This material, including documentation and any related 00008 * computer programs, is protected by copyright controlled by 00009 * Nokia Corporation. 00010 * ============================================================================== 00011 */ 00012 00013 // INCLUDE FILES 00014 #include <eikmenup.h> 00015 #include <avkon.hrh> 00016 00017 #include "EnvMappingAppUi.h" 00018 #include "EnvMappingContainer.h" 00019 #include <EnvMapping.rsg> 00020 #include "envmapping.hrh" 00021 00022 00023 // ================= MEMBER FUNCTIONS ======================= 00024 // 00025 // ---------------------------------------------------------- 00026 // CEnvMappingAppUi::ConstructL() 00027 // Symbian 2nd phase constructor can leave. 00028 // ---------------------------------------------------------- 00029 // 00030 void CEnvMappingAppUi::ConstructL() 00031 { 00032 BaseConstructL(); 00033 00034 iAppContainer = new (ELeave) CEnvMappingContainer; 00035 iAppContainer->SetMopParent(this); 00036 00037 iAppContainer->ConstructL( ClientRect(), this ); 00038 AddToStackL( iAppContainer ); 00039 } 00040 00041 // ---------------------------------------------------- 00042 // CEnvMappingAppUi::~CEnvMappingAppUi() 00043 // Destructor 00044 // Frees reserved resources 00045 // ---------------------------------------------------- 00046 // 00047 CEnvMappingAppUi::~CEnvMappingAppUi() 00048 { 00049 if ( iAppContainer ) 00050 { 00051 RemoveFromStack( iAppContainer ); 00052 delete iAppContainer; 00053 } 00054 } 00055 00056 // ------------------------------------------------------------------------------ 00057 // CEnvMappingAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) 00058 // This function is called by the EIKON framework just before it displays 00059 // a menu pane. Its default implementation is empty, and by overriding it, 00060 // the application can set the state of menu items dynamically according 00061 // to the state of application data. 00062 // ------------------------------------------------------------------------------ 00063 // 00064 void CEnvMappingAppUi::DynInitMenuPaneL( 00065 TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/) 00066 { 00067 } 00068 00069 // ---------------------------------------------------- 00070 // CEnvMappingAppUi::HandleKeyEventL( 00071 // const TKeyEvent& aKeyEvent,TEventCode /*aType*/) 00072 // Key event handler 00073 // ---------------------------------------------------- 00074 // 00075 TKeyResponse CEnvMappingAppUi::HandleKeyEventL( 00076 const TKeyEvent& aKeyEvent, TEventCode aType ) 00077 { 00078 if ( iAppContainer->iEnvMapping->GetState() == CEnvMapping::ERunning ) 00079 { 00080 if( aType == EEventKeyDown ) 00081 { 00082 TUint scan = aKeyEvent.iScanCode; 00083 00084 switch(scan) 00085 { 00086 case(14): 00087 iAppContainer->iEnvMapping->RotateObjectLeft(); 00088 return EKeyWasConsumed; 00089 case(15): 00090 iAppContainer->iEnvMapping->RotateObjectRight(); 00091 return EKeyWasConsumed; 00092 default: 00093 return EKeyWasNotConsumed; 00094 } 00095 } 00096 else if( aType == EEventKeyUp ) 00097 { 00098 TUint scan = aKeyEvent.iScanCode; 00099 00100 switch(scan) 00101 { 00102 case(14): 00103 iAppContainer->iEnvMapping->RotateObjectLeft(); 00104 return EKeyWasConsumed; 00105 case(15): 00106 iAppContainer->iEnvMapping->RotateObjectRight(); 00107 return EKeyWasConsumed; 00108 default: 00109 return EKeyWasNotConsumed; 00110 } 00111 } 00112 } 00113 00114 return EKeyWasNotConsumed; 00115 } 00116 00117 // ---------------------------------------------------- 00118 // CEnvMappingAppUi::HandleCommandL(TInt aCommand) 00119 // command handler 00120 // ---------------------------------------------------- 00121 // 00122 void CEnvMappingAppUi::HandleCommandL(TInt aCommand) 00123 { 00124 switch ( aCommand ) 00125 { 00126 case EAknSoftkeyBack: 00127 case EEikCmdExit: 00128 { 00129 Exit(); 00130 break; 00131 } 00132 case EEnvMappingDuckObject: 00133 { 00134 iAppContainer->iEnvMapping->DuckModel(); 00135 break; 00136 } 00137 case EEnvMappingHeadObject: 00138 { 00139 iAppContainer->iEnvMapping->HeadModel(); 00140 break; 00141 } 00142 default: 00143 break; 00144 } 00145 } 00146 00147 00148 // End of File
|
© Nokia 2009 |