S60UIExampleInitialView.cpp
上传用户:laixiong
上传日期:2007-03-11
资源大小:2994k
文件大小:6k
源码类别:
Symbian
开发平台:
C/C++
- // Copyright (c) 2006 Nokia Corporation.
- #include "S60UIExampleInitialView.h"
- #include "S60UIExampleInitialContainer.h"
- #include "S60UIExampleModel.h"
- #include "S60UIExampleForm.h" // for the Register Form
- #include "S60UIExample.hrh"
- #include <aknviewappui.h>
- #include <S60UIExample.rsg>
- #include <eikmenup.h> // for CEikMenuPane
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialView::CS60UIExampleInitialView()
- // C++ default constructor can NOT contain any code, that might leave.
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleInitialView::CS60UIExampleInitialView(CS60UIExampleModel& aModel)
- :iModel(aModel)
- {
- // No implementation required
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialView::NewL()
- // Two-phased constructor.
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleInitialView* CS60UIExampleInitialView::NewL(
- CS60UIExampleModel& aModel)
- {
- CS60UIExampleInitialView* self = CS60UIExampleInitialView::NewLC(aModel);
- CleanupStack::Pop(self);
- return self;
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialView::NewLC()
- // Two-phased constructor.
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleInitialView* CS60UIExampleInitialView::NewLC(
- CS60UIExampleModel& aModel)
- {
- CS60UIExampleInitialView* self =
- new (ELeave) CS60UIExampleInitialView(aModel);
- CleanupStack::PushL(self);
- self->ConstructL();
- return self;
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialView::ConstructL()
- // Symbian 2nd phase constructor can leave.
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleInitialView::ConstructL()
- {
- BaseConstructL(R_S60UIEXAMPLE_INITIALVIEW);
- // Set an initial value for the birth date, as value must be between
- // the limits set for the editor.
- iBirthDate.HomeTime();
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialView::~CS60UIExampleInitialView()
- // Destructor.
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleInitialView::~CS60UIExampleInitialView()
- {
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialView::Id()
- // Returns View's ID.
- // -----------------------------------------------------------------------------
- //
- TUid CS60UIExampleInitialView::Id() const
- {
- return TUid::Uid(ES60UIExampleInitialViewId);
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialView::DoActivateL()
- // Activate an InitialView
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleInitialView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
- TUid /*aCustomMessageId*/,
- const TDesC8& /*aCustomMessage*/)
- {
- iContainer = CS60UIExampleInitialContainer::NewL(ClientRect(), iModel);
- AppUi()->AddToStackL(*this, iContainer);
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialView::DoDeactivate()
- // DeActivate an InitialView
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleInitialView::DoDeactivate()
- {
- if (iContainer)
- {
- // Remove InitialView's container form control Stack
- AppUi()->RemoveFromStack(iContainer);
- delete iContainer;
- iContainer = NULL;
- }
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialView::HandleCommandL()
- // Takes care of Command handling.
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleInitialView::HandleCommandL(TInt aCommand)
- {
- switch (aCommand)
- {
- case ES60UIExampleStartGame:
- {
- iModel.GameStart();
- // Switch to game view
- AppUi()->ActivateLocalViewL(TUid::Uid(ES60UIExamplePlayViewId));
- break;
- }
- case ES60UIExampleContinueGame:
- {
- iModel.GameContinue();
- // Switch to Game view
- AppUi()->ActivateLocalViewL(TUid::Uid(ES60UIExamplePlayViewId));
- break;
- }
- case ES60UIExampleRegister:
- {
- // Show registration form
- CS60UIExampleForm::RunDlgLD(iName, iBirthDate, iMobile);
- break;
- }
- case ES60UIExampleSettings:
- {
- // Show Settings List
- AppUi()->ActivateLocalViewL(TUid::Uid(ES60UIExampleSettingsViewId));
- break;
- }
- case ES60UIExampleHighscores:
- {
- // Show High Scores
- AppUi()->ActivateLocalViewL(TUid::Uid(ES60UIExampleHighScoreViewId));
- break;
- }
- default:
- // Pass any other commands to the AppUi
- AppUi()->HandleCommandL(aCommand);
- }
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialView::DynInitMenuPaneL()
- // Used to remove unwanted options from the options menu
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleInitialView::DynInitMenuPaneL(TInt aResourceId,
- CEikMenuPane* aMenuPane)
- {
- if (aResourceId == R_S60UIEXAMPLE_INITIALMENU)
- {
- if (!iModel.IsGameStarted())
- {
- aMenuPane->SetItemDimmed(ES60UIExampleContinueGame, ETrue);
- }
- }
- }
- // End of File