S60UIExamplePlayView.cpp
上传用户:laixiong
上传日期:2007-03-11
资源大小:2994k
文件大小:5k
源码类别:

Symbian

开发平台:

C/C++

  1. // Copyright (c) 2006 Nokia Corporation.
  2. #include "S60UIExamplePlayView.h"
  3. #include "S60UIExamplePlayContainer.h"
  4. #include "S60UIExampleModel.h"
  5. #include "S60UIExample.hrh"
  6. #include <aknviewappui.h>
  7. #include <S60UIExample.rsg>
  8. #include <stringloader.h>    
  9. // -----------------------------------------------------------------------------
  10. // CS60UIExamplePlayView::CS60UIExamplePlayView()
  11. // C++ default constructor can NOT contain any code, that might leave.
  12. // -----------------------------------------------------------------------------
  13. //
  14. CS60UIExamplePlayView::CS60UIExamplePlayView(CS60UIExampleModel& aModel)
  15.     :iModel(aModel)
  16.     {
  17.     // No implementation required
  18.     }
  19. // -----------------------------------------------------------------------------
  20. // CS60UIExamplePlayView::NewL()
  21. // Two-phased constructor.
  22. // -----------------------------------------------------------------------------
  23. //
  24. CS60UIExamplePlayView* CS60UIExamplePlayView::NewL(CS60UIExampleModel& aModel)
  25.     {
  26.     CS60UIExamplePlayView* self = CS60UIExamplePlayView::NewLC(aModel);
  27.     CleanupStack::Pop(self);
  28.     return self;
  29.     }
  30. // -----------------------------------------------------------------------------
  31. // CS60UIExamplePlayView::NewLC()
  32. // Two-phased constructor.
  33. // -----------------------------------------------------------------------------
  34. //
  35. CS60UIExamplePlayView* CS60UIExamplePlayView::NewLC(CS60UIExampleModel& aModel)
  36.     {
  37.     CS60UIExamplePlayView* self = new (ELeave) CS60UIExamplePlayView(aModel);
  38.     CleanupStack::PushL(self);
  39.     self->ConstructL();
  40.     return self;
  41.     }
  42. // -----------------------------------------------------------------------------
  43. // CS60UIExamplePlayView::ConstructL()
  44. // Symbian 2nd phase constructor can leave.
  45. // -----------------------------------------------------------------------------
  46. //
  47. void CS60UIExamplePlayView::ConstructL()
  48.     {
  49.     BaseConstructL(R_S60UIEXAMPLE_PLAYVIEW);
  50.     }
  51. // -----------------------------------------------------------------------------
  52. // CS60UIExamplePlayView::~CS60UIExamplePlayView()
  53. // Destructor.
  54. // -----------------------------------------------------------------------------
  55. //
  56. CS60UIExamplePlayView::~CS60UIExamplePlayView()
  57.     {
  58.     // No implementation required
  59.     }
  60. // -----------------------------------------------------------------------------
  61. // CS60UIExamplePlayView::Id()
  62. // Returns View's ID.
  63. // -----------------------------------------------------------------------------
  64. //
  65. TUid CS60UIExamplePlayView::Id() const
  66.     {
  67.     return TUid::Uid(ES60UIExamplePlayViewId);
  68.     }
  69. // -----------------------------------------------------------------------------
  70. // CS60UIExamplePlayView::DoActivateL()
  71. // Activate the View
  72. // -----------------------------------------------------------------------------
  73. //
  74. void CS60UIExamplePlayView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
  75.                                         TUid /*aCustomMessageId*/,
  76.                                         const TDesC8& /*aCustomMessage*/)
  77.     {
  78.     iContainer = CS60UIExamplePlayContainer::NewL(ClientRect(), iModel);
  79.     AppUi()->AddToViewStackL(*this, iContainer);
  80.     }
  81. // -----------------------------------------------------------------------------
  82. // CS60UIExamplePlayView::DoDeactivate()
  83. // -----------------------------------------------------------------------------
  84. //
  85. void CS60UIExamplePlayView::DoDeactivate()
  86.     {
  87.     if (iContainer)
  88.         {
  89.         AppUi()->RemoveFromViewStack(*this, iContainer);
  90.         delete iContainer;
  91.         iContainer = NULL;
  92.         }
  93.         
  94.     }
  95. // -----------------------------------------------------------------------------
  96. // CS60UIExamplePlayView::HandleCommandL()
  97. // Takes care of Command handling.
  98. // -----------------------------------------------------------------------------
  99. //
  100. void CS60UIExamplePlayView::HandleCommandL(TInt aCommand)
  101.     {
  102.     switch (aCommand)
  103.         {
  104.         case ES60UIExampleStopGame:
  105.             {
  106.             iModel.GameStop();
  107.             // Switch back to initial view
  108.             AppUi()->ActivateLocalViewL(TUid::Uid(ES60UIExampleInitialViewId));
  109.             break;
  110.             }
  111.             
  112.         case ES60UIExampleStartGame:
  113.             {
  114.             iModel.GameStart();
  115.             // Get reset scores to navi pane
  116.             iContainer->UpdateNaviPaneL();
  117.             // Draw game image (without paused text)
  118.             iContainer->DrawNow();
  119.             break;
  120.             }
  121.             
  122.         case ES60UIExampleContinueGame:
  123.             iModel.GameContinue();
  124.             // Draw game image (without paused text)
  125.             iContainer->DrawNow();
  126.             break;
  127.             
  128.         case ES60UIExamplePauseGame:
  129.             iModel.GamePause();
  130.             // Draw game image (with paused text)
  131.             iContainer->DrawNow();
  132.             break;
  133.             
  134.         default:
  135.             // pass anything else to the AppUi
  136.             AppUi()->HandleCommandL(aCommand);
  137.         }
  138.     }
  139. // End of File