|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : SimpleLightAppUi.cpp 00004 * Part of : OpenGLEx / SimpleLight 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 "SimpleLightAppUi.h" 00015 #include "SimpleLightContainer.h" 00016 #include <SimpleLight.rsg> 00017 #include "simplelight.hrh" 00018 00019 #include <eikmenup.h> 00020 #include <avkon.hrh> 00021 00022 // ================= MEMBER FUNCTIONS ======================= 00023 // 00024 // ---------------------------------------------------------- 00025 // CSimpleLightAppUi::ConstructL 00026 // Symbian 2nd phase constructor can leave. 00027 // ---------------------------------------------------------- 00028 // 00029 void CSimpleLightAppUi::ConstructL() 00030 { 00031 BaseConstructL(); 00032 iAppContainer = new (ELeave) CSimpleLightContainer; 00033 iAppContainer->SetMopParent(this); 00034 iAppContainer->ConstructL( ClientRect(), this ); 00035 AddToStackL( iAppContainer ); 00036 } 00037 00038 // Destructor 00039 CSimpleLightAppUi::~CSimpleLightAppUi() 00040 { 00041 if ( iAppContainer ) 00042 { 00043 RemoveFromStack( iAppContainer ); 00044 delete iAppContainer; 00045 } 00046 } 00047 00048 // ------------------------------------------------------------------------------ 00049 // CSimpleLightAppUi::DynInitMenuPaneL 00050 // This function is called by the EIKON framework just before it displays 00051 // a menu pane. Its default implementation is empty, and by overriding it, 00052 // the application can set the state of menu items dynamically according 00053 // to the state of application data. 00054 // ------------------------------------------------------------------------------ 00055 // 00056 void CSimpleLightAppUi::DynInitMenuPaneL( 00057 TInt aResourceId, CEikMenuPane* aMenuPane ) 00058 { 00059 // Item texts for the lighting menu. 00060 if ( aResourceId == R_SIMPLELIGHT_LIGHTING_MENU ) 00061 { 00062 // Text for switching the lights on/off. 00063 if ( iAppContainer->iSimpleLight->iLightingEnabled ) 00064 { 00065 aMenuPane->SetItemTextL( ESimpleLightLights, R_LIGHTS_OFF ); 00066 } 00067 else 00068 { 00069 aMenuPane->SetItemTextL( ESimpleLightLights, R_LIGHTS_ON ); 00070 } 00071 00072 // Text for switching the lamp on/off. 00073 if ( iAppContainer->iSimpleLight->iLampEnabled ) 00074 { 00075 aMenuPane->SetItemTextL( ESimpleLightLamp, R_LAMP_OFF ); 00076 } 00077 else 00078 { 00079 aMenuPane->SetItemTextL( ESimpleLightLamp, R_LAMP_ON ); 00080 } 00081 00082 // Text for switching the spot on/off. 00083 if ( iAppContainer->iSimpleLight->iSpotEnabled ) 00084 { 00085 aMenuPane->SetItemTextL( ESimpleLightSpot, R_SPOT_OFF ); 00086 } 00087 else 00088 { 00089 aMenuPane->SetItemTextL( ESimpleLightSpot, R_SPOT_ON ); 00090 } 00091 } 00092 } 00093 00094 // ---------------------------------------------------- 00095 // CSimpleLightAppUi::HandleKeyEventL 00096 // Key event handler 00097 // ---------------------------------------------------- 00098 // 00099 TKeyResponse CSimpleLightAppUi::HandleKeyEventL( 00100 const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) 00101 { 00102 return EKeyWasNotConsumed; 00103 } 00104 00105 // ---------------------------------------------------- 00106 // CSimpleLightAppUi::HandleCommandL 00107 // Command handler 00108 // ---------------------------------------------------- 00109 // 00110 void CSimpleLightAppUi::HandleCommandL(TInt aCommand) 00111 { 00112 switch ( aCommand ) 00113 { 00114 case EAknSoftkeyBack: 00115 case EEikCmdExit: 00116 { 00117 Exit(); 00118 break; 00119 } 00120 case ESimpleLightLights: 00121 iAppContainer->iSimpleLight->ToggleLighting(); 00122 break; 00123 case ESimpleLightLamp: 00124 iAppContainer->iSimpleLight->ToggleLamp(); 00125 break; 00126 case ESimpleLightSpot: 00127 iAppContainer->iSimpleLight->ToggleSpot(); 00128 break; 00129 case ESimpleLightDuck: 00130 iAppContainer->iSimpleLight->DuckModel(); 00131 break; 00132 case ESimpleLightHead: 00133 iAppContainer->iSimpleLight->HeadModel(); 00134 break; 00135 default: 00136 break; 00137 } 00138 } 00139 00140 // End of File
|
© Nokia 2009 |