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

Symbian

开发平台:

C/C++

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