Exemplo n.º 1
0
/** Sets the brush settings for the specified graphics context. 

If iBitmap is set, it sets this as the brush pattern and sets the brush style 
to EPatternedBrush. Otherwise, it sets the brush style and brush colour using 
the values of iBrushStyle and iBrushColor.

@param aGc The graphics context to set. */
EXPORT_C void MCoeControlBrushContext::PrepareContext(CWindowGc& aGc) const
	{
	if (iBitmap)
		{
		aGc.UseBrushPattern(iBitmap);
		aGc.SetBrushStyle(CGraphicsContext::EPatternedBrush);
		return;
		}
	aGc.SetBrushStyle(iBrushStyle);
	aGc.SetBrushColor(iBrushColor);
	}
void CMultiPtrTestChildControl::WriteName( CWindowGc& aGc, const TDesC& aText ) const 
	{
	TRect rect = Rect();
	rect.Shrink( 3, 3 );
	aGc.UseFont( iFont );
	TInt ascent = ( rect.iBr.iY - rect.iTl.iY-iFont->HeightInPixels() ) / 2 + iFont->AscentInPixels();
	aGc.SetPenColor( KRgbBlack );
	aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
	aGc.DrawText( aText, rect, ascent, CGraphicsContext::ELeft );	
	aGc.DiscardFont();
	}
void CSpaceInvadersAppView::DrawShip(CWindowGc& aGc) const
{
    // Draw the image in the desired position
    TPoint shipPoint(iShip->X(), iShip->Y());
    aGc.BitBlt( shipPoint, iBitmapShip);

    if ( iShip->HasFired() )
    {
        TPoint shotPoint(iShip->Shot()->X(), iShip->Shot()->Y());
        aGc.BitBlt( shotPoint, iBitmapShot );
    }
}
inline void CRecognizerContainer::DrawCross(CWindowGc& gc, const TPoint& center) const 
{
	CALLSTACKITEM_N(_CL("CRecognizerContainer"), _CL("DrawCross"));

	gc.DrawLine(TPoint(center.iX-5, center.iY), TPoint(center.iX+6, center.iY));
	gc.DrawLine(TPoint(center.iX, center.iY-5), TPoint(center.iX, center.iY+6));
}
Exemplo n.º 5
0
void CSmiley::DrawMouth(CWindowGc& aGc, TBool bSmiling) const
	{
	aGc.SetPenColor(KRgbBlack);
	if (bSmiling)
		{
		aGc.DrawArc(iSmileRect,
				iSmileRect.iTl + TPoint(0, iSmileRect.Height() / 2),
				iSmileRect.iTl + TPoint(iSmileyWidth / 2, iSmileRect.Height() / 2));
		}
	else
		{
		aGc.DrawArc(iFrownRect,
				iFrownRect.iTl + TPoint(iSmileyWidth / 2, iFrownRect.Height() / 2),
				iFrownRect.iTl + TPoint(0, iFrownRect.Height() / 2));
		}
	}
Exemplo n.º 6
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;
	}
Exemplo n.º 7
0
void CCalendarManagerContainer::DrawWeek(CWindowGc& gc, const TRect& aRect, const TRgb& p_Default_Font_Color1, const CFont& p_Font) const
	{
	gc.SetPenColor(p_Default_Font_Color1);
	gc.SetUnderlineStyle(EUnderlineOff);
	
	TInt i_Pos_X = 0;
	TInt i_Pos_Y = g_Pos_Y;
	
	for (TInt i = 0;i < sizeof(g_CalendarClass->g_Week) / sizeof(TInt);i++)
		{
		TBuf<10> i_Num;
		i_Num.AppendNum(g_CalendarClass->g_Week[i]);
		
		gc.DrawText(i_Num, TRect(i_Pos_X, i_Pos_Y, i_Pos_X + g_Space_X, i_Pos_Y + g_Space_Y), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels() + 1, CGraphicsContext::ECenter, 0);
		i_Pos_Y += g_Space_Y + 2;
		}					
	}
void CCustomControlScroll::Draw(CWindowGc& gc)
	{
	TInt x, y;
	//上图标
	x = iDisplayPoint.iX;
	y = iDisplayPoint.iY;
	if (iBitmapDirection[0])
		gc.BitBlt(TPoint(x, y), iBitmapDirection[0]);
	//下图标
	y += iDisplaySize.iHeight-iBitmapHeight;
	if (iBitmapDirection[1])
		gc.BitBlt(TPoint(x, y), iBitmapDirection[1]);
	//滚动条
	y = iDisplayPoint.iY+iScrollerPosY;
	if (iBitmapScroller)
		gc.BitBlt(TPoint(x, y), iBitmapScroller);
	}
Exemplo n.º 9
0
void CSmiley::DrawEyebrow(CWindowGc & aGc, TBool bSmiling) const
	{
	//Draw the mouth, smiling or looking sad.
	aGc.SetPenSize(TSize(1, 1));
	aGc.SetPenColor(KRgbWhite);
	if (bSmiling)
		{
		aGc.DrawArc(iFrownRect,
				iFrownRect.iTl + TPoint(iSmileyWidth / 2, iFrownRect.Height() / 2),
				iFrownRect.iTl + TPoint(0, iFrownRect.Height() / 2));
		}
	else
		{
		aGc.DrawArc(iSmileRect,
				iSmileRect.iTl + TPoint(0, iSmileRect.Height() / 2),
				iSmileRect.iTl + TPoint(iSmileyWidth / 2, iSmileRect.Height() / 2));
		}
	}
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;
	}
void CSpaceInvadersAppView::DrawPoints(CWindowGc& aGc) const
{
    TRgb pencolor = TRgb(255,255,255);
    aGc.SetPenColor(pencolor);
    _LIT(KPointsText, "Points: ");

    TBufC<15> pointsText;
    TPtr pointsPtr = pointsText.Des();
    pointsPtr.Append(KPointsText);
    pointsPtr.AppendNum(iHolder->ActivePoints());

    const CFont* menuFont =
        AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont, NULL);
    aGc.UseFont(menuFont);
    TInt textLength = menuFont->TextWidthInPixels(pointsPtr);
    TInt textHeight = menuFont->HeightInPixels();
    TPoint textpoint(Rect().Width() / 2 - textLength / 2, textHeight);
    aGc.DrawText(pointsPtr, textpoint);
}
void CSpaceInvadersAppView::DrawQuitCommand(CWindowGc& aGc) const
{
    TRgb pencolor = TRgb(255,255,255);
    aGc.SetPenColor(pencolor);
    _LIT(KQuitText, "Quit");

    TBufC<4> quitText;
    TPtr quitPtr = quitText.Des();
    quitPtr.Append(KQuitText);

    const CFont* menuFont =
        AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont, NULL);
    aGc.UseFont(menuFont);
    TInt textLength = menuFont->TextWidthInPixels(quitPtr);
    TInt textHeight = menuFont->HeightInPixels();
    TPoint textpoint(Rect().Width() - ( textLength + 10 ),
                     Rect().Height() - textHeight);
    aGc.DrawText(quitPtr, textpoint);
}
Exemplo n.º 13
0
void CCalendarManagerContainer::DrawSchedule(CWindowGc& gc, const TRect& aRect, const TRgb& p_Default_Font_Color1, const CFont& p_Font) const
	{		
	g_Pos_Y += g_Space_Y;	
	gc.SetPenColor(p_Default_Font_Color1);
	TInt i_Count = GetScheduleCount();
	
	if (i_Count == 0)
		{		
		gc.DrawText(_L("\x6CA1\x6709\x65E5\x7A0B"), TRect(0, 0, aRect.Width(), g_Pos_Y), (g_Pos_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0);
		}			
	else
		{
		TBuf<20> i_NUM;
		i_NUM.Append(_L("\x6709"));
		i_NUM.AppendNum(i_Count);
		i_NUM.Append(_L("\x4E2A\x65E5\x7A0B"));
		
		gc.DrawText(i_NUM, TRect(0, 0, aRect.Width(), g_Pos_Y), (g_Pos_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0);
		}
	//gc.DrawLine(TPoint(0, g_Pos_Y), TPoint(aRect.Width(), g_Pos_Y));	
	}
Exemplo n.º 14
0
/**
 * Prepares the graphics context aGc according of aHighlightType before drawing an item. At the
 * same time it determines and returns the text color to be used during the drawing of all components
 * of an item.
 */
EXPORT_C void LafMenuPane::PrepareGcForHighlight(const MLafEnv& aLafEnv, const CCoeControl& aMenuPane, CWindowGc& aGc, const TItemAttributes& aItemAttributes)
	{
	TRgb textColor = aLafEnv.ControlColor(EColorMenuPaneText, aMenuPane); //KEikMenuPaneTextColor;
	switch (aItemAttributes.iHighlightType)
		{
	case SLafMenuPane::EDrawHighlight:
		aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
		textColor = aLafEnv.ControlColor(EColorMenuPaneTextHighlight, aMenuPane);
		if (aMenuPane.IsFocused())
			{
			aGc.SetBrushColor(aLafEnv.ControlColor(EColorMenuPaneHighlight, aMenuPane));
			if (aItemAttributes.iFlags&EEikMenuItemDimmed)
				textColor = aLafEnv.ControlColor(EColorMenuPaneDimmedTextHighlight, aMenuPane);
			}
		else
			{
			aGc.SetBrushColor(aLafEnv.ControlColor(EColorMenuPaneDimmedHighlight, aMenuPane));
			textColor = aLafEnv.ControlColor(EColorMenuPaneDimmedTextHighlight, aMenuPane);
			}
		break;
	case SLafMenuPane::ERemoveHighlight:
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
		if (aItemAttributes.iFlags&EEikMenuItemDimmed)
			textColor = aLafEnv.ControlColor(EColorMenuPaneDimmedText, aMenuPane);
		break;
	case SLafMenuPane::ENoHighlight:
		aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
		if (aItemAttributes.iFlags&EEikMenuItemDimmed)
			textColor = aLafEnv.ControlColor(EColorMenuPaneDimmedText, aMenuPane);
		break;
	default:
		break;
		}
	aGc.SetPenColor(textColor);
	}
Exemplo n.º 15
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;
    }
Exemplo n.º 16
0
void CRhodesAppView::DrawImage(CWindowGc& aGc,   
    const TRect& aRect) const   
    {   
    TSize bmpSizeInPixels( iBitmap->SizeInPixels() );   
    TInt xDelta = (aRect.Width() - bmpSizeInPixels.iWidth) / 2;   
    TInt yDelta = (aRect.Height() - bmpSizeInPixels.iHeight) / 2;   
    TPoint pos( xDelta, yDelta ); // displacement vector   
    pos += aRect.iTl; // bitmap top left corner position   
   
    // Drawing viewfinder image to bitmap   
    iFbsBitGc->BitBlt( pos, iBitmap, TRect( TPoint( 0, 0 ), bmpSizeInPixels ));   
   
    // Draws bitmap with indicators on the screen   
    TSize size( iOffScreenBitmap->SizeInPixels() );   
    aGc.BitBlt( TPoint(0,0), iOffScreenBitmap, TRect( TPoint(0,0), size ) );   
    }
Exemplo n.º 17
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.º 18
0
/**
 * Draws the left adornment to the graphics context aGc, in the rectangle aRect. The menu pane
 * flags determines the type of adornment to be drawn.
 */
EXPORT_C void LafMenuPane::DrawLeftAdornment(const MLafEnv& aLafEnv, const CCoeControl& /*aMenuPane*/, CWindowGc& aGc, const TRect& aRect, const TItemAttributes& aItemAttributes)
	{
// Brush the background of the rect.
	aGc.SetPenStyle(CGraphicsContext::ENullPen);
	aGc.DrawRect(aRect);
	aGc.SetPenStyle(CGraphicsContext::ESolidPen);
	const TInt itemFlags = aItemAttributes.iFlags;
	if (itemFlags&EEikMenuItemSymbolOn)
		{
		if (itemFlags&EEikMenuItemCheckBox)
			{
			TRect rect = aRect;
			rect.iTl.iY += aItemAttributes.iBaseLine;
			TBuf<1> buf;
			buf.Append(TChar(ESymFontTick));
			aGc.UseFont(SymbolFont(aLafEnv));
			aGc.SetPenStyle(CGraphicsContext::ESolidPen);
			// as the tick is big, ignore KPreLeftAdornment and steal 1 pixels from left.
			aGc.DrawText(buf,TPoint(rect.iTl.iX-1, rect.iTl.iY));
			aGc.UseFont(NormalFont(aLafEnv));
			}
		else if (itemFlags&KLafMenuItemRadio)
			{
			TUid bmpUid(TUid::Uid(KLafUidEikonOptiVal));
			const CFbsBitmap* bitmap = aLafEnv.Bitmap(bmpUid);
			TSize bitsize = bitmap->SizeInPixels();
			TRect butRect(TPoint(0,0), TPoint(bitsize.iWidth,bitsize.iHeight));
			TInt yoffset = (aRect.Size().iHeight - bitsize.iHeight) / 2;
			TInt xoffset = KLafPreLeftAdornmentSpace;
			TPoint offset(xoffset,yoffset);
			if (aItemAttributes.iHighlightType == SLafMenuPane::EDrawHighlight)
				{
				bmpUid=TUid::Uid(KLafUidEikonOptihVal);
				bitmap = aLafEnv.Bitmap(bmpUid);
				}
			bmpUid=TUid::Uid(KLafUidEikonOptimVal);
			const CFbsBitmap* mask = aLafEnv.Bitmap(bmpUid);
			aGc.BitBltMasked((aRect.iTl+offset), bitmap, butRect, mask,ETrue);
			}
		}
	}
void CWsGraphicShareBase::ConstructL()
	{
	User::LeaveIfError(iWs.Connect());
	iScreen=new(ELeave) CWsScreenDevice(iWs);
	User::LeaveIfError(iScreen->Construct(iScreenNumber));
	iGc=new(ELeave) CWindowGc(iScreen);
	User::LeaveIfError(iGc->Construct());
	iGroupWin=new(ELeave) RWindowGroup(iWs);
	iGroupWin->Construct(1);
		
	iWin=new(ELeave) RWindow(iWs);
	iWin->Construct(*iGroupWin,ENullWsHandle);
	iWin->SetRequiredDisplayMode(EColor256);
	iWin->SetExtent(TPoint(0,0),iScreen->SizeInPixels());
	iWin->Activate();
	iWin->BeginRedraw();
	iWin->EndRedraw();
	iWs.Flush();
	}	
Exemplo n.º 20
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CMySplashScreen::DrawImages(CWindowGc& aGc,const TRect& aRect,CGulIcon* aIcon) const
{
	if(aIcon)
	{
		if(aIcon->Bitmap() && aIcon->Mask())
		{
			if(aIcon->Bitmap()->Handle() && aIcon->Mask()->Handle())
			{
				TSize ImgSiz(aIcon->Bitmap()->SizeInPixels());
				
				TInt LFtMargin = aRect.iTl.iX + ((aRect.Width() - ImgSiz.iWidth) / 2);
				TInt RghMargin = aRect.iTl.iY + ((aRect.Height() - ImgSiz.iHeight) / 2);
				
				TRect DrwRect(LFtMargin,RghMargin,(ImgSiz.iWidth + LFtMargin),(ImgSiz.iHeight + RghMargin));
				
				aGc.DrawBitmapMasked(DrwRect,aIcon->Bitmap(),TRect(0,0,ImgSiz.iWidth,ImgSiz.iHeight),aIcon->Mask(),EFalse);
			}
		}
	}
}
Exemplo n.º 21
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.º 22
0
/**
  Draw function of CConeBackgroundTestDrawer2 class used to draw the control.\n
  Sets the brush style to Solid Brush and Pen Style to Null Pen.\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 CConeBackgroundTestDrawer1::Draw(CWindowGc& aGc, const CCoeControl& /*aControl*/, const TRect& aRect) const
	{
	
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	aGc.SetPenStyle(CGraphicsContext::ENullPen);
	
	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(0xff0000));
	aGc.DrawRect(tlRect);
	
	TRect brRect = tlRect;
	brRect.Move(tlRect.Width(), tlRect.Height());
	aGc.SetBrushColor(TRgb(0x00ff00));
	aGc.DrawRect(brRect);
	}
Exemplo n.º 23
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.º 24
0
/**
 * Draws the cascade symbol into the graphics context aGc, in the rectangle aRect and sets
 * the pen color depending on whether the menu item is dimmed or focused.
 */
EXPORT_C void LafMenuPane::DrawRightAdornment(const MLafEnv& aLafEnv, const CCoeControl& /*aMenuPane*/, CWindowGc& aGc, const TRect& aRect, const TItemAttributes& aItemAttributes)
	{
	const TInt cascadeSize=Min(KLafRightAdornmentSpace,aItemAttributes.iHeight);

// Brush the background of the rect.
	aGc.SetPenStyle(CGraphicsContext::ENullPen);
	aGc.DrawRect(aRect);
	aGc.SetPenStyle(CGraphicsContext::ESolidPen);
	if (aItemAttributes.iInternalFlags&EMenuIsRightAdornment)
		{
		//Sort out rect for cascade symbol
		TRect cascadeRect=TRect(TPoint(aRect.iBr.iX-cascadeSize-PostRightAdornmentSpace(),aItemAttributes.iHPosition),
					TSize(cascadeSize,aItemAttributes.iHeight));
		cascadeRect.iTl.iY+=((aItemAttributes.iHeight-cascadeSize)/2);
		cascadeRect.iBr.iY-=((aItemAttributes.iHeight-cascadeSize)/2);
		TBuf<1> cascade;
		cascade.Append(TChar(ESymFontMenuCascade));
		aGc.UseFont(SymbolFont(aLafEnv));
		aGc.DrawText(cascade,cascadeRect,cascadeRect.Height(),CGraphicsContext::ERight);
		aGc.UseFont(NormalFont(aLafEnv));
		}
	}
Exemplo n.º 25
0
void CCalendarManagerContainer::DrawGrid(CWindowGc& gc, const TRect& aRect, const TRgb& p_Default_Grid_Color1) const
	{
	gc.SetPenColor(p_Default_Grid_Color1);
	gc.SetPenSize(TSize(2, 2));	
	gc.DrawLine(TPoint(0, g_Pos_Y), TPoint(aRect.Width(), g_Pos_Y));
		
	gc.SetPenSize(TSize(1, 1));
	TInt i_Pos_X = g_Space_X;
	for (TInt i = 0; i < 7; i++)
		{
		gc.DrawLine(TPoint(i_Pos_X, g_Pos_Y), TPoint(i_Pos_X, aRect.Height()));
		i_Pos_X += g_Space_X + 1;
		}
	
	g_Pos_Y += 1;
	TInt i_Pos_Y = g_Pos_Y;	
	for (TInt i = 0; i < 6; i++)
		{
		gc.DrawLine(TPoint(g_Space_X, i_Pos_Y), TPoint(aRect.Width(), i_Pos_Y));
		i_Pos_Y += g_Space_Y + 2;
		}
	}
Exemplo n.º 26
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();

	} 
Exemplo n.º 27
0
void CCalendarManagerContainer::DrawWeekName(CWindowGc& gc, const TRect& aRect, const TRgb& p_Default_Font_Color1, const CFont& p_Font) const
	{
	//TInt i_Pos_X = g_Space_X + 1;
	TInt i_Pos_X = 0;
	TInt i_Width = 0;
	TInt i_Height = g_Pos_Y + g_Space_Y;
	
	gc.SetPenColor(p_Default_Font_Color1);
	i_Width = i_Pos_X + g_Space_X;
	gc.DrawText(_L("\x5468"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0);
	i_Pos_X += g_Space_X + 1;
	
	for (TInt i = 0;i < 7;i++)
		{
		switch (i)
			{
			case 0:
				i_Width = i_Pos_X + g_Space_X;
				gc.DrawText(_L("\x65E5"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0);
				i_Pos_X += g_Space_X + 1;
				break;
				
			case 1:
				i_Width = i_Pos_X + g_Space_X;
				gc.DrawText(_L("\x4E00"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0);
				i_Pos_X += g_Space_X + 1;
				break;
				
			case 2:
				i_Width = i_Pos_X + g_Space_X;
				gc.DrawText(_L("\x4E8C"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0);
				i_Pos_X += g_Space_X + 1;
				break;
				
			case 3:
				i_Width = i_Pos_X + g_Space_X;
				gc.DrawText(_L("\x4E09"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0);
				i_Pos_X += g_Space_X + 1;
				break;
				
			case 4:
				i_Width = i_Pos_X + g_Space_X;
				gc.DrawText(_L("\x56DB"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0);
				i_Pos_X += g_Space_X + 1;
				break;
				
			case 5:
				i_Width = i_Pos_X + g_Space_X;
				gc.DrawText(_L("\x4E94"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0);
				i_Pos_X += g_Space_X + 1;
				break;
				
			case 6:				
				i_Width = i_Pos_X + g_Space_X;
				gc.DrawText(_L("\x516D"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0);
				i_Pos_X += g_Space_X + 1;
				break;
			}			
		}
	
	g_Pos_Y += g_Space_Y;
	//gc.DrawLine(TPoint(0, g_Pos_Y), TPoint(aRect.Width(), g_Pos_Y));
	}
void CSpaceInvadersAppView::DrawBackground(CWindowGc& aGc) const
{
    TRgb backcolor = TRgb(0,0,0);
    aGc.SetBrushColor(backcolor);
    aGc.Clear();
}
Exemplo n.º 29
0
void CCalendarManagerContainer::DrawDay(CWindowGc& gc, const TRect& aRect, const TRgb& p_Default_Font_Color1, const TRgb& p_Default_Font_Color2, const CFont& p_Font) const
	{
	gc.SetPenColor(p_Default_Font_Color1);
	
	TInt i_Total = 0;
	TInt i_WeekPos = g_CalendarClass->g_FirstWeek;	
	//TInt i_Pos_X = g_Space_X * (i_WeekPos + 1) + i_WeekPos + 1;
	//TInt i_Pos_Y = g_Pos_Y;
	
	TInt i_Pos_X = g_Space_X + 1;
	TInt i_Pos_Y = g_Pos_Y;
	
	if (i_WeekPos != 7)
		{
		gc.SetPenColor(p_Default_Font_Color2);
		for (TInt i = g_CalendarClass->g_MaxDay_PreMonth - i_WeekPos + 1;i <= g_CalendarClass->g_MaxDay_PreMonth;i++)
			{
			TBuf<5> i_Num;
			i_Num.AppendNum(i);
			
			gc.DrawText(i_Num, TRect(i_Pos_X, i_Pos_Y, i_Pos_X + g_Space_X, i_Pos_Y + g_Space_Y), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels() + 1, CGraphicsContext::ECenter, 0);
			
			i_Pos_X += g_Space_X + 1;
			i_Total++;
			}
		}
	
	i_Pos_X = g_Space_X * (i_WeekPos + 1) + i_WeekPos + 1;
	
	for (TInt i = 1; i <= g_CalendarClass->g_MaxDay; i++)
		{
		TBuf<5> i_Num;
		i_Num.AppendNum(i);
		
		if (i_WeekPos == 0)
			gc.SetPenColor(KRgbRed);
		else
			gc.SetPenColor(p_Default_Font_Color1);
			
		if (g_CalendarClass->g_SelectYear == g_CalendarClass->g_Year && g_CalendarClass->g_SelectMonth == g_CalendarClass->g_Month && i == g_CalendarClass->g_Day)			
			gc.SetUnderlineStyle(EUnderlineOn);		
		else			
			gc.SetUnderlineStyle(EUnderlineOff);			
		
		gc.DrawText(i_Num, TRect(i_Pos_X, i_Pos_Y, i_Pos_X + g_Space_X, i_Pos_Y + g_Space_Y), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels() + 1, CGraphicsContext::ECenter, 0);
				
		i_WeekPos++;		
		if (i_WeekPos >= 7)
			{
			i_WeekPos = 0;			
			i_Pos_Y += g_Space_Y + 2;			
			}				
		
		i_Pos_X = g_Space_X * (i_WeekPos + 1) + i_WeekPos + 1;
		i_Total++;
		}
	
	TInt j = 1;
	gc.SetPenColor(p_Default_Font_Color2);
	for (TInt i = i_Total + 1;i <= 42;i++)
		{
		TBuf<5> i_Num;
		i_Num.AppendNum(j);
		
		gc.DrawText(i_Num, TRect(i_Pos_X, i_Pos_Y, i_Pos_X + g_Space_X, i_Pos_Y + g_Space_Y), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels() + 1, CGraphicsContext::ECenter, 0);
		
		i_WeekPos++;		
		if (i_WeekPos >= 7)
			{
			i_WeekPos = 0;			
			i_Pos_Y += g_Space_Y + 2;
			}
			
		i_Pos_X = g_Space_X * (i_WeekPos + 1) + i_WeekPos + 1;		
		j++;
		}
	}
void CWelcomePageBase::DrawRectL(CWindowGc& aGc, const TRgb& aColor, const TJuikLayoutItem& aL) const
{
	aGc.SetBrushColor( aColor );
	aGc.DrawRect( aL.Rect() );	
}