appview.cpp

来自「Symbian C++ scmp.zip」· C++ 代码 · 共 82 行

CPP
82
字号
// appview.cpp
//
// Copyright (c) 2000 Symbian Ltd.  All rights reserved.
//

#include "appview.h"

#include <eikenv.h>
#include <eiklabel.h>
#include <gsdpchat.rsg>

// app view

void CGameAppView::ConstructL(CGameEngine* aEngine, const TRect& aRect)
	{
	iEngine=aEngine;
	CreateWindowL();
	SetRect(aRect);
	// set up last-message views
	TRect rectTop=Rect();
	rectTop.iBr.iY=Rect().iBr.iY/2;
	TRect rectBottom=Rect();
	rectBottom.iTl.iY=rectTop.iBr.iY;
	iLastSentLabel=new(ELeave) CEikLabel;
	iLastSentLabel->SetContainerWindowL(*this);
	iLastSentLabel->SetRect(rectTop);
	iLastSentLabel->SetTextL(iEngine->LastSent());
	iLastReceivedLabel=new(ELeave) CEikLabel;
	iLastReceivedLabel->SetContainerWindowL(*this);
	iLastReceivedLabel->SetRect(rectBottom);
	iLastReceivedLabel->SetTextL(iEngine->LastReceived());
	// activate
	ActivateL(); // ready for drawing etc
	}

CGameAppView::~CGameAppView()
	{
	delete iLastSentLabel;
	delete iLastReceivedLabel;
	}

void CGameAppView::SetEngineL(CGameEngine* aEngine)
	{
	iEngine=aEngine;
	iLastSentLabel->SetTextL(iEngine->LastSent());
	iLastReceivedLabel->SetTextL(iEngine->LastReceived());
	DrawNow();
	}

void CGameAppView::Draw(const TRect& aRect) const
	{
	CWindowGc& gc=SystemGc();
	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	gc.SetPenStyle(CGraphicsContext::ENullPen);
	gc.SetBrushColor(KRgbWhite);
	gc.DrawRect(aRect);
	}

TKeyResponse CGameAppView::OfferKeyEventL(const TKeyEvent& /* aKeyEvent */,TEventCode /* aType */)
	{
	// don't handle keys when this view is hidden
	if (!IsVisible())
		return EKeyWasNotConsumed;
	// do nothing, for now
	return EKeyWasNotConsumed;
	}

TInt CGameAppView::CountComponentControls() const
	{
	return 2;
	}

CCoeControl* CGameAppView::ComponentControl(TInt aIndex) const
	{
	switch (aIndex)
		{
	case 0: return iLastSentLabel;
	case 1: return iLastReceivedLabel;
		}
	return 0;
	}

⌨️ 快捷键说明

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