Exemplo n.º 1
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.º 2
0
//Background drawing function
void CTestRectGc::Draw(CWindowGc& aGc, const CCoeControl& aControl, const TRect& aRect) const
	{		
		if (iBmpBackground) 
		{
						
			TPoint a = PositionRelativeToScreen();
			TPoint b = aControl.PositionRelativeToScreen();

			//The source rect of the background is the relationship between this control and the control being drawn (child)
			//plus the subrect (aRect) to be drawn.
			TRect SourceRect(b-a+aRect.iTl, aRect.Size());

			aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
			aGc.BitBlt(aRect.iTl, iBmpBackground, SourceRect);			
			aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
		}
		else
		{
			TRect rc;
			aGc.SetClippingRect(aRect);
			aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    		aGc.SetBrushColor(iBrushColor);
    		aGc.SetBrushStyle(iBrushStyle);
			aGc.DrawRect(rc);
			aGc.CancelClippingRect();

		}		
	}
Exemplo n.º 3
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 Blue and paints an ellipse on  the control.\n
*/
void CConeBackgroundTestDrawer2::Draw(CWindowGc& aGc, const CCoeControl& /*aControl*/, const TRect& aRect) const
	{
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	aGc.SetPenStyle(CGraphicsContext::ENullPen);
	aGc.SetBrushColor(TRgb(0x0000ff));
	aGc.DrawEllipse(aRect);
	}
Exemplo n.º 4
0
/**
 * Prepares the graphics context aGc for drawing the items by setting the pen and brush.
 */
EXPORT_C void LafMenuPane::PrepareGcForDrawingItems(const MLafEnv& aLafEnv, const CCoeControl& aMenuPane, CWindowGc& aGc)
	{
	const CFont* font = NormalFont(aLafEnv);
	aGc.UseFont(font);
	aGc.SetPenColor(aLafEnv.ControlColor(EColorMenuPaneText, aMenuPane));
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	aGc.SetBrushColor(aLafEnv.ControlColor(EColorMenuPaneBackground, aMenuPane));
	}
Exemplo n.º 5
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.º 6
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);
	}
Exemplo n.º 7
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.º 8
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.º 9
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();

	} 
void CWelcomePageBase::DrawRectL(CWindowGc& aGc, const TRgb& aColor, const TJuikLayoutItem& aL) const
{
	aGc.SetBrushColor( aColor );
	aGc.DrawRect( aL.Rect() );	
}
void CSpaceInvadersAppView::DrawBackground(CWindowGc& aGc) const
{
    TRgb backcolor = TRgb(0,0,0);
    aGc.SetBrushColor(backcolor);
    aGc.Clear();
}
Exemplo n.º 12
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CTraceContainer::PieDrawer(CWindowGc& aGc, TPoint aLeftTop, TInt aSize, TInt aProsentages, const TBool& aReverceColor) const
{
	TBuf<50> Buffer;
	Buffer.Num(aProsentages);
	Buffer.Append(_L("%"));

	aGc.SetPenColor(KRgbBlack);
	
	if(aReverceColor)
		aGc.SetBrushColor(KRgbGreen);
	else
		aGc.SetBrushColor(KRgbRed);
	
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	aGc.DrawEllipse(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize));

	if(aProsentages < 0)
	{
		Buffer.Copy(_L("N/A"));
		
		if(aReverceColor)
			aGc.SetBrushColor(KRgbGreen);
		else
			aGc.SetBrushColor(KRgbRed);
	}
	else
	{
		TInt HelpPie = 0;
		
		if(aReverceColor)
			aGc.SetBrushColor(KRgbRed);
		else
			aGc.SetBrushColor(KRgbGreen);

		TInt Angle =((aProsentages * 360) / 100);

		if(Angle == 360)
		{
			aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),aLeftTop,aLeftTop);
		}
		else if(Angle == 45)
		{
			aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(aLeftTop.iX,aLeftTop.iY));
		}
		else if(Angle == 135)
		{
			aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(aLeftTop.iX,aLeftTop.iY + aSize));
		}
		else if(Angle == 225)
		{
			aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(aLeftTop.iX + aSize,aLeftTop.iY + aSize));
		}
		else if(Angle == 315)
		{
			aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(aLeftTop.iX + aSize,aLeftTop.iY));
		}
		else if(Angle > 45 && Angle < 135)
		{				
			HelpPie = ((((Angle - 45) * aSize) / 90) + aLeftTop.iY);
			aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(aLeftTop.iX,HelpPie));
		}
		else if(Angle > 135 && Angle < 225)
		{
			HelpPie = ((((Angle - 135) * aSize) / 90) + aLeftTop.iX);
			aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(HelpPie,aLeftTop.iY + aSize));
		}
		else if(Angle > 225 && Angle < 315)
		{
			HelpPie = (((aLeftTop.iY + aSize) - ((Angle - 225) * aSize) / 90));
			aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(aLeftTop.iX + aSize,HelpPie));
		}
		else if(Angle > 0 && Angle < 45)
		{
			HelpPie = (((aLeftTop.iX + (aSize/2)) - ((Angle) * (aSize/2)) / 45));
			aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(HelpPie,aLeftTop.iY));
		}
		else if(Angle > 315 && Angle < 360)
		{
			HelpPie = (((aLeftTop.iX + aSize) - ((Angle - 315) * (aSize/2)) / 45));
			aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(HelpPie,aLeftTop.iY));
		}

		if(aReverceColor)
		{
			if(Angle > 180)
				aGc.SetBrushColor(KRgbGreen);
			else	
				aGc.SetBrushColor(KRgbRed);
		}
		else
		{
			if(Angle > 180)
				aGc.SetBrushColor(KRgbRed);
			else	
				aGc.SetBrushColor(KRgbGreen);
		}		
	}

	const CFont* MuFonr = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont);

	TInt TextHeight= MuFonr->HeightInPixels();
	TInt TextWidth = MuFonr->TextWidthInPixels(Buffer);

	TInt StartX = (aLeftTop.iX + ((aSize - TextWidth) / 2));
	TInt StartY = (aLeftTop.iY + ((aSize - TextHeight) / 2));

	aGc.UseFont(MuFonr);
	aGc.SetPenColor(KRgbBlack);
	aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
	
	aGc.DrawText(Buffer,TRect(StartX,StartY,StartX + TextWidth,StartY + TextHeight),MuFonr->AscentInPixels(), CGraphicsContext::ELeft, 0);			

	aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
}