Binary files step4/bitmaps/tlo.bmp and step5/bitmaps/tlo.bmp differ diff -urN step4/group/S60test.mmp step5/group/S60test.mmp --- step4/group/S60test.mmp 2004-06-19 20:27:56.000000000 +0200 +++ step5/group/S60test.mmp 2004-06-19 19:58:44.000000000 +0200 @@ -1,7 +1,7 @@ -TARGET Step4.app +TARGET Step5.app TARGETTYPE app -UID 0x100039CE 0x04545FF4 -TARGETPATH \system\apps\Step4 +UID 0x100039CE 0x04545FF5 +TARGETPATH \system\apps\Step5 LANG SC SOURCEPATH ..\src @@ -15,12 +15,20 @@ SOURCE Grid.cpp SOURCEPATH ..\group -RESOURCE Step4.rss +RESOURCE Step5.rss USERINCLUDE ..\inc SYSTEMINCLUDE \epoc32\include +START BITMAP S60Test.mbm +HEADER +TARGETPATH \system\apps\step5 +SOURCEPATH ..\bitmaps +SOURCE c12 tlo.bmp +END + + LIBRARY euser.lib LIBRARY apparc.lib LIBRARY cone.lib diff -urN step4/group/Step5.rss step5/group/Step5.rss --- step4/group/Step5.rss 2004-06-19 20:46:58.000000000 +0200 +++ step5/group/Step5.rss 2004-06-19 19:50:44.000000000 +0200 @@ -41,7 +41,7 @@ // --------------------------------------------------------- -// +// // r_helloworld_menubar // Menubar for HelloWorld example // @@ -73,8 +73,27 @@ }; } +RESOURCE TBUF16 r_menu_pause_title +{ + buf = "Pause"; +} + +RESOURCE TBUF16 r_menu_unpause_title +{ + buf = "Unpause"; +} + RESOURCE TBUF32 r_note_game_over { buf = "Game Over"; } +RESOURCE TBUF32 r_format_score +{ + buf = "Score: %d"; +} + +RESOURCE TBUF32 r_format_level +{ + buf = "Level: %d"; +} diff -urN step4/inc/s60testappui.h step5/inc/s60testappui.h --- step4/inc/s60testappui.h 2004-06-19 20:29:04.000000000 +0200 +++ step5/inc/s60testappui.h 2004-06-20 10:46:36.000000000 +0200 @@ -21,6 +21,7 @@ void HandleCommandL(TInt aCommand); TKeyResponse HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/); + void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane *aMenuPane); private: CS60TestEngine *iEngine; diff -urN step4/inc/s60testappview.h step5/inc/s60testappview.h --- step4/inc/s60testappview.h 2004-06-20 10:31:56.000000000 +0200 +++ step5/inc/s60testappview.h 2004-06-20 16:22:22.000000000 +0200 @@ -15,15 +15,21 @@ ~CS60TestAppView(); static const TUint32 KColors[10]; + CFbsBitmap *iBackground; public: // from CCoeControl void Draw(const TRect& aRect) const; +protected: + void FocusChanged(TDrawNow aDrawNow); + private: void ConstructL(const TRect& aRect); CS60TestAppView(CS60TestDocument *aDoc, CS60TestEngine *aEngine); CS60TestDocument *iDoc; CS60TestEngine *iEngine; + TBuf<32> iFormatLevel, iFormatScore; + bool iFocus; }; diff -urN step4/inc/s60testengine.h step5/inc/s60testengine.h --- step4/inc/s60testengine.h 2004-06-21 18:55:36.000000000 +0200 +++ step5/inc/s60testengine.h 2004-01-11 21:51:06.000000000 +0100 @@ -16,9 +16,15 @@ void KeyRotate(int dir); void KeyDrop(); + void TechPause() { iTechPauseRef++; DoPause(); } + void TechUnpause() { iTechPauseRef--; DoPause(); } + void Pause() { iPauseRef=1; DoPause(); } + void Unpause() { iPauseRef=0; DoPause(); } + void Reset(); int iInterval; + int iPauseRef, iTechPauseRef; TTime iBeginTime; TTime iPauseTime; @@ -37,6 +43,7 @@ :CTimer(EPriorityStandard), iInterval(500000), iDoc(aDoc) { } void RunL(); void ConstructL(); + void DoPause(); }; #endif diff -urN step4/src/s60testapplication.cpp step5/src/s60testapplication.cpp --- step4/src/s60testapplication.cpp 2004-06-20 10:31:26.000000000 +0200 +++ step5/src/s60testapplication.cpp 2004-06-20 10:44:26.000000000 +0200 @@ -2,7 +2,7 @@ #include "S60TestApplication.h" // UID for the application, this should correspond to the uid defined in the mmp file -static const TUid KUidS60TestApp = {0x04545FF4}; +static const TUid KUidS60TestApp = {0x04545FF5}; CApaDocument* CS60TestApplication::CreateDocumentL() { diff -urN step4/src/s60testappui.cpp step5/src/s60testappui.cpp --- step4/src/s60testappui.cpp 2004-06-20 10:28:08.000000000 +0200 +++ step5/src/s60testappui.cpp 2004-06-20 13:46:10.000000000 +0200 @@ -1,12 +1,13 @@ #include #include -#include +#include #include "S60Test.pan" #include "S60TestDocument.h" #include "S60TestAppUi.h" #include "S60TestAppView.h" #include "S60Test.hrh" +#include "Step5.rsg" void CS60TestAppUi::ConstructL() { @@ -39,6 +40,16 @@ iAppView->DrawDeferred(); } +void CS60TestAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane *aMenuPane) +{ + if (aResourceId==R_S60TEST_MENU) + { + if (iEngine->iPauseRef>0) + aMenuPane->SetItemTextL(ES60TestPause, R_MENU_UNPAUSE_TITLE); + else aMenuPane->SetItemTextL(ES60TestPause, R_MENU_PAUSE_TITLE); + } +} + // handle any menu commands void CS60TestAppUi::HandleCommandL(TInt aCommand) { @@ -55,6 +66,11 @@ UpdateBoard(); break; + case ES60TestPause: + if (iEngine->iPauseRef>0) iEngine->Unpause(); + else iEngine->Pause(); + break; + default: Panic(ES60TestBasicUi); break; diff -urN step4/src/s60testappview.cpp step5/src/s60testappview.cpp --- step4/src/s60testappview.cpp 2004-06-20 16:23:20.000000000 +0200 +++ step5/src/s60testappview.cpp 2004-06-20 16:22:04.000000000 +0200 @@ -4,6 +4,8 @@ #include "S60TestAppView.h" #include "S60TestDocument.h" #include "S60TestEngine.h" +#include "S60Test.mbg" +#include "Step5.rsg" const TUint32 CS60TestAppView::KColors[10]= {0xffffff, 0xff0000, 0x00ff00, 0x0000ff, 0xff00ff, @@ -27,20 +29,45 @@ CS60TestAppView::CS60TestAppView(CS60TestDocument *aDoc, CS60TestEngine *aEngine) { iDoc=aDoc; + iFocus=true; iEngine=aEngine; + CEikonEnv::Static()->ReadResource(iFormatLevel, R_FORMAT_LEVEL); + CEikonEnv::Static()->ReadResource(iFormatScore, R_FORMAT_SCORE); } CS60TestAppView::~CS60TestAppView() { + delete iBackground; } void CS60TestAppView::ConstructL(const TRect& aRect) { + _LIT(iPathName, "\\System\\Apps\\Step5\\S60Test.mbm"); + iBackground=CEikonEnv::Static()->CreateBitmapL(iPathName, EMbmS60testTlo); CreateWindowL(); SetRect(aRect); ActivateL(); } +void CS60TestAppView::FocusChanged(TDrawNow aDrawNow) +{ + if (IsFocused()) + { + if (!iFocus) + { + iFocus=true; + iEngine->TechUnpause(); + } + } else + { + if (iFocus) + { + iFocus=false; + iEngine->TechPause(); + } + } +} + const int KCellSize=7; const int KBoardOffset=2; @@ -48,21 +75,19 @@ { CWindowGc &gc=SystemGc(); TRect rect=Rect(); - gc.Clear(rect); + + gc.UseFont(iCoeEnv->NormalFont()); + gc.DrawBitmap(TPoint(0, 0), iBackground); + TBuf<32> napis, format; + napis.Format(iFormatScore, iDoc->iScore); + gc.DrawText(napis, TPoint(83, 90)); + napis.Format(iFormatLevel, iDoc->iLevel); + gc.DrawText(napis, TPoint(83, 126)); int i, j; TFixedArray arr; gc.SetPenColor(TRgb(0)); gc.SetBrushStyle(CWindowGc::ESolidBrush); - - for (i=0; i<=KGridY; i++) - gc.DrawLine(TPoint(KBoardOffset, KBoardOffset+KCellSize*i), - TPoint(KBoardOffset+KGridX*KCellSize, KBoardOffset+KCellSize*i)); - - for (i=0; i<=KGridX; i++) - gc.DrawLine(TPoint(KBoardOffset+KCellSize*i, KBoardOffset), - TPoint(KBoardOffset+KCellSize*i, KBoardOffset+KGridY*KCellSize)); - for (i=0; iGetRowContent(i, arr); diff -urN step4/src/s60testengine.cpp step5/src/s60testengine.cpp --- step4/src/s60testengine.cpp 2004-06-21 18:56:10.000000000 +0200 +++ step5/src/s60testengine.cpp 2004-06-21 19:15:56.000000000 +0200 @@ -4,7 +4,7 @@ #include "s60testdocument.h" #include "s60testengine.h" #include "s60test.pan" -#include "step4.rsg" +#include "step5.rsg" CS60TestEngine *CS60TestEngine::NewLC(CS60TestDocument *aDoc) { @@ -55,8 +55,42 @@ { if (iState==ERunning) Cancel(); - iState=ERunning; - After(iInterval); + iPauseRef=0; + if (iTechPauseRef==0) + { + After(iInterval); + iState=ERunning; + } else + { + iPauseTime.HomeTime(); + iBeginTime.HomeTime(); + iState=EPaused; + } +} + +void CS60TestEngine::DoPause() +{ + __ASSERT_ALWAYS(iPauseRef>=0 && iTechPauseRef>=0, Panic(ES60TestAssert)); + + if (iPauseRef==0 && iTechPauseRef==0) + { + if (iState==EPaused) + { + int ms=iPauseTime.MicroSecondsFrom(iBeginTime).Int64().GetTInt(); + if (ms<0 || ms>iInterval) + ms=0; + iState=ERunning; + After(iInterval-ms); + } + } else + { + if (iState==ERunning) + { + iState=EPaused; + iPauseTime.HomeTime(); + Cancel(); + } + } } void CS60TestEngine::RunL()