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

📄 appui.cpp

📁 也是一个基于S60的源代码
💻 CPP
字号:
// appui.cpp
//
// Copyright (c) 2000 Symbian Ltd.  All rights reserved.
//

#include "appui.h"
#include "controller.h"
#include "view.h"

#include <eikenv.h>

/*
	CGameAppUi
*/

void CGameAppUi::ConstructL()
    {
    BaseConstructL();
	// construct app view
	iController=static_cast<CGameDocument*>(Document())->iController;
    iAppView=new(ELeave) CFleetView;
    iAppView->ConstructL(ClientRect());
	iController->SetAppView(iAppView);
	AddToStackL(iAppView);
    }

CGameAppUi::~CGameAppUi()
	{
	RemoveFromStack(iAppView);
	delete iAppView;
	}

void CGameAppUi::HandleCommandL(TInt aCommand)
	{
	switch (aCommand)
		{
	case EEikCmdExit:
		SaveL();
		Exit();
		break;
	case EEikCmdZoomIn:
		CmdZoomInL();
		break;
	case EEikCmdZoomOut:
		CmdZoomOutL();
		break;
	case EGameCmdStart:
		CmdStartL();
		break;
		}
	}

void CGameAppUi::CmdStartL()
	{
	// user-friendly check
	if (iController->IsMyTurn())
		{
		if (!iEikonEnv->QueryWinL(R_GAME_QUERY_ABANDON))
			return;
		}
	iController->Reset();
	iAppView->DrawTilesNow();
	}

void CGameAppUi::CmdZoomInL()
	{
	iController->ZoomInL();
	}

void CGameAppUi::CmdZoomOutL()
	{
	iController->ZoomOutL();
	}

void CGameAppUi::HandleModelChangeL()
	{
	// change pointers to new objects
	iController=static_cast<CGameDocument*>(Document())->iController;
	iController->SetAppView(iAppView);
	}
	
/*
	CGameDocument
*/

CGameDocument::CGameDocument(CEikApplication& aApp)
		: CEikDocument(aApp)
	{
	}

void CGameDocument::ConstructL()
	{
	iController=CGameController::NewL();
	}

CGameDocument::~CGameDocument()
	{
	delete iController;
	}

CEikAppUi* CGameDocument::CreateAppUiL()
	{
    return new(ELeave) CGameAppUi;
	}

void CGameDocument::NewDocumentL()
	{
	iController->Reset();
	}

void CGameDocument::RestoreL(const CStreamStore& aStore,const CStreamDictionary& aStreamDict)
	{
	// new controller initialized from store
	TStreamId id=aStreamDict.At(KUidExample);
	CGameController* controller=CGameController::NewL(aStore, id);
	delete iController;
	iController=controller;
	}

void CGameDocument::StoreL(CStreamStore& aStore,CStreamDictionary& aStreamDict) const
	{
	TStreamId id=iController->StoreL(aStore);
	aStreamDict.AssignL(KUidExample,id);
	}

/*
	CGameApplication
*/

TUid CGameApplication::AppDllUid() const
	{
	return KUidExample;
	}

CApaDocument* CGameApplication::CreateDocumentL()
	{
	CGameDocument* doc=new(ELeave) CGameDocument(*this);
	CleanupStack::PushL(doc);
	doc->ConstructL();
	CleanupStack::Pop();
	return doc;
	}

// DLL interface stuff

EXPORT_C CApaApplication* NewApplication()
	{
	return new CGameApplication;
	}

GLDEF_C TInt E32Dll(TDllReason)
	{
	return KErrNone;
	}

⌨️ 快捷键说明

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