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

📄 oandxappui.cpp

📁 Symbian OS C++ for Mobile Phones Volume 3 源码
💻 CPP
字号:
// Copyright (c) 2006, Symbian Software Ltd. All rights reserved.

#include <avkon.hrh>
#include <aknnotewrappers.h>

#include "OandXAppUi.h"
#include "oandxcontroller.h"
#include "oandxengine.h"
#include "OandXAppView.h"
#include "oandxdefs.h"
#include "OandX.hrh"
#include <OandX.rsg>


COandXAppUi::COandXAppUi()
/**
	This empty constructor is defined to ensure that exactly
	one instance is generated.
 */
//:	iStacked(EFalse)
    {
    // empty.
    }

void COandXAppUi::ConstructL()
/**
	Sets default skin parameters, creates engine and app view.
	
	@see ~COandXAppUi
 */
    {
	BaseConstructL(EAknEnableSkin);
	iEngine = COandXEngine::NewL();

	iAppView = COandXAppView::NewL(ClientRect());
	AddToStackL(iAppView); // Enable keypresses to the view
	iStacked = ETrue;

	iController = COandXController::NewL(iAppView);
	// this can't be called until iController has a value so Controller() works
	iAppView->ResetView();
    }


COandXAppUi::~COandXAppUi()
/**
	This destructor undoes the secondary initialization in ConstructL.
	
	@see ConstructL
 */
    {
	delete iController;
    if (iStacked)
        RemoveFromStack(iAppView);
	delete iAppView;
	delete iEngine;
	
	REComSession::FinalClose();
	}


void COandXAppUi::HandleCommandL(TInt aCommand)
/**
	This function handles commands from menus, softkeys,
	and from the system, e.g. EEikCmdExit.
	
	@param	aCommand		Command identifier.
 */
    {
    switch (aCommand)
        {
    case EEikCmdExit:
    case EAknSoftkeyExit:
        Exit();
		break;
	
	// offer game
	case EOandXOfferGameSerialComm:
		iController->OfferGameL(KSerialCommTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	case EOandXOfferGameIrComm:
		iController->OfferGameL(KIrCommTransportUid, /* aRequireAddress */ EFalse);
		break;
	
	case EOandXOfferGameBtComm:
		iController->OfferGameL(KBtCommTransportUid, /* aRequireAddress */ EFalse);
		break;
	
	case EOandXOfferGameSms:
		iController->OfferGameL(KSmsTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	case EOandXOfferGameMmsSendAs:
		iController->OfferGameL(KMmsSendAsTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	case EOandXOfferGameEmail:
		iController->OfferGameL(KEmailTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	case EOandXOfferGameMms:
		iController->OfferGameL(KMmsTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	case EOandXOfferGameBluetooth:
		// address is protocol - "L2CAP" or "RFCOMM"
		iController->OfferGameL(KBluetoothTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	case EOandXOfferGameIrSocket:
		// address is protocol - "IrTinyTP" or "Irmux"
		iController->OfferGameL(KIrSocketTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	// join game
	case EOandXJoinGameSerialComm:
		iController->JoinGameL(KSerialCommTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	case EOandXJoinGameIrComm:
		iController->JoinGameL(KIrCommTransportUid, /* aRequireAddress */ EFalse);
		break;
	
	case EOandXJoinGameBtComm:
		iController->JoinGameL(KBtCommTransportUid, /* aRequireAddress */ EFalse);
		break;
	
	case EOandXJoinGameSms:
		iController->JoinGameL(KSmsTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	case EOandXJoinGameMmsSendAs:
		iController->JoinGameL(KMmsSendAsTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	case EOandXJoinGameEmail:
		iController->JoinGameL(KEmailTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	case EOandXJoinGameMms:
		iController->JoinGameL(KMmsTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	case EOandXJoinGameBluetooth:
		iController->JoinGameL(KBluetoothTransportUid, /* aRequireAddress */ EFalse);
		break;
	
	case EOandXJoinGameIrSocket:
		// address is protocol - "IrTinyTP" or "Irmux"
		iController->JoinGameL(KIrSocketTransportUid, /* aRequireAddress */ ETrue);
		break;
	
	// send custom index
	case EOandXSendIndex:
		iController->SendIndexL();
		break;
		
    default:
        break;
        }
    }

void COandXAppUi::ReportWinnerL(TInt aWinner)
/**
	Tell the user who won the game by displaying the information
	in a platform-specific dialog.
 */
    {
	TInt resourceId = (aWinner == ETileCross) ? R_OANDX_X_WINS : R_OANDX_O_WINS;
	CEikonEnv*ee = CEikonEnv::Static();
	HBufC* dispText = ee->AllocReadResourceLC(resourceId);
	
    CAknInformationNote* informationNote = new(ELeave) CAknInformationNote;
    informationNote->ExecuteLD(*dispText);
	
	CleanupStack::PopAndDestroy(dispText);
    }

// Global accessor functions

GLDEF_C COandXAppUi* OandXAppUi()
/**
Accessor function provides access to singleton instance of app ui object.
@return  The application UI, cast to COandXAppUi.
 */
    {
    return static_cast<COandXAppUi*>(CEikonEnv::Static()->AppUi());
    }

GLDEF_C COandXController& Controller()
/**
Return mutable reference to singleton instance of COandXController object.
@return	Singleton COandXController object.
 */
	{
	return *OandXAppUi()->iController;
	}

GLDEF_C COandXEngine& Engine()
/**
Return mutable reference to singleton instance of COandXEngine object.
@return	Singleton COandXEngine object.
 */
	{
	return *OandXAppUi()->iEngine;
	}

⌨️ 快捷键说明

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