|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : SIPExGameView.cpp 00004 * Part of : SIPEx 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 <aknviewappui.h> 00018 #include <eikmenup.h> // CEikMenupane 00019 #include <avkon.hrh> 00020 #include <SIPEx.rsg> 00021 #include "SIPExGameView.h" 00022 #include "SIPExGameContainer.h" 00023 #include "SIPExAppUi.h" 00024 #include "SIPExDoc.h" 00025 00026 00027 // ============================ MEMBER FUNCTIONS =============================== 00028 00029 // ----------------------------------------------------------------------------- 00030 // CSIPExGameView::NewL 00031 // EPOC two-phase construction 00032 // ----------------------------------------------------------------------------- 00033 // 00034 CSIPExGameView* CSIPExGameView::NewLC( CSIPExEngine& aEngine ) 00035 { 00036 CSIPExGameView* self = new ( ELeave ) CSIPExGameView( aEngine ); 00037 CleanupStack::PushL( self ); 00038 self->ConstructL(); 00039 return self; 00040 } 00041 00042 // ----------------------------------------------------------------------------- 00043 // CSIPExGameView::CSIPExGameView 00044 // C++ default constructor 00045 // ----------------------------------------------------------------------------- 00046 // 00047 CSIPExGameView::CSIPExGameView( CSIPExEngine& aEngine ) 00048 : iEngine( aEngine ) 00049 { 00050 } 00051 00052 // ----------------------------------------------------------------------------- 00053 // CSIPExGameView::ConstructL 00054 // EPOC second-phased constructor 00055 // ----------------------------------------------------------------------------- 00056 // 00057 void CSIPExGameView::ConstructL() 00058 { 00059 BaseConstructL( R_SIP_EX_VIEW1 ); 00060 } 00061 00062 // ----------------------------------------------------------------------------- 00063 // CSIPExGameView::~CSIPExGameView 00064 // Default destructor 00065 // ----------------------------------------------------------------------------- 00066 // 00067 CSIPExGameView::~CSIPExGameView() 00068 { 00069 if ( iContainer ) 00070 { 00071 AppUi()->RemoveFromViewStack( *this, iContainer ); 00072 } 00073 00074 delete iContainer; 00075 } 00076 00077 // ----------------------------------------------------------------------------- 00078 // TUid CSIPExGameView::Id 00079 // This returns the view ID 00080 // ----------------------------------------------------------------------------- 00081 // 00082 TUid CSIPExGameView::Id() const 00083 { 00084 return KGameViewId; 00085 } 00086 00087 // ----------------------------------------------------------------------------- 00088 // CSIPExGameView::HandleCommandL 00089 // Here we handle commands for this view. 00090 // ----------------------------------------------------------------------------- 00091 // 00092 void CSIPExGameView::HandleCommandL( TInt aCommand ) 00093 { 00094 switch ( aCommand ) 00095 { 00096 00097 case EAknSoftkeyBack: 00098 { 00099 AppUi()->HandleCommandL( EEikCmdExit ); 00100 break; 00101 } 00102 00103 default: 00104 { 00105 AppUi()->HandleCommandL( aCommand ); 00106 break; 00107 } 00108 } 00109 } 00110 00111 // ----------------------------------------------------------------------------- 00112 // CSIPExGameView::HandleViewRectChange() 00113 // ----------------------------------------------------------------------------- 00114 // 00115 void CSIPExGameView::HandleViewRectChange() 00116 { 00117 if ( iContainer ) 00118 { 00119 iContainer->SetRect( ClientRect() ); 00120 } 00121 } 00122 00123 // ----------------------------------------------------------------------------- 00124 // CSIPExGameView::DynInitMenuPaneL 00125 // Handles menu initialization event. 00126 // ----------------------------------------------------------------------------- 00127 // 00128 void CSIPExGameView::DynInitMenuPaneL( 00129 TInt aResourceId, 00130 CEikMenuPane* aMenuPane ) 00131 { 00132 if ( aResourceId != R_SIP_EX_MENU ) 00133 { 00134 // Not this view's menu, ignore 00135 return; 00136 } 00137 00138 switch ( static_cast< CSIPExAppUi* >( AppUi() )->EngineState() ) 00139 { 00140 case CSIPExEngine::EIdle: 00141 aMenuPane->SetItemDimmed( ECmdInviteForGame, ETrue ); 00142 aMenuPane->SetItemDimmed( ECmdEnableProfile, EFalse ); 00143 aMenuPane->SetItemDimmed( ECmdDisableProfile, ETrue ); 00144 aMenuPane->SetItemDimmed( ECmdSendIM, ETrue ); 00145 aMenuPane->SetItemDimmed( ECmdEndGame, ETrue ); 00146 break; 00147 case CSIPExEngine::EEnabled: 00148 aMenuPane->SetItemDimmed( ECmdInviteForGame, EFalse ); 00149 aMenuPane->SetItemDimmed( ECmdEnableProfile, ETrue ); 00150 aMenuPane->SetItemDimmed( ECmdDisableProfile, EFalse ); 00151 aMenuPane->SetItemDimmed( ECmdSendIM, EFalse ); 00152 aMenuPane->SetItemDimmed( ECmdEndGame, ETrue ); 00153 break; 00154 case CSIPExEngine::EActivating: 00155 aMenuPane->SetItemDimmed( ECmdInviteForGame, ETrue ); 00156 aMenuPane->SetItemDimmed( ECmdEnableProfile, ETrue ); 00157 aMenuPane->SetItemDimmed( ECmdDisableProfile, ETrue ); 00158 aMenuPane->SetItemDimmed( ECmdSendIM, EFalse ); 00159 aMenuPane->SetItemDimmed( ECmdEndGame, ETrue ); 00160 break; 00161 case CSIPExEngine::EActive: 00162 aMenuPane->SetItemDimmed( ECmdInviteForGame, ETrue ); 00163 aMenuPane->SetItemDimmed( ECmdEnableProfile, ETrue ); 00164 aMenuPane->SetItemDimmed( ECmdDisableProfile, ETrue ); 00165 aMenuPane->SetItemDimmed( ECmdSendIM, EFalse ); 00166 aMenuPane->SetItemDimmed( ECmdEndGame, EFalse ); 00167 break; 00168 default: 00169 break; 00170 } 00171 } 00172 00173 // ----------------------------------------------------------------------------- 00174 // CSIPExGameView::DoActivateL 00175 // This is called when a view needs to be activated. 00176 // This creates container with its controls. 00177 // It also receives messages sent to the view. 00178 // ----------------------------------------------------------------------------- 00179 // 00180 void CSIPExGameView::DoActivateL( 00181 const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, 00182 const TDesC8& /*aCustomMessage*/ ) 00183 { 00184 if ( !iContainer ) 00185 { 00186 iContainer = new ( ELeave ) CSIPExGameContainer( iEngine ); 00187 iContainer->SetMopParent( this ); 00188 iContainer->ConstructL( ClientRect() ); 00189 AppUi()->AddToStackL( *this, iContainer ); 00190 } 00191 } 00192 00193 // ----------------------------------------------------------------------------- 00194 // CSIPExGameView::HandleCommandL 00195 // This is called when a view needs to be deactivated. 00196 // This destroys container with its controls. 00197 // ----------------------------------------------------------------------------- 00198 // 00199 void CSIPExGameView::DoDeactivate() 00200 { 00201 if ( iContainer ) 00202 { 00203 AppUi()->RemoveFromViewStack( *this, iContainer ); 00204 } 00205 00206 delete iContainer; 00207 iContainer = NULL; 00208 } 00209 00210 // ----------------------------------------------------------------------------- 00211 // CSIPExGameView::Container 00212 // ----------------------------------------------------------------------------- 00213 // 00214 CSIPExGameContainer* CSIPExGameView::Container() 00215 { 00216 return iContainer; 00217 } 00218 00219 // End of File 00220
|
© Nokia 2006 |