⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 noughtsandcrossesview.cpp

📁 Symbian智能手机操作系统源代码值的参考_界面
💻 CPP
字号:
/* Copyright (c) 2005, Nokia. All rights reserved */


// INCLUDE FILES
#include <aknviewappui.h>

#include "noughtsandcrossescontainer.h"
#include "noughtsandcrossesdocument.h"
#include "noughtsandcrossesinformationandsettings.h"
#include "noughtsandcrossesview.h"

#include "nac.hrh"
#include <nac.rsg>


// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CNoughtsAndCrossesView::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CNoughtsAndCrossesView* CNoughtsAndCrossesView::NewL()
    {
    CNoughtsAndCrossesView* self = new(ELeave) CNoughtsAndCrossesView;
    CleanupStack::PushL (self);
    self->ConstructL();
    CleanupStack::Pop();
    return self;
    }

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

// -----------------------------------------------------------------------------
// CNoughtsAndCrossesView::CNoughtsAndCrossesView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CNoughtsAndCrossesView::CNoughtsAndCrossesView() : iContainer (NULL),
    iCursorRow (0), iCursorColumn (0)
    {
    ResetCoordinates();
    }

// -----------------------------------------------------------------------------
// CNoughtsAndCrossesView::~CNoughtsAndCrossesView()
// Destructor.
// -----------------------------------------------------------------------------
//
CNoughtsAndCrossesView::~CNoughtsAndCrossesView()
    {
    if (iContainer)
        {
        AppUi()->RemoveFromViewStack (*this, iContainer);
        }
	
    delete iContainer;
    }

// -----------------------------------------------------------------------------
// TUid CNoughtsAndCrossesView::Id()
// Returns the View Id.
// -----------------------------------------------------------------------------
//
TUid CNoughtsAndCrossesView::Id() const
    {
    return TUid::Uid (EMultiViewsPlayGameId);
    }

// -----------------------------------------------------------------------------
// CNoughtsAndCrossesView::HandleCommandL()
// Handles the commands.
// -----------------------------------------------------------------------------
//
void CNoughtsAndCrossesView::HandleCommandL (TInt aCommand)
    {
    switch (aCommand)
        {
        case ENoughtsAndCrossesCmdAppNewGame:
            {
            CNoughtsAndCrossesDocument* document = static_cast<
                CNoughtsAndCrossesDocument*> (AppUi()->Document());
            document->NewGame();			
            break;
            }

        case ENoughtsAndCrossesCmdAppSetting:
            {
            AppUi()->ActivateLocalViewL (TUid::Uid (EMultiViewsSettingId));
            break;
            }

        case ENoughtsAndCrossesCmdAppStatistics:
            {
            TBuf<20> wins;
            TBuf<20> losses;

            CNoughtsAndCrossesDocument* document = static_cast<
                CNoughtsAndCrossesDocument*> (AppUi()->Document());

            wins.Format (_L("H. Wins: %i"), document->InformationAndSettings().HumanWins());
            losses.Format (_L("H. Losses: %i"), document->InformationAndSettings().HumanLosses());

            static_cast<CEikonEnv*> (iCoeEnv)->InfoWinL (wins, losses);
            break;
            }

        default:
            AppUi()->HandleCommandL (aCommand);	
        }	
    }

// -----------------------------------------------------------------------------
// CNoughtsAndCrossesView::DoActivateL()
// Creates the Container class object.
// -----------------------------------------------------------------------------
//
void CNoughtsAndCrossesView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
    TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
    {
    if (!iContainer)
        {
        iContainer = CNoughtsAndCrossesContainer::NewL (ClientRect(),
            *this, iCursorRow, iCursorColumn);
		
        CNoughtsAndCrossesDocument* document = static_cast<
            CNoughtsAndCrossesDocument*> (AppUi()->Document());

        document->SetObserver (iContainer);
        AppUi()->AddToStackL (*this, iContainer);
        }

    iContainer->MakeVisible (ETrue);
    }

// -----------------------------------------------------------------------------
// CNoughtsAndCrossesView::DoDeactivate()
// Deletes the Container class object.
// -----------------------------------------------------------------------------
//
void CNoughtsAndCrossesView::DoDeactivate()
    {
    if (iContainer)
        {
        CNoughtsAndCrossesDocument* document = static_cast<
            CNoughtsAndCrossesDocument*> (AppUi()->Document());		
        document->SetObserver (NULL);
        AppUi()->RemoveFromStack (iContainer);
        delete iContainer;
        iContainer = NULL;
        }
    }

// -----------------------------------------------------------------------------
// CNoughtsAndCrossesView::ResetCoordinates()
// 
// -----------------------------------------------------------------------------
//
void CNoughtsAndCrossesView::ResetCoordinates()
    {
    iWinningRowX    = -1;
    iWinningColumnX = -1;
    iWinningRowY    = -1;
    iWinningColumnY = -1;
    }

// End of File

⌨️ 快捷键说明

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