s60uiexampleplayview.cpp

来自「symbianOS第三版开发与实用教程部分源码和部分试验」· C++ 代码 · 共 159 行

CPP
159
字号
// Copyright (c) 2006 Nokia Corporation.

#include "S60UIExamplePlayView.h"
#include "S60UIExamplePlayContainer.h"
#include "S60UIExampleModel.h"
#include "S60UIExample.hrh"
#include <aknviewappui.h>
#include <S60UIExample.rsg>
#include <stringloader.h>    

// -----------------------------------------------------------------------------
// CS60UIExamplePlayView::CS60UIExamplePlayView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CS60UIExamplePlayView::CS60UIExamplePlayView(CS60UIExampleModel& aModel)
    :iModel(aModel)
    {
    // No implementation required
    }


// -----------------------------------------------------------------------------
// CS60UIExamplePlayView::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CS60UIExamplePlayView* CS60UIExamplePlayView::NewL(CS60UIExampleModel& aModel)
    {
    CS60UIExamplePlayView* self = CS60UIExamplePlayView::NewLC(aModel);
    CleanupStack::Pop(self);
    return self;
    }


// -----------------------------------------------------------------------------
// CS60UIExamplePlayView::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CS60UIExamplePlayView* CS60UIExamplePlayView::NewLC(CS60UIExampleModel& aModel)
    {
    CS60UIExamplePlayView* self = new (ELeave) CS60UIExamplePlayView(aModel);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }


// -----------------------------------------------------------------------------
// CS60UIExamplePlayView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CS60UIExamplePlayView::ConstructL()
    {
    BaseConstructL(R_S60UIEXAMPLE_PLAYVIEW);
    }


// -----------------------------------------------------------------------------
// CS60UIExamplePlayView::~CS60UIExamplePlayView()
// Destructor.
// -----------------------------------------------------------------------------
//
CS60UIExamplePlayView::~CS60UIExamplePlayView()
    {
    // No implementation required
    }


// -----------------------------------------------------------------------------
// CS60UIExamplePlayView::Id()
// Returns View's ID.
// -----------------------------------------------------------------------------
//
TUid CS60UIExamplePlayView::Id() const
    {
    return TUid::Uid(ES60UIExamplePlayViewId);
    }


// -----------------------------------------------------------------------------
// CS60UIExamplePlayView::DoActivateL()
// Activate the View
// -----------------------------------------------------------------------------
//
void CS60UIExamplePlayView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
                                        TUid /*aCustomMessageId*/,
                                        const TDesC8& /*aCustomMessage*/)
    {
    iContainer = CS60UIExamplePlayContainer::NewL(ClientRect(), iModel);
    AppUi()->AddToViewStackL(*this, iContainer);
    }


// -----------------------------------------------------------------------------
// CS60UIExamplePlayView::DoDeactivate()
// -----------------------------------------------------------------------------
//
void CS60UIExamplePlayView::DoDeactivate()
    {
    if (iContainer)
        {
        AppUi()->RemoveFromViewStack(*this, iContainer);
        delete iContainer;
        iContainer = NULL;
        }
        
    }


// -----------------------------------------------------------------------------
// CS60UIExamplePlayView::HandleCommandL()
// Takes care of Command handling.
// -----------------------------------------------------------------------------
//
void CS60UIExamplePlayView::HandleCommandL(TInt aCommand)
    {
    switch (aCommand)
        {
        case ES60UIExampleStopGame:
            {
            iModel.GameStop();
            // Switch back to initial view
            AppUi()->ActivateLocalViewL(TUid::Uid(ES60UIExampleInitialViewId));
            break;
            }
            
        case ES60UIExampleStartGame:
            {
            iModel.GameStart();
            // Get reset scores to navi pane
            iContainer->UpdateNaviPaneL();
            // Draw game image (without paused text)
            iContainer->DrawNow();
            break;
            }
            
        case ES60UIExampleContinueGame:
            iModel.GameContinue();
            // Draw game image (without paused text)
            iContainer->DrawNow();
            break;
            
        case ES60UIExamplePauseGame:
            iModel.GamePause();
            // Draw game image (with paused text)
            iContainer->DrawNow();
            break;
            
        default:
            // pass anything else to the AppUi
            AppUi()->HandleCommandL(aCommand);
        }

    }

// End of File

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?