|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
#include <IMOpenAPIExampleContainer.h>
Public Member Functions | |
| void | ConstructL (const TRect &aRect) |
| ~CIMOpenAPIExampleContainer () | |
| void | SetCellSign (const TGameSign aCellSign, const TInt aCellIndex) |
| void | SetMySign (const TGameSign aMySign) |
| void | SetGameView (const TGameState aDesiredView) |
| void | SetModel (CIMOpenAPIExamplemodel *aModel) |
| void | PlayMove () |
| void | ActivateL () |
| void | SizeChanged () |
| TInt | CountComponentControls () const |
| CCoeControl * | ComponentControl (TInt aIndex) const |
| void | Draw (const TRect &aRect) const |
| void | HandleControlEventL (CCoeControl *aControl, TCoeEvent aEventType) |
| TKeyResponse | OfferKeyEventL (const TKeyEvent &aKeyEvent, TEventCode aType) |
Private Member Functions | |
| void | LoadMySignBMPL (const TDesC &aImageFile) |
Private Attributes | |
| CEikLabel * | iTurnIndicator |
| CEikLabel * | iSignIndicator |
| CFbsBitmap * | iCrossSign |
| CFbsBitmap * | iZeroSign |
| CFbsBitmap * | iEmptySign |
| CFbsBitmap * | iMySignBMP |
| TGameSign | iMySign |
| TFileName | iImageFileName |
| CIMOpenAPIExamplemodel * | iModel |
| CIMOpenAPIExampleGrid * | iGamesGrid |
| CEikButtonGroupContainer * | iCba |
Definition at line 40 of file IMOpenAPIExampleContainer.h.
|
|
Destructor. Definition at line 92 of file IMOpenAPIExampleContainer.cpp. References iCrossSign, iEmptySign, iGamesGrid, iMySignBMP, iSignIndicator, iTurnIndicator, and iZeroSign. 00093 { 00094 delete iTurnIndicator; 00095 iTurnIndicator = NULL; 00096 00097 delete iSignIndicator; 00098 iSignIndicator = NULL; 00099 00100 delete iCrossSign; 00101 iCrossSign = NULL; 00102 00103 delete iMySignBMP; 00104 iMySignBMP = NULL; 00105 00106 delete iZeroSign; 00107 iZeroSign = NULL; 00108 00109 delete iEmptySign; 00110 iEmptySign = NULL; 00111 00112 delete iGamesGrid; 00113 iGamesGrid = NULL; 00114 00115 }
|
|
|
EPOC default constructor.
Definition at line 52 of file IMOpenAPIExampleContainer.cpp. References ActivateL(), CIMOpenAPIExampleGrid::ConstructL(), iCrossSign, iEmptySign, iGamesGrid, iImageFileName, iMySign, iMySignBMP, iSignIndicator, iTurnIndicator, iZeroSign, and LoadMySignBMPL(). 00053 { 00054 CreateWindowL(); 00055 00056 00057 iMySign = EZeroSign; 00058 00059 iTurnIndicator = new (ELeave) CEikLabel; 00060 iTurnIndicator->SetContainerWindowL( *this ); 00061 iTurnIndicator->SetTextL(KNullDesC); 00062 00063 iSignIndicator = new (ELeave) CEikLabel; 00064 iSignIndicator->SetContainerWindowL( *this ); 00065 iSignIndicator->SetTextL(KNullDesC); 00066 00067 00068 iCrossSign = new (ELeave) CFbsBitmap; 00069 iZeroSign = new (ELeave) CFbsBitmap; 00070 iEmptySign = new (ELeave) CFbsBitmap; 00071 iMySignBMP = new (ELeave) CFbsBitmap; 00072 00073 iImageFileName = KImageFilePath; 00074 iImageFileName.Append(KImageFileName); 00075 LoadMySignBMPL(iImageFileName); 00076 00077 // Construct the grid 00078 iGamesGrid = new (ELeave)CIMOpenAPIExampleGrid; 00079 iGamesGrid->SetContainerWindowL(*this); 00080 iGamesGrid->ConstructL(R_IMOPENAPIEXAMPLE_GRID, iImageFileName); 00081 00082 00083 SetRect(aRect); 00084 ActivateL(); 00085 }
|
|
||||||||||||
|
SetCellSign. Sets the graphical sign of given cell, either empty,cross or circle
Definition at line 269 of file IMOpenAPIExampleContainer.cpp. References iGamesGrid, and CIMOpenAPIExampleGrid::SetCellSign(). 00270 { 00271 iGamesGrid->SetCellSign(aCellSign, aCellIndex); 00272 DrawNow(); 00273 }
|
|
|
SetMySign. Sets the players own graphical sign either cross or zero
Definition at line 279 of file IMOpenAPIExampleContainer.cpp. References iImageFileName, iMySign, and LoadMySignBMPL(). 00280 { 00281 iMySign = mysign; 00282 LoadMySignBMPL(iImageFileName); 00283 DrawNow(); 00284 }
|
|
|
SetGameView. Sets the complete game view according the the give state of the game
Definition at line 290 of file IMOpenAPIExampleContainer.cpp. References iGamesGrid, iMySign, iSignIndicator, iTurnIndicator, CIMOpenAPIExampleGrid::ResetGrid(), and SizeChanged(). 00291 { 00292 TBuf<25> iTurnIndicatorString(KNullDesC); 00293 TBuf<25> iSignIndicatorString(KNullDesC); 00294 00295 switch (desiredView) 00296 { 00297 case EStateNotLogin: 00298 iGamesGrid->MakeVisible(EFalse); 00299 iSignIndicator->MakeVisible(EFalse); 00300 StringLoader::Load ( iTurnIndicatorString, R_INFO_MSG_NOT_LOGGEDIN ); 00301 iTurnIndicator->SetTextL(iTurnIndicatorString); 00302 break; 00303 00304 case EStateLoginIdle: 00305 iGamesGrid->MakeVisible(EFalse); 00306 iSignIndicator->MakeVisible(EFalse); 00307 StringLoader::Load ( iTurnIndicatorString, R_INFO_MSG_LOGIN_SUCCESS ); 00308 iTurnIndicator->SetTextL(iTurnIndicatorString); 00309 break; 00310 00311 case EStateChallenged: 00312 iGamesGrid->MakeVisible(EFalse); 00313 iSignIndicator->MakeVisible(EFalse); 00314 StringLoader::Load ( iTurnIndicatorString, R_INFO_MSG_WAITING_FOR_REPLY ); 00315 iTurnIndicator->SetTextL(iTurnIndicatorString); 00316 break; 00317 00318 case EStateReadytoStart: 00319 { 00320 iGamesGrid->MakeVisible(ETrue); 00321 iGamesGrid->SetDimmed(ETrue); 00322 iSignIndicator->MakeVisible(ETrue); 00323 StringLoader::Load ( iSignIndicatorString, R_INFO_MSG_YOUR_SIGN_IS ); 00324 iSignIndicator->SetTextL(iSignIndicatorString); 00325 if (iMySign == ECrossSign) 00326 StringLoader::Load ( iTurnIndicatorString, R_INFO_MSG_START_GAME ); 00327 else 00328 StringLoader::Load ( iTurnIndicatorString, R_INFO_MSG_WAITING_OPP_TO_START ); 00329 iTurnIndicator->SetTextL(iTurnIndicatorString); 00330 iGamesGrid->ResetGrid(); 00331 break; 00332 } 00333 00334 case EStateWaitingForOppMove: 00335 iGamesGrid->MakeVisible(ETrue); 00336 iGamesGrid->SetDimmed(ETrue); 00337 iSignIndicator->MakeVisible(ETrue); 00338 StringLoader::Load ( iSignIndicatorString, R_INFO_MSG_YOUR_SIGN_IS ); 00339 iSignIndicator->SetTextL(iSignIndicatorString); 00340 StringLoader::Load ( iTurnIndicatorString, R_INFO_MSG_OPPONENT_MOVE ); 00341 iTurnIndicator->SetTextL(iTurnIndicatorString); 00342 break; 00343 00344 00345 case EStateWaitingForOwnMove: 00346 iGamesGrid->MakeVisible(ETrue); 00347 iGamesGrid->SetDimmed(EFalse); 00348 iSignIndicator->MakeVisible(ETrue); 00349 StringLoader::Load ( iSignIndicatorString, R_INFO_MSG_YOUR_SIGN_IS ); 00350 iSignIndicator->SetTextL(iSignIndicatorString); 00351 StringLoader::Load ( iTurnIndicatorString, R_INFO_MSG_YOUR_MOVE ); 00352 iTurnIndicator->SetTextL(iTurnIndicatorString); 00353 break; 00354 00355 default: 00356 break; 00357 } 00358 00359 SizeChanged(); 00360 DrawNow(); 00361 return; 00362 }
|
|
|
SetModel. Sets the pointer to model
Definition at line 368 of file IMOpenAPIExampleContainer.cpp. References iModel. 00369 { 00370 iModel = aModel; 00371 }
|
|
|
PlayMove. Plays a move at focused grid index only if that position is empty Definition at line 255 of file IMOpenAPIExampleContainer.cpp. References iGamesGrid, iModel, iMySign, CIMOpenAPIExamplemodel::IsIndexPositionEmpty(), CIMOpenAPIExamplemodel::SendPlayedIndex(), and SetCellSign(). 00256 { 00257 TInt currentIndex = iGamesGrid->CurrentDataIndex(); 00258 if ( iModel->IsIndexPositionEmpty(currentIndex) ) 00259 { 00260 SetCellSign(iMySign, currentIndex); 00261 iModel->SendPlayedIndex(currentIndex); 00262 } 00263 }
|
|
|
ActivateL. From CCoeControl Definition at line 377 of file IMOpenAPIExampleContainer.cpp. References iCba. 00378 { 00379 CCoeControl::ActivateL(); 00380 if(iCba) 00381 { 00382 iCba->DrawableWindow()->SetOrdinalPosition(0); 00383 } 00384 else 00385 { 00386 iAvkonAppUi->Cba()->DrawableWindow()->SetOrdinalPosition(0); 00387 } 00388 }
|
|
|
From CoeControl,SizeChanged. Definition at line 122 of file IMOpenAPIExampleContainer.cpp. References iGamesGrid, iSignIndicator, and iTurnIndicator. 00123 { 00124 TSize selectedImageSize( 91, 91); 00125 TPoint selectedImageTopLeft( 70, 80 ); 00126 00127 iTurnIndicator->SetExtent( TPoint(1,2), iTurnIndicator->MinimumSize() ); 00128 iSignIndicator->SetExtent( TPoint(1,30), iSignIndicator->MinimumSize() ); 00129 00130 if (iGamesGrid) 00131 { 00132 iGamesGrid->SetExtent (selectedImageTopLeft,selectedImageSize); 00133 } 00134 00135 }
|
|
|
From CoeControl,CountComponentControls. Definition at line 141 of file IMOpenAPIExampleContainer.cpp.
|
|
|
From CCoeControl,ComponentControl. Definition at line 150 of file IMOpenAPIExampleContainer.cpp. References iGamesGrid, iSignIndicator, and iTurnIndicator. 00151 { 00152 switch ( aIndex ) 00153 { 00154 case 0: 00155 return iTurnIndicator; 00156 case 1: 00157 return iSignIndicator; 00158 case 2: 00159 return iGamesGrid; 00160 default: 00161 return NULL; 00162 } 00163 }
|
|
|
From CCoeControl,Draw. Definition at line 169 of file IMOpenAPIExampleContainer.cpp. References iMySignBMP. 00170 { 00171 CWindowGc& gc = SystemGc(); 00172 00173 gc.SetPenStyle( CGraphicsContext::ESolidPen ); 00174 gc.SetBrushColor( KRgbGreen ); 00175 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); 00176 gc.DrawRect( aRect ); 00177 00178 // Drawing my sign 00179 TSize selectedImageSize( 15, 15 ); 00180 TPoint selectedImageTopLeft( 160, 35 ); 00181 TRect mySignPlace( selectedImageTopLeft, selectedImageSize ); 00182 gc.DrawBitmap( mySignPlace, iMySignBMP ); 00183 00184 00185 }
|
|
||||||||||||
|
From MCoeControlObserver Acts upon changes in the hosted control's state.
Definition at line 192 of file IMOpenAPIExampleContainer.cpp.
|
|
||||||||||||
|
From CCoeControl. Sets the complete game view according the the give state of the game Definition at line 224 of file IMOpenAPIExampleContainer.cpp. References iGamesGrid, and PlayMove(). 00225 { 00226 00227 // if it's not an event key we're not interested so return not consumed 00228 if (aType != EEventKey) 00229 return EKeyWasNotConsumed; 00230 00231 TInt code = aKeyEvent.iCode; 00232 00233 if ( iGamesGrid && ( !iGamesGrid->IsDimmed() ) ) //&& iGamesGrid->IsFocused()) 00234 { 00235 if ( code == EKeyOK) 00236 { 00237 PlayMove(); 00238 return( EKeyWasConsumed ); 00239 } 00240 else 00241 { 00242 TKeyResponse returnValue = iGamesGrid->OfferKeyEventL( aKeyEvent, aType ); 00243 DrawNow(); 00244 return returnValue; 00245 } 00246 } 00247 00248 return EKeyWasNotConsumed; 00249 }
|
|
|
LoadMySignBMPL. Load the MBM file with given filename. MBM file contains images used in this application
Definition at line 202 of file IMOpenAPIExampleContainer.cpp. References iCrossSign, iEmptySign, iMySign, iMySignBMP, and iZeroSign. 00203 { 00204 TInt err; 00205 00206 err = iCrossSign->Load( aImageFile, 0, ETrue); 00207 User::LeaveIfError(err); 00208 00209 err = iZeroSign->Load( aImageFile, 1, ETrue); 00210 User::LeaveIfError(err); 00211 00212 err = iEmptySign->Load( aImageFile, 2, ETrue); 00213 User::LeaveIfError(err); 00214 00215 err = iMySignBMP->Load( aImageFile, iMySign, ETrue); 00216 User::LeaveIfError(err); 00217 00218 }
|
|
|
iTurnIndicator. Pointer to CEikLabel, a text label which shows whos turn it is Definition at line 154 of file IMOpenAPIExampleContainer.h. |
|
|
iSignIndicator. Pointer to CEikLabel, shows the players own sign text label Definition at line 160 of file IMOpenAPIExampleContainer.h. |
|
|
iCrossSign. Pointer to CFbsBitmap, Graphic of cross sign Definition at line 166 of file IMOpenAPIExampleContainer.h. |
|
|
iZeroSign. Pointer to CFbsBitmap, Graphic of circle sign Definition at line 172 of file IMOpenAPIExampleContainer.h. |
|
|
iEmptySign. Pointer to CFbsBitmap, Graphic of an empty sign Definition at line 178 of file IMOpenAPIExampleContainer.h. |
|
|
iMySignBMP. Pointer to CFbsBitmap, Graphic of user's own sign, cross or circle Definition at line 184 of file IMOpenAPIExampleContainer.h. |
|
|
iMySign. User's own sign in enum format Definition at line 190 of file IMOpenAPIExampleContainer.h. |
|
|
iImageFileName. Name of the image file where images used by this application are stored Definition at line 196 of file IMOpenAPIExampleContainer.h. |
|
|
iModel. Pointer to CIMOpenAPIExamplemodel Definition at line 202 of file IMOpenAPIExampleContainer.h. |
|
|
iGamesGrid. Pointer to CIMOpenAPIExampleGrid, container hold this object Definition at line 208 of file IMOpenAPIExampleContainer.h. |
|
|
iCba. To help draw screen correctly Definition at line 214 of file IMOpenAPIExampleContainer.h. |
|
© Nokia 2006 |