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); }
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); }
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)); } } }
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); }
//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); }
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); }
/** Sets the brush colour. The brush is used for filling shapes and the background of text boxes. The brush has colour, style, pattern and pattern origin parameters. If no brush colour has been set, it defaults to white. However the default brush style is null, so when drawing to a window the default appears to be the window's background colour. @param aColor The logical colour for the brush. @see CGraphicsContext::SetDrawMode() */ EXPORT_C void MTmCustomExtension::SetBrushColor(CGraphicsContext& aGc,TLogicalRgb aColor) const { aGc.SetBrushColor(SystemColor(aColor)); }