Exemplo n.º 1
0
void CMainWindow::HandlePointerEvent(TPointerEvent& aPointerEvent)
	{
	switch (aPointerEvent.iType)
		{
		case TPointerEvent::EButton1Down:
			{
			if (aPointerEvent.iModifiers & EModifierShift)
				{
				Window().EnablePointerMoveBuffer();
				CWindowGc* gc = SystemGc();
				gc->Activate(Window());
				gc->MoveTo(aPointerEvent.iPosition);
				gc->Deactivate();
				}
			break;
			}
		case TPointerEvent::EButton1Up:
			{
			Window().DisablePointerMoveBuffer();
			break;
			}
		default:
			break;
		}
	}
Exemplo n.º 2
0
TInt LoadsOfText(TInt aOwningGroup)
	{
	RWsSession ws;
	ws.Connect();
	CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws);
	device->Construct();
	RWindowGroup group(ws);
	group.Construct(ENullWsHandle);
	group.SetOwningWindowGroup(aOwningGroup);
	TSize scrSize(device->SizeInPixels());
//
	RWindow window(ws);
	window.Construct(group,ENullWsHandle);
	window.SetExtent(TPoint(), scrSize);
	window.Activate();
//
	CWindowGc *gc;
	device->CreateContext(gc);
	window.BeginRedraw();
	gc->Activate(window);
	gc->Clear();
	window.EndRedraw();
	TFontSpec fspec(KTestFontTypefaceName,200);
	CFbsFont *font;
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips((CFont *&)font, fspec));
	gc->UseFont(font);
	TBuf<100> loadsatext(_L("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890zyxwvutsrqponmlkjihgfedcba"));
	TInt ascent=font->AscentInPixels();
	TInt fheight=font->HeightInPixels();
	for(TInt nTimes=0;nTimes<10;nTimes++)
		{
		TPoint pos;
//		for(pos.iY=ascent;pos.iY<scrSize.iHeight;pos.iY+=font->HeightInPixels())
//			gc->DrawText(loadsatext,pos);
		for(pos.iY=0;pos.iY<scrSize.iHeight;pos.iY+=fheight)
			gc->DrawText(loadsatext,TRect(pos,TPoint(scrSize.iWidth,pos.iY+fheight)),ascent);
		gc->Clear();
		}
	gc->Deactivate();
//
	ws.Flush();
	delete gc;
	device->ReleaseFont(font);
	window.Close();
	group.Close();
	delete device;
	ws.Close();
	return(KErrNone);
	}
Exemplo n.º 3
0
/**
* Runs the test in a second thread.
*
* @param aFunctionIndex The drawing function command to be executed. All commands are defined in TestFunctionIndex.
*/
TInt CTW32CmdBuf::DoTestCmdBufFunctionL(TTestFunctionIndex aFunctionIndex)
	{
	RWsSession session;
	User::LeaveIfError(session.Connect());
	CleanupClosePushL(session);
	CWsScreenDevice *device = new(ELeave) CWsScreenDevice(session);
	CleanupStack::PushL(device);
	User::LeaveIfError(device->Construct(CTestBase::iScreenNo));
	CWindowGc* gc;
	User::LeaveIfError(device->CreateContext(gc));
	CleanupStack::PushL(gc);
	RWindowGroup group(session);
	User::LeaveIfError(group.Construct(1, EFalse));
	CleanupClosePushL(group);
	RWindow window(session);
	User::LeaveIfError(window.Construct(group, 2));
	CleanupClosePushL(window);
	window.SetExtent(TPoint(0,0), TSize(200, 200));
	User::LeaveIfError(window.SetRequiredDisplayMode(EColor64K));
	window.Activate();	
	gc->Activate(window);
	session.SetAutoFlush(EFalse);
	window.Invalidate();
	window.BeginRedraw();
	for(TInt i=KMinTestIterations; i<KMaxTestIterations; ++i)
		{
		for(TInt j=0; j<i; ++j)
			{
			gc->Clear();
			}

		CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
		CleanupStack::PushL(bitmap);
		User::LeaveIfError(bitmap->Create(TSize(100, 100), EColor64K));
		CFbsBitmap* mask = new(ELeave) CFbsBitmap;
		CleanupStack::PushL(mask);
		User::LeaveIfError(mask->Create(TSize(100, 100), EColor64K));
		KTestFunctions[aFunctionIndex](gc, bitmap, mask);
		CleanupStack::PopAndDestroy(2);
		session.Flush();	
		}	
	window.EndRedraw();	
	gc->Deactivate();
	CleanupStack::PopAndDestroy(5);
	return KErrNone;
	}
void CWsGraphicShareBase::DoTestDrawGraphicCompareL(TPtrC aShare)
	{
	// UID of the shared graphic
	TUid uid1 = {0x12000021};
	TWsGraphicId twsGraphicId1(uid1);

	_LIT8(KTestData,"HelloWorld");
	
	CFbsBitmap bitmap1;
	CFbsBitmap mask1;
	
	TSize screenSize = iScreen->SizeInPixels();
	User::LeaveIfError(bitmap1.Load(MY_TEST_BITMAP,0));
	mask1.Create(bitmap1.SizeInPixels(),iScreen->DisplayMode());
	
		CWsGraphicBitmap* bTest = CWsGraphicBitmap::NewL(&bitmap1,&mask1);
	
	// divide the screen into two equal rectangles
	TRect position1(0,0,screenSize.iWidth/2,screenSize.iHeight);
	TRect position2(screenSize.iWidth/2,0,screenSize.iWidth,screenSize.iHeight);
	
	// draw the new graphic and attempt to draw the shared graphic
	iGc->Activate(*iWin);
	iWin->Invalidate();
	iWin->BeginRedraw();
	iGc->Clear(position1);
	iGc->Clear(position2);

	iGc->DrawWsGraphic(bTest->Id(),position1,KTestData);
	iGc->DrawWsGraphic(twsGraphicId1.Uid(),position2,KTestData);

	iGc->Deactivate();	
	iWin->EndRedraw();
	
	iWs.Flush();
	iWs.Finish();
	// compare the graphic in both positions
	if (aShare==_L("false"))
		Test(!iScreen->RectCompare(position1,position2));
	else
		Test(iScreen->RectCompare(position1,position2));	
		
	delete bTest;
	}
Exemplo n.º 5
0
void CMainWindow::HandlePointerMoveBufferReady()
	{
	TPoint pnts[KPointerMoveBufferSize];
	TPtr8 ptr((TUint8 *) &pnts, sizeof(pnts));
	TInt numPnts = Window().RetrievePointerMoveBuffer(ptr);
	TRect redrawRect(Window().Position(), Window().Size());

	CWindowGc* gc = SystemGc();
	gc->Activate(Window());
	gc->SetPenColor(KRgbBlue);
	gc->SetPenSize(TSize(2, 2));
	Window().Invalidate();
	Window().BeginRedraw(redrawRect); // N.B. Redrawer::RunL() gets called with this 
	// rectangle - must give it a non-zero value
	for (TInt index = 0; index < numPnts; index++)
		{
		gc->DrawLineTo(pnts[index]);
		}
	Window().EndRedraw();
	gc->Deactivate();
	}
Exemplo n.º 6
0
void MainL()	
	{	
	RWsSession ws;
	ws.Connect();
 	CWsScreenDevice* scr = new(ELeave) CWsScreenDevice(ws);
	scr->Construct();
 	CWindowGc* gc = new(ELeave) CWindowGc(scr);
	gc->Construct();
 	RWindowGroup grp(ws);
	grp.Construct(0xc0decafe, ETrue);
 	RWindow win(ws);
	win.Construct(grp, 0xbeefcafe);
	win.SetExtent(TPoint(20,160), TSize(320,240));
	win.Activate();
 	win.Invalidate();
	win.BeginRedraw();
	gc->Activate(win);
 	gc->SetPenStyle(CGraphicsContext::ENullPen);
	gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
 	TBool color = EFalse;

if (Profiler::Start() == KErrNotFound)
	{
	_LIT(KProfiler,"profiler");
	_LIT(KStart,"start -noui -drive=S");
	RProcess p;
	if (p.Create(KProfiler,KStart) == KErrNone)
		{
		p.Resume();
		p.Close();
		}
	}

	for (TInt col=0; col<KCol; ++col)
		{
		color = !color;		
		for (TInt row=0; row<KRow; ++row)
			{
			TRect rect;
			rect.iTl.iX = col * KSize.iWidth;
			rect.iTl.iY = row * KSize.iHeight;
			rect.SetSize(KSize);
			color = !color;
			gc->SetBrushColor(color? KRgbBlue : KRgbBlack);
			gc->DrawRect(rect);
			}
	}
	
	
	
	gc->Deactivate();
	win.EndRedraw();
	ws.Flush();
 	User::After(3000000);
 	win.Close();
	grp.Close();
	delete gc;
	delete scr;
	ws.Close();

	Profiler::Stop();
	Profiler::Close();
	Profiler::Unload();

	}