コード例 #1
0
ファイル: CONPICS.CPP プロジェクト: kuailexs/symbiandump-os2
EXPORT_C void CTestPicture::Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,MGraphicsDeviceMap* /*aMap*/) const
// draw a simple object
{
    aGc.Reset();
    aGc.SetClippingRect(aClipRect);
    TSize size; // Size in pixels
    TSize sizeInner; // In pixels
    TRect box;
    GetSizeInPixels(aGc.Device(),size);
    box.iTl=aTopLeft;
    box.iBr.iX=aTopLeft.iX+size.iWidth;
    box.iBr.iY=aTopLeft.iY+size.iHeight;
    TRgb black(0,0,0);
    TRgb white(255,255,255);
// First draw outer box and fill in rest of box.
    aGc.SetBrushColor(white);
    aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    aGc.DrawRect(box);
// Inner box.
    sizeInner.iWidth=size.iWidth/3;
    sizeInner.iHeight=size.iHeight/3;
    box.iTl.iX+=sizeInner.iWidth;
    box.iTl.iY+=sizeInner.iHeight;
    box.iBr.iX-=sizeInner.iWidth;
    box.iBr.iY-=+sizeInner.iHeight;
    aGc.SetBrushColor(black);
    aGc.SetBrushStyle(CGraphicsContext::EDiamondCrossHatchBrush);
    aGc.DrawRect(box);
}
コード例 #2
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);
	}
}
コード例 #3
0
ファイル: CONPICS.CPP プロジェクト: kuailexs/symbiandump-os2
EXPORT_C void CXzePicture::Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,MGraphicsDeviceMap* aMap) const
// Draw this simple picture.
//
{
    aGc.Reset();
    aGc.SetClippingRect(aClipRect);
    TSize size;  // Size of graphics device in pixels
    GetSizeInPixels(aMap,size);
    TRect box;  // The rectangle that exactly fits the picture
    box.iTl=aTopLeft;
    box.iBr.iX=aTopLeft.iX+size.iWidth;
    box.iBr.iY=aTopLeft.iY+size.iHeight;
    TRgb white(255,255,255);
// First draw outer box and fill in rest of box.
    aGc.SetBrushColor(white);
    aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    aGc.DrawRect(box);
// Now draw label
    CFont* font;
    TFontSpec fontSpec(_L("Arial"),213);
    if (aMap->GetNearestFontInTwips(font,fontSpec)<0)
    {
        return;
    }
    aGc.UseFont(font);
    TBuf<1> label;
    label.Append(iLabel);
    TInt baselineOffset=(box.Height()+font->AscentInPixels())/2;
    aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
    aGc.DrawText(label,box,baselineOffset,CGraphicsContext::ECenter);
    aGc.DiscardFont();
    aMap->ReleaseFont(font);
}
コード例 #4
0
ファイル: TMSOURCE.CPP プロジェクト: cdaffara/symbiandump-os2
/**
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;
	}
コード例 #5
0
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
 void Draw(CGraphicsContext& aGc, const TPoint& aTopLeft, const TRect& aClipRect, MGraphicsDeviceMap* aMap) const
 {
     // This picture is a magenta square
     TPoint size(KWidth, KHeight);
     if (aMap)
         size = aMap->TwipsToPixels(size);
     TRect rect(aTopLeft, aTopLeft + size);
     aGc.SetClippingRect(aClipRect);
     aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
     aGc.SetPenColor(KRgbMagenta);
     aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
     aGc.SetBrushColor(KRgbMagenta);
     aGc.DrawRect(rect);
 }
コード例 #7
0
ファイル: GULUTIL.CPP プロジェクト: cdaffara/symbiandump-mw1
EXPORT_C void DrawUtils::DrawBetweenRects(CGraphicsContext& aGc,const TRect& aOuterRect,const TRect& aInnerRect)
/** Draws between two rectangles.

The pen and brush settings are used as specified in the graphics context.

@param aGc The graphics context.
@param aOuterRect The outer rectangle to be drawn.
@param aInnerRect The inner rectangle to be drawn. */
    { // static
    TRect rect=aOuterRect;
    rect.iBr.iY=aInnerRect.iTl.iY;
    aGc.DrawRect(rect);
    rect.iBr.iY=aOuterRect.iBr.iY;
    rect.iTl.iY=aInnerRect.iBr.iY;
    aGc.DrawRect(rect);
    rect=aInnerRect;
    rect.iTl.iX=aOuterRect.iTl.iX;
    rect.iBr.iX=aInnerRect.iTl.iX;
    aGc.DrawRect(rect);
    rect.iTl.iX=aInnerRect.iBr.iX;
    rect.iBr.iX=aOuterRect.iBr.iX;
    aGc.DrawRect(rect);
    }
コード例 #8
0
//draw a red square
void CTestPicture::Draw(CGraphicsContext& aGc, const TPoint& aTopLeft,
	const TRect& aClipRect, MGraphicsDeviceMap* aMap) const
	{
	aGc.Reset();
	aGc.SetClippingRect(aClipRect);
	TSize size;  
	GetSizeInPixels(aMap,size);
	TRect box;  
	box.iTl=aTopLeft;
	box.iBr.iX=aTopLeft.iX+size.iWidth;
	box.iBr.iY=aTopLeft.iY+size.iHeight;
	TRgb red(255,0,0);
	aGc.SetBrushColor(red);
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	aGc.DrawRect(box);
	}
コード例 #9
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);
}
コード例 #10
0
ファイル: TMSOURCE.CPP プロジェクト: cdaffara/symbiandump-os2
/**
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);
	}