Пример #1
0
void CPictureWidget::Draw(CGraphicsContext &aGc) const
{
	if(iActive)
	{
		aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
		aGc.SetPenStyle(CGraphicsContext::ESolidPen);
		aGc.SetPenColor(KRgbBlack);
		TRect rect(point,iSize);
		rect.Move(TPoint(0,-iTextHeight));
		rect.Shrink(-1,-1);
		aGc.DrawRect(rect);
	}

	if(iBitmap)
	{
		aGc.DrawBitmap(TRect(point - TPoint(0,iTextHeight),iSize),iBitmap,TRect(iSize));
	}
	else
	{
		const TDesC& text = /*((CPictureWidget&)element).*/Alt();
		int width = CCoeEnv::Static()->NormalFont()->MeasureText(text);
		TRect rect(point,TSize(width,iTextHeight));
		rect.Move(TPoint(0,-iTextHeight));
		aGc.SetPenStyle(CGraphicsContext::ESolidPen);
		aGc.SetPenColor(KRgbYellow);
		aGc.DrawRect(rect);

		aGc.SetPenColor(KRgbBlue);
		aGc.DrawText(text,point);
	}
}
Пример #2
0
EXPORT_C void DrawUtils::ClearBetweenRects(CGraphicsContext& aGc,const TRect& aOuterRect,const TRect& aInnerRect)
/** Clears between two rectangles, using a solid brush style and no pen.

@param aGc The graphics context.
@param aOuterRect The outer rectangle.
@param aInnerRect The inner rectangle. */
    { // static
    aGc.SetPenStyle(CGraphicsContext::ENullPen);
    aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    DrawBetweenRects(aGc,aOuterRect,aInnerRect);
    aGc.SetPenStyle(CGraphicsContext::ESolidPen);
    aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
    }
Пример #3
0
/**
The default function to drawn the background. It fills the supplied rectangle with the background colour.
*/
EXPORT_C void MTmCustom::DrawBackground(CGraphicsContext& aGc,const TPoint& /*aTextLayoutTopLeft*/,const TRect& aRect,
										const TLogicalRgb& aBackground,TRect& aRectDrawn) const
	{
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	SetBrushColor(aGc,aBackground);
	aGc.SetPenStyle(CGraphicsContext::ENullPen);
	aGc.DrawRect(aRect);
	aRectDrawn = aRect;
	}
Пример #4
0
void CTextWidget::Draw(CGraphicsContext &aGc) const
{
	const TDesC& text = /*((CTextWidget&)element).*/Text();

	//gc.DrawRect(rect);

	if(/*element.*/Link().Length())		//带链接
	{
		int width = CCoeEnv::Static()->NormalFont()->MeasureText(text);
		//aGc.SetPenColor(KRgbBlue);
		if(iActive)
		{
			int textHeight = CCoeEnv::Static()->NormalFont()->HeightInPixels();
			TRect rect(point,TSize(width,textHeight));
			rect.Move(TPoint(0,-textHeight));
			aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
			aGc.SetBrushColor(KRgbBlue);
			aGc.SetPenStyle(CGraphicsContext::ENullPen);
			aGc.DrawRect(rect);
			aGc.SetPenColor(KRgbWhite);
		}
		else
		{
			aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
			aGc.SetPenStyle(CGraphicsContext::ESolidPen);
			aGc.SetPenColor(KRgbBlue);
		}
		TPoint point1 = point;
		TPoint point2 = point1;
		point2.iX += width;
		aGc.DrawLine(point1,point2);
	}
	else							//不带链接
	{
		aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
		aGc.SetPenStyle(CGraphicsContext::ESolidPen);
		aGc.SetPenColor(KRgbBlack);
	}
	aGc.DrawText(text,point);
}
void CWapBrowserAppView::DrawWaiting(CGraphicsContext& aGc) const
{
	if(iShowWaiting)
	{
		TRect rect = Rect();
		rect.iTl.iY = rect.iBr.iY - 20;
		aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
		aGc.SetBrushColor(KRgbYellow);
		aGc.SetPenStyle(CGraphicsContext::ENullPen);
		aGc.DrawRect(rect);
		rect.iTl.iX = 10*iWaitingPos;
		rect.iBr.iX = rect.iTl.iX + 10;
		aGc.SetBrushColor(KRgbGreen);
		for ( int i = 0 ; i < 20 ; i++)
		{
			aGc.DrawRect(rect);
			rect.Move(TPoint(30,0));
		}
	}
}
Пример #6
0
/**
Draw text and its highlit background if any. The text should be drawn with its origin
at aTextOrigin after optionally drawing the background in aRect; and the text should be expanded
in width by aExtraPixels, normally by using letterspacing. The default function
draws the text with no special effects and supports standard and rounded highlighting only.
The font, colour, and text style, which are specified in aFormat, have already been selected into the graphics context.
*/
EXPORT_C void MTmCustomExtension::DrawText(CGraphicsContext& aGc,const TPoint& /*aTextLayoutTopLeft*/,const TRect& aRect,
								  const TTmLineInfo& /*aLineInfo*/,const TTmCharFormat& aFormat,
								  const TDesC& aText,const TInt aStart, const TInt aEnd, const TPoint& aTextOrigin,TInt aExtraPixels) const
	{
	TUint effects = aFormat.iEffects;
	CGraphicsContext::TTextParameters contextParam;
	contextParam.iStart = aStart;
	contextParam.iEnd = aEnd;
	
	// Draw the highlight.
	if (effects)
		{
		if (effects & TTmCharFormat::EBackground)
			{
			// Draw the background.
			if (!(effects & TTmCharFormat::ERounded))
				{
				SetBrushColor(aGc,aFormat.iBackgroundColor);
				aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
				aGc.SetPenStyle(CGraphicsContext::ENullPen);
				aGc.DrawRect(aRect);
				aGc.SetPenStyle(CGraphicsContext::ESolidPen);
				}

			// Draw the background with rounded corners.
			else
				{
				/*
				The pen is made solid, not null, and the pen colour is set, to
				work around some bugs in DrawRoundRect: see ER5U defect EDNGASR-487K64.
				*/
				SetBrushColor(aGc,aFormat.iBackgroundColor);
				aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
				aGc.SetPenStyle(CGraphicsContext::ESolidPen);
				SetPenColor(aGc,aFormat.iBackgroundColor);
				TSize corner(Min(aRect.Height(),aRect.Width()) / 3,aRect.Height() / 3);
				aGc.DrawRoundRect(aRect,corner);
				//+ fill in flat side if needed; draw ordinary rectangle if both sides are flat.
				SetPenColor(aGc,aFormat.iTextColor);
				}
			}

		// Draw the text offset towards the bottom-right in the highlight colour before drawing in the text colour.
		else if (effects & TTmCharFormat::EShadow)
			{
			SetPenColor(aGc,aFormat.iBackgroundColor);
			if (aExtraPixels)
				aGc.SetCharJustification(aExtraPixels,aText.Length());
			TPoint p(aTextOrigin);
			p.iX += 2;
			p.iY += 2;
			if (aStart < 0 || aEnd < 0)
				aGc.DrawText(aText,p);
			else
				aGc.DrawText(aText,&contextParam,p);
			SetPenColor(aGc,aFormat.iTextColor);
			}
		}

	// Draw the text, with letterspacing if needed.
	if (aExtraPixels)
		aGc.SetCharJustification(aExtraPixels,aText.Length());
	if (aStart < 0 || aEnd < 0)
		aGc.DrawText(aText,aTextOrigin);
	else	
		aGc.DrawText(aText,&contextParam,aTextOrigin);
	}