|
Nokia N97 SDK Example Applications Guide |
00001 /** 00002 * Copyright (c) 2007 Nokia Corporation. 00003 * This material, including documentation and any related 00004 * computer programs, is protected by 00005 * copyright controlled by Nokia Corporation. 00006 */ 00007 00008 00009 00010 // INCLUDE FILES 00011 #include <avkon.hrh> 00012 #include <eikmenup.h> 00013 #include <choicelistex.rsg> 00014 00015 #include "ChoiceListExAppUi.h" 00016 #include "ChoiceListEx.hrh" 00017 #include "ChoiceListExContainer.h" 00018 00019 00020 // ============================ MEMBER FUNCTIONS =============================== 00021 00022 // ----------------------------------------------------------------------------- 00023 // CChoiceListExAppUi::ConstructL() 00024 // Symbian 2nd phase constructor can leave. 00025 // ----------------------------------------------------------------------------- 00026 // 00027 void CChoiceListExAppUi::ConstructL() 00028 { 00029 BaseConstructL( EAknEnableSkin ); 00030 00031 iAppContainer = new ( ELeave ) CChoiceListExContainer(); 00032 iAppContainer->SetMopParent( this ); 00033 iAppContainer->ConstructL( ClientRect() ); 00034 00035 iMenuFlags.ClearAll(); 00036 00037 AddToStackL( iAppContainer ); 00038 } 00039 00040 // ----------------------------------------------------------------------------- 00041 // CChoiceListExAppUi::CChoiceListExAppUi() 00042 // C++ default constructor can NOT contain any code, that might leave. 00043 // ----------------------------------------------------------------------------- 00044 // 00045 CChoiceListExAppUi::CChoiceListExAppUi() 00046 { 00047 // no implementation required 00048 } 00049 00050 // ----------------------------------------------------------------------------- 00051 // CChoiceListExAppUi::~CChoiceListExAppUi() 00052 // Destructor. 00053 // ----------------------------------------------------------------------------- 00054 // 00055 CChoiceListExAppUi::~CChoiceListExAppUi() 00056 { 00057 if ( iAppContainer ) 00058 { 00059 RemoveFromStack( iAppContainer ); 00060 delete iAppContainer; 00061 } 00062 } 00063 00064 // ----------------------------------------------------------------------------- 00065 // CChoiceListExAppUi::HandleCommandL() 00066 // Takes care of command handling. 00067 // ----------------------------------------------------------------------------- 00068 // 00069 void CChoiceListExAppUi::HandleCommandL( TInt aCommand ) 00070 { 00071 switch( aCommand ) 00072 { 00073 case EEikCmdExit: 00074 case EAknSoftkeyExit: 00075 Exit(); 00076 break; 00077 00078 case ECmdCreateDefault: 00079 iAppContainer->CreateDefaultChoiceListL(); 00080 iMenuFlags.ClearAll(); 00081 iMenuFlags.Set( ECmdCreateDefault ); 00082 break; 00083 00084 case ECmdCreateButton: 00085 iAppContainer->CreateButtonChoiceListL(); 00086 iMenuFlags.ClearAll(); 00087 iMenuFlags.Set( ECmdCreateButton ); 00088 break; 00089 00090 case ECmdCreateResource: 00091 iAppContainer->CreateResourceChoiceListL(); 00092 iMenuFlags.ClearAll(); 00093 iMenuFlags.Set( ECmdCreateResource ); 00094 break; 00095 00096 case ECmdShowList: 00097 iAppContainer->ShowListL(); 00098 break; 00099 00100 case ECmdAddItem: 00101 iAppContainer->AddItemL(); 00102 break; 00103 00104 case ECmdInsertItem: 00105 iAppContainer->InsertItemL(); 00106 break; 00107 00108 case ECmdRemoveItem: 00109 iAppContainer->RemoveItemL(); 00110 break; 00111 00112 case ECmdSelectItem: 00113 iAppContainer->SelectItemL(); 00114 break; 00115 00116 case ECmdListPosLeft: 00117 iAppContainer->ChangeListFlagsL( 00118 CAknChoiceList::EAknChoiceListPositionLeft ); 00119 break; 00120 case ECmdListPosRight: 00121 iAppContainer->ChangeListFlagsL( 00122 CAknChoiceList::EAknChoiceListPositionRight ); 00123 break; 00124 00125 case ECmdListPosBottom: 00126 iAppContainer->ChangeListFlagsL( 00127 CAknChoiceList::EAknChoiceListPositionBottom ); 00128 break; 00129 00130 default: 00131 return; 00132 } 00133 iAppContainer->DrawDeferred(); 00134 } 00135 00136 // ----------------------------------------------------------------------------- 00137 // CChoiceListExAppUi::DynInitMenuPaneL() 00138 // Updates options menu 00139 // ----------------------------------------------------------------------------- 00140 // 00141 void CChoiceListExAppUi::DynInitMenuPaneL( TInt aMenuId, 00142 CEikMenuPane* aMenuPane ) 00143 { 00144 // Options menu item dimming 00145 if ( aMenuId == R_CHOICELISTEX_MENU ) 00146 { 00147 TBool dim ( ETrue ); 00148 if ( iMenuFlags.IsSet( ECmdCreateDefault ) || 00149 iMenuFlags.IsSet( ECmdCreateButton) || 00150 iMenuFlags.IsSet( ECmdCreateResource )) 00151 { 00152 dim = EFalse; 00153 } 00154 00155 aMenuPane->SetItemDimmed( ECmdAddItem, dim ); 00156 aMenuPane->SetItemDimmed( ECmdInsertItem, dim ); 00157 aMenuPane->SetItemDimmed( ECmdRemoveItem, dim ); 00158 aMenuPane->SetItemDimmed( ECmdSelectItem, dim ); 00159 aMenuPane->SetItemDimmed( ECmdPositionMenu, dim ); 00160 aMenuPane->SetItemDimmed( ECmdShowList, dim ); 00161 aMenuPane->SetItemDimmed( ECmdShowList, dim ); 00162 } 00163 } 00164 00165
|
© Nokia 2009 |