Exemplo n.º 1
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.º 2
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.º 4
0
/****************************************************************************\
|	Function:	CNumberedWindow::Draw
 |	Purpose:	Redraws the contents of CNumberedWindow within a given
 |				rectangle.  CNumberedWindow displays a number in the window.
 |	Input:		aRect	Rectangle that needs redrawing
 |	Output:		None
 \****************************************************************************/
void CNumberedWindow::Draw(const TRect& aRect)
    {
    const TBufC<1> strings[5] =
        {
        *&KString1, *&KString2, *&KString3, *&KString4, *&KString5
        };

    CWindowGc* gc = SystemGc(); // get a graphics context
    gc->SetClippingRect(aRect); // clip outside the redraw area
    gc->Clear(aRect); // clear the redraw area
    TSize size = iWindow.Size();
    TInt height = size.iHeight; // Need window height to calculate vertical text offset
    TInt ascent = Font()->AscentInPixels();
    TInt descent = Font()->DescentInPixels();
    TInt offset = (height + (ascent + descent)) / 2; // Calculate vertical text offset
    gc->SetPenColor(TRgb(0, 0, 0)); // Set pen to black
    gc->UseFont(Font());
    gc->DrawText(strings[iNumber], TRect(TPoint(0, 0), size), offset,
            CGraphicsContext::ECenter);
    gc->DiscardFont();
    }
Exemplo n.º 5
0
/**
  Draw function of CConeBackgroundTestDrawer2 class used to draw the control.\n
  Sets the background style for Drawing.\n
  1. if aStyle is zero , the brush style is EVerticalHatchBrush.\n
  2. if aStyle is one , the brush style is EForwardDiagonalHatchBrush.\n
  3. if aStyle is two , the brush style is EHorizontalHatchBrush.\n
  4. if aStyle is three , the brush style is ERearwardDiagonalHatchBrush.\n
  Sets the brush colour to Red and paints the top left part of the control.\n
  Sets the brush colour and points the bottom right part of the control.\n
*/
void CConeBackgroundTestDrawer0::Draw(CWindowGc& aGc, const CCoeControl& /*aControl*/, const TRect& aRect) const
	{
	aGc.SetPenStyle(CGraphicsContext::ENullPen);
	aGc.SetBrushColor(TRgb(0xffffff));
	aGc.Clear();

	switch (iBgStyle)
		{
		case 0:
			aGc.SetBrushStyle(CGraphicsContext::EVerticalHatchBrush);
			break;
			
		case 1:
			aGc.SetBrushStyle(CGraphicsContext::EForwardDiagonalHatchBrush);
			break;
			
		case 2:
			aGc.SetBrushStyle(CGraphicsContext::EHorizontalHatchBrush);
			break;
			
		case 3:
			aGc.SetBrushStyle(CGraphicsContext::ERearwardDiagonalHatchBrush);
			break;
		}

	aGc.SetPenColor(TRgb(0xff0000));
	aGc.DrawRect(aRect);
	
	TRect tlRect = aRect;
	tlRect.iBr.iX = (tlRect.iBr.iX - tlRect.iTl.iX)/2 + tlRect.iTl.iX;
	tlRect.iBr.iY = (tlRect.iBr.iY - tlRect.iTl.iY)/2 + tlRect.iTl.iY;
	
	aGc.SetBrushColor(TRgb(0xff00ff));
	aGc.DrawRect(tlRect);
	
	TRect brRect = tlRect;
	brRect.Move(tlRect.Width(), tlRect.Height());
	aGc.SetBrushColor(TRgb(0x00ff00));
	aGc.DrawRect(brRect);
	}
Exemplo n.º 6
0
/**
 * Draws the thumb of the scrollbar. The thumb can be drawn in pressed colors if aIsDragged is true, or in normal
 * colors otherwise. The scrollbar is horizontal if aHorizontal is true and vertical otherwise.
 */
EXPORT_C void LafScrollThumb::DrawDragState(const MLafEnv& aLafEnv,CWindowGc& aGc,const CCoeControl& aScrollThumb,TBool aIsDragged, const TRect& aRect, TBool aHorizontal)
    {
    TRgb bgColor;
    if (aScrollThumb.IsDimmed())
        {
        bgColor=aLafEnv.ControlColor((aIsDragged? EColorScrollButtonThumbBackgroundPressed : EColorScrollThumbDimmed),aScrollThumb);
        }
    else
        {
        bgColor=aLafEnv.ControlColor((aIsDragged? EColorScrollButtonThumbBackgroundPressed : EColorScrollButtonThumbBackground),aScrollThumb);
        }
    
    aGc.SetBrushColor(bgColor);
    aGc.Clear(aRect);
    
    TRect gripRect=aRect;
    TInt length=(aHorizontal)? gripRect.Size().iWidth : gripRect.Size().iHeight;
    TInt gripStart=((length*(KLafScrollThumbGripProportion-1))/KLafScrollThumbGripProportion)/2;
    TInt horizBorder=(aHorizontal)? gripStart : KLafScrollThumbGripMargin;
    TInt vertBorder=(aHorizontal)? KLafScrollThumbGripMargin : gripStart;
    
    gripRect.Shrink(horizBorder,vertBorder);
    // TLafGrip::TOrientation gripOrientation=(aHorizontal)? TLafGrip::EVertical : TLafGrip::EHorizontal;
    }
void CSpaceInvadersAppView::DrawBackground(CWindowGc& aGc) const
{
    TRgb backcolor = TRgb(0,0,0);
    aGc.SetBrushColor(backcolor);
    aGc.Clear();
}
Exemplo n.º 8
0
void CMainWindow::Draw(const TRect& aRect)
    {
    CWindowGc* gc = SystemGc(); // get a gc
    gc->SetClippingRect(aRect); // clip outside this rect
    gc->Clear(aRect); // clear
    }