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

📄 testdirectdrawappview.cpp

📁 directDraw 画界面
💻 CPP
字号:
/*
 ============================================================================
 Name		: TestDirectDrawAppView.cpp
 Author	  : 
 Copyright   : Your copyright notice
 Description : Application view implementation
 ============================================================================
 */

// INCLUDE FILES
#include <coemain.h>
#include <EIKENV.H>
#include <BITSTD.H>
#include <aknenv.h>
#include "TestDirectDrawAppView.h"

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

// -----------------------------------------------------------------------------
// CTestDirectDrawAppView::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CTestDirectDrawAppView* CTestDirectDrawAppView::NewL(const TRect& aRect)
	{
	CTestDirectDrawAppView* self = CTestDirectDrawAppView::NewLC(aRect);
	CleanupStack::Pop(self);
	return self;
	}

// -----------------------------------------------------------------------------
// CTestDirectDrawAppView::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CTestDirectDrawAppView* CTestDirectDrawAppView::NewLC(const TRect& aRect)
	{
	CTestDirectDrawAppView* self = new ( ELeave ) CTestDirectDrawAppView;
	CleanupStack::PushL(self);
	self->ConstructL(aRect);
	return self;
	}

// -----------------------------------------------------------------------------
// CTestDirectDrawAppView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CTestDirectDrawAppView::ConstructL(const TRect& aRect)
	{
	// Create a window for this application view
	CreateWindowL();

	// Set the windows size
	SetRect(aRect);

	// Activate the window, which makes it ready to be drawn
	ActivateL();

	CEikonEnv* env = CEikonEnv::Static();
	iDSA = CDirectScreenAccess::NewL(env->WsSession(), *(env->ScreenDevice()), this->Window(), *this);

	iDSA->StartL();
	DrawGraphics();
	}

void CTestDirectDrawAppView::Restart(RDirectScreenAccess::TTerminationReasons aReason)
	{
	iDSA->StartL();
	DrawGraphics();
	}

void CTestDirectDrawAppView::AbortNow(RDirectScreenAccess::TTerminationReasons aReason)
	{
	iDSA->Cancel();
	}

void CTestDirectDrawAppView::DrawGraphics()
	{
	CFbsBitGc* gc = iDSA->Gc();

	TRgb colorRed= AKN_LAF_COLOR(35);
	gc->SetPenColor(colorRed);
	gc->DrawRect(TRect(0, 0, 100, 100));

	iDSA->ScreenDevice()->Update();
	}

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

// -----------------------------------------------------------------------------
// CTestDirectDrawAppView::~CTestDirectDrawAppView()
// Destructor.
// -----------------------------------------------------------------------------
//
CTestDirectDrawAppView::~CTestDirectDrawAppView()
	{
	// No implementation required
	if (iDSA)
		{
		iDSA->Cancel();
		delete iDSA;
		iDSA = NULL;
		}
	}

// -----------------------------------------------------------------------------
// CTestDirectDrawAppView::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void CTestDirectDrawAppView::Draw(const TRect& /*aRect*/) const
	{
	// Get the standard graphics context
	if (iDSA && iDSA->IsActive())
		{
//		CWindowGc& gc = SystemGc();
//
//		//	// Gets the control's extent
//		TRect drawRect(Rect());
//
//		// Clears the screen
//		gc.Clear(drawRect);
		}
	}

// -----------------------------------------------------------------------------
// CTestDirectDrawAppView::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void CTestDirectDrawAppView::SizeChanged()
	{
	DrawNow();
	}
// End of File

⌨️ 快捷键说明

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