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

📄 tgraphic.cpp

📁 在手机操作系统symbina上使用的一个脚本扩展语言的代码实现,可以参考用于自己的开发
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// TGRAPHIC.CPP
//
// Copyright (c) 1997-2000 Symbian Ltd. All rights reserved.

#define __DEBUG

#include <e32std.h>
#include <graphics.h>
#include "tgraphic.h"
#include <eikenv.h>
#include <eikappc.h>


// dummy table for testing purposes only
OPCODEFUNC OpCode::OpCodeTable[] =
		{
		&FieldRightSideInt,
		&FieldRightSideLong
		};			  
										 
// another dummy!!
void COplRuntime::SetUserRaisedError(TOplRaised aRaised)
	{
	iRaised = aRaised;
	}

TKeyResponse COplRuntime::OfferUnhandledKeyL(TKeyEvent* aKeyEvent,TEventCode aType)
	{
    if (aType==EEventKey && aKeyEvent->code==CTRL('q'))
        {
        CmdQuitL();
    	return(EKeyWasConsumed);
		}

	TInt code = aKeyEvent->code;
	switch(code)
		{
	case '0' :
		iStack->Push((TInt16)0);	// 0 for visible = false
		return(EKeyWasConsumed);
	case '1' :
		iStack->Push((TInt16)1);	// 1 for visible = true
		return(EKeyWasConsumed);
	case '2' :
		iStack->Push((TInt16)2);	// specifies window 2 as needed by gUse	and gClose
		return(EKeyWasConsumed);
	case '3' :
		iStack->Push((TInt16)3);	// specifies window 3 as needed by gUse	and gClose
		return(EKeyWasConsumed);
	case '4' :
		iStack->Push((TInt16)4);	// specifies window 4 as needed by gUse	and gClose
		return(EKeyWasConsumed);
	case '5' :
		iStack->Push((TInt16)5);	// specifies window 5 as needed by gUse	and gClose
		return(EKeyWasConsumed);
	case '6' :
		iStack->Push((TInt16)6);	// specifies window 6 as needed by gUse	and gClose
		return(EKeyWasConsumed);
	case '7' :
		iStack->Push((TInt16)6);	// specifies window 7 as needed by gUse	and gClose
		return(EKeyWasConsumed);
	case '8' :
		iStack->Push((TInt16)6);	// specifies window 8 as needed by gUse	and gClose
		return(EKeyWasConsumed);
	case '9' :
		iStack->Push((TInt16)6);	// specifies window 9 as needed by gUse	and gClose
		return(EKeyWasConsumed);
	case 'w' :
		RunTests(1);	// gCreate & gBorder
		return(EKeyWasConsumed);
	case 'l' :
		RunTests(2);	// gLineBy
		return(EKeyWasConsumed);
	case 'u' :
		RunTests(3);	// gUse
		return(EKeyWasConsumed);
	case 'b' :
		RunTests(4);	// gBox
		return(EKeyWasConsumed);
	case 'c' :
		RunTests(5);	// gCls
		return(EKeyWasConsumed);
	case 'e' :
		RunTests(6);	// gEllipse
		return(EKeyWasConsumed);
	case 'v' :
		RunTests(7);	// gVisible
		return(EKeyWasConsumed);
	case 'n' :
		RunTests(8);	// gSetWin
		return(EKeyWasConsumed);
	case 'x' :
		RunTests(9);	// gClose
		return(EKeyWasConsumed);
	case 'i' :
		RunTests(10);	// gCreateBit
		return(EKeyWasConsumed);
	case 'a' :
		RunTests(11);	// gAt
		return(EKeyWasConsumed);
	case 'p' :
		RunTests(12);	// gPrintWord
		return(EKeyWasConsumed);
	case 'd' :
		RunTests(13);	// gOriginX,gOriginY,gWidth,gHeight & gRank
		return(EKeyWasConsumed);
	case 'o' :
		RunTests(14);	// gOrder
		return(EKeyWasConsumed);
	case 'm' :
		RunTests(15);	// gGMode
		return(EKeyWasConsumed);
	case 'f' :
		RunTests(16);	// gFill
		return(EKeyWasConsumed);
	case 'y' :
		RunTests(17);	// gPoly
		return(EKeyWasConsumed);
	case 's' :
		RunTests(18);	// gSaveBit
		return(EKeyWasConsumed);
	case 't' :
		RunTests(19);	// gTMode
		return(EKeyWasConsumed);
	case 'r' :
		RunTests(20);	// gPrintBoxText
		return(EKeyWasConsumed);
	case 'h' :
		RunTests(21);	// gScroll
		return(EKeyWasConsumed);
		}
	return(EKeyWasNotConsumed);
	}

void COplRuntime::Destruct()
	{
	Adt::Destroy(iConsole);
	Adt::Destroy(iStack);
	Adt::Destroy(iDrawablesCollection);
 	Adt::Destroy(iTest);		// destroy test
	CEikAppControl::Destruct();
	}

COplRuntime::COplRuntime()
	{
	}

void COplRuntime::EikonEnvironmentReadyL()
	{
	SetTheRuntime(this);
	iConsole=new(ELeave) CEikConsoleScreen;
	CleanupStack::PushL(iConsole);
	iConsole->ConstructL(_L("TESTCONS.CPP"),TSize(80,44));
	CleanupStack::Pop();	   
	iStack=CStack::NewL(2048);
	iConsole->DrawCursor();
	iDrawablesCollection = new(ELeave) CDrawablesCollection;
	CleanupStack::PushL(iDrawablesCollection);
	iDrawablesCollection->ConstructL();
	CleanupStack::Pop();
	iTest=new(ELeave) CTestGraphics;	// create it
	TBuf<80> buf;
	buf.Format(_L("Starting Tests\r\n"));
	iConsole->Write(buf);
	buf.Format(_L("Press w to run graphics tests\r\n"));
	iConsole->Write(buf);
	}

void COplRuntime::RunTests(TInt aTestNo)	   // This is where to add your tests
	{
	iTest->DoTest(aTestNo,*iStack, *TheRuntime(), iFrame);			// test it
	}



//
// Main
//

EXPORT_C CEikAppControl* EikMain()
    {
	CEikAppControl* appControl=new COplRuntime;
	appControl->SetAppControlFlags(EEikAppControlNoAppResourceFile);
	return(appControl);
    }

GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
	{
	return(ETrue);
	}


void CTestGraphics::Destruct()
	{
	}

void CTestGraphics::DoTest(TInt aTestNo, CStack& aStack, COplRuntime& aRuntime, CFrame* aFramePtr)
	{
	switch(aTestNo)
		{
	case 1 :
		Test1(aStack,aRuntime,aFramePtr);	// test gCreate	& gBorder
		return;
	case 2 :
		Test2(aStack,aRuntime,aFramePtr);   // test gLineBy
		return;
	case 3 :
		Test3(aStack,aRuntime,aFramePtr);   // test gUse
		return;
	case 4 :
		Test4(aStack,aRuntime,aFramePtr);	// test gBox
		return;
	case 5 :
		Test5(aStack,aRuntime,aFramePtr);	// test gCls
		return;
	case 6 :
		Test6(aStack,aRuntime,aFramePtr);	// test gEllipse
		return;
	case 7 :
		Test7(aStack,aRuntime,aFramePtr);	// test gVisible
		return;
	case 8 :
		Test8(aStack,aRuntime,aFramePtr);	// test gSetWin
		return;
	case 9 :
		Test9(aStack,aRuntime,aFramePtr);	// test gClose
		return;
	case 10 :
		Test10(aStack,aRuntime,aFramePtr);	// test gCreateBit
		return;
	case 11 :
		Test11(aStack,aRuntime,aFramePtr);	// test gAt
		return;
	case 12 :
		Test12(aStack,aRuntime,aFramePtr);	// test gPrintWord
		return;
	case 13 :
		Test13(aStack,aRuntime,aFramePtr);	// test gOriginX,gOriginY,gWidth,gHeight & gRank
		return;
	case 14 :
		Test14(aStack,aRuntime,aFramePtr);	// test gOrder
		return;
	case 15 :
		Test15(aStack,aRuntime,aFramePtr);	// test gGMode
		return;
	case 16 :
		Test16(aStack,aRuntime,aFramePtr);	// test gFill
		return;
	case 17 :
		Test17(aStack,aRuntime,aFramePtr);	// test gPoly
		return;
	case 18 :
		Test18(aStack,aRuntime,aFramePtr);	// test gSaveBit
		return;
	case 19 :
		Test19(aStack,aRuntime,aFramePtr);	// test gTMode
		return;
	case 20 :
		Test20(aStack,aRuntime,aFramePtr);	// test gPrintBoxText
		return;
	case 21 :
		Test21(aStack,aRuntime,aFramePtr);	// test gScroll
		return;
		}									
	}

void CTestGraphics::Test1(CStack& aStack, COplRuntime& aRuntime, CFrame* aFramePtr)
	{
	aStack.Push((TInt16)450); // x pos
	aStack.Push((TInt16)70); // y pos
	aStack.Push((TInt16)100); // width
	aStack.Push((TInt16)110); // height
	aStack.Push((TInt16)1); // visible
	FuncOpCode::gCreate(aStack,aRuntime,aFramePtr);
	TInt id = aStack.PopInt16();
	
	TInt num = 1;
	TInt* pNum;
	pNum = &num;
	aRuntime.SetIP((TUint8*)pNum);
	aStack.Push((TInt16)3);
	OpCode::gBorder(aStack,aRuntime,aFramePtr);		 

	aStack.Push((TInt16)400); // x pos

⌨️ 快捷键说明

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