|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================ 00003 * Name : datamobilityappmenucontainer.cpp 00004 * Part of : datamobility 00005 * Description : CDataMobilityAppMenuContainer implementation. 00006 * 00007 * Copyright (c) 2007 Nokia Corporation. 00008 * This material, including documentation and any related 00009 * computer programs, is protected by copyright controlled by 00010 * Nokia Corporation. 00011 * ============================================================================ 00012 */ 00013 00014 // INCLUDE FILES 00015 #include <aknlists.h> // ListBox 00016 #include <barsread.h> // for TResourceReader 00017 #include <AknUtils.h> 00018 00019 #include "datamobilityappmenucontainer.h" 00020 #include "datamobility.hrh" 00021 #include <datamobility.rsg> 00022 00023 // ============================ MEMBER FUNCTIONS =============================== 00024 00025 // ----------------------------------------------------------------------------- 00026 // CDataMobilityAppMenuContainer::ConstructL 00027 // 00028 // Symbian OS two phased constructor 00029 // ----------------------------------------------------------------------------- 00030 // 00031 void CDataMobilityAppMenuContainer::ConstructL( const TRect& aRect ) 00032 { 00033 CreateWindowL(); 00034 00035 iListBox = new ( ELeave ) CAknSingleStyleListBox(); 00036 iListBox->SetContainerWindowL( *this ); 00037 TResourceReader reader; 00038 iCoeEnv->CreateResourceReaderLC( reader, R_MENU_LISTBOX ); 00039 iListBox->SetListBoxObserver( this ); 00040 iListBox->ConstructFromResourceL( reader ); 00041 CleanupStack::PopAndDestroy(); // resource stuffs. 00042 iListBox->ActivateL(); // Sets control as ready to be drawn 00043 00044 SetRect( aRect ); 00045 ActivateL(); 00046 } 00047 00048 00049 // ----------------------------------------------------------------------------- 00050 // CDataMobilityAppMenuContainer::~CDataMobilityAppMenuContainer 00051 // 00052 // Destructor 00053 // ----------------------------------------------------------------------------- 00054 // 00055 CDataMobilityAppMenuContainer::~CDataMobilityAppMenuContainer() 00056 { 00057 if( iListBox ) 00058 { 00059 delete iListBox; 00060 iListBox = NULL; 00061 } 00062 } 00063 00064 // ----------------------------------------------------------------------------- 00065 // CDataMobilityAppMenuContainer::SizeChanged 00066 // 00067 // Called by framework when the view size is changed 00068 // ----------------------------------------------------------------------------- 00069 // 00070 void CDataMobilityAppMenuContainer::SizeChanged() 00071 { 00072 if ( iListBox ) 00073 { 00074 iListBox->SetRect( Rect() ); // Sets rectangle of listbox. 00075 } 00076 } 00077 00078 // ----------------------------------------------------------------------------- 00079 // CDataMobilityAppMenuContainer::CountComponentControls 00080 // 00081 // Returns number of controls indside this container. 00082 // ----------------------------------------------------------------------------- 00083 // 00084 TInt CDataMobilityAppMenuContainer::CountComponentControls() const 00085 { 00086 return 1; 00087 } 00088 00089 // ----------------------------------------------------------------------------- 00090 // CDataMobilityAppMenuContainer::ComponentControl 00091 // 00092 // Gets the specified component of a compound control. 00093 // ----------------------------------------------------------------------------- 00094 // 00095 CCoeControl* CDataMobilityAppMenuContainer::ComponentControl( TInt aIndex ) const 00096 { 00097 switch ( aIndex ) 00098 { 00099 case 0: 00100 return iListBox; 00101 default: 00102 return NULL; 00103 } 00104 } 00105 00106 // ----------------------------------------------------------------------------- 00107 // CDataMobilityAppMenuContainer::HandleListBoxEventL 00108 // 00109 // Handles list box events. 00110 // ----------------------------------------------------------------------------- 00111 // 00112 void CDataMobilityAppMenuContainer::HandleListBoxEventL( CEikListBox* aListBox, 00113 TListBoxEvent aEventType ) 00114 { 00115 if ( aEventType == EEventEnterKeyPressed && aListBox ) 00116 { 00117 HandleSelectedListItemL( aListBox->CurrentItemIndex() ); 00118 } 00119 } 00120 00121 // ---------------------------------------------------------------------------- 00122 // CDataMobilityAppMenuContainer::HandleSelectedListItemL 00123 // 00124 // Method HandleSelectedListItemL handles valix index. 00125 // ---------------------------------------------------------------------------- 00126 // 00127 void CDataMobilityAppMenuContainer::HandleSelectedListItemL( TInt aIndex ) const 00128 { 00129 CEikAppUi* appUi = static_cast<CEikAppUi*>( iCoeEnv->AppUi() ); 00130 00131 // Change active view. 00132 switch ( aIndex ) 00133 { 00134 case 0: 00135 appUi->HandleCommandL( EAppUIGoToStandardApplication ); 00136 break; 00137 case 1: 00138 appUi->HandleCommandL( EAppUIGoToApplicationUsingSnap ); 00139 break; 00140 case 2: 00141 appUi->HandleCommandL( EAppUIGoToTriggeringConnectionDialog ); 00142 break; 00143 case 3: 00144 appUi->HandleCommandL( EAppUIGoToALRApplication ); 00145 break; 00146 case 4: 00147 appUi->HandleCommandL( EAppUIGoToALRApplicationUsingDefaultConnection ); 00148 break; 00149 case 5: 00150 appUi->HandleCommandL( EAppUIGoToUsingConnectionSetting ); 00151 break; 00152 default: 00153 break; 00154 } 00155 } 00156 00157 // ----------------------------------------------------------------------------- 00158 // CDataMobilityAppMenuContainer::OfferKeyEventL 00159 // 00160 // Handles key events. 00161 // ----------------------------------------------------------------------------- 00162 // 00163 TKeyResponse CDataMobilityAppMenuContainer::OfferKeyEventL( 00164 const TKeyEvent& aKeyEvent, TEventCode aType ) 00165 { 00166 if ( aType != EEventKey ) 00167 { 00168 return EKeyWasNotConsumed; 00169 } 00170 00171 // Offers key events to list box 00172 if ( iListBox ) 00173 { 00174 return iListBox->OfferKeyEventL( aKeyEvent, aType ); 00175 } 00176 else 00177 { 00178 return EKeyWasNotConsumed; 00179 } 00180 } 00181 00182 // ---------------------------------------------------------------------------- 00183 // CDataMobilityAppMenuContainer:::GetActiveLine 00184 // 00185 // Get currently selected items index. 00186 // ---------------------------------------------------------------------------- 00187 // 00188 TInt CDataMobilityAppMenuContainer::GetActiveLine() const 00189 { 00190 return iListBox->CurrentItemIndex(); 00191 } 00192 00193 // --------------------------------------------------------- 00194 // CDataMobilityAppMenuContainer::HandleResourceChange() 00195 // 00196 // Called by framework when layout is changed. 00197 // --------------------------------------------------------- 00198 // 00199 void CDataMobilityAppMenuContainer::HandleResourceChange( TInt aType ) 00200 { 00201 CCoeControl::HandleResourceChange( aType ); 00202 00203 // ADDED FOR SCALABLE UI SUPPORT 00204 // ***************************** 00205 if ( aType == KEikDynamicLayoutVariantSwitch ) 00206 { 00207 TRect rect; 00208 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, rect ); 00209 SetRect( rect ); 00210 } 00211 } 00212 00213 // End of File
|
© Nokia 2009 |