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); }
// --------------------------------------------------------- // Draw() // --------------------------------------------------------- // void CMyPicture::Draw( CGraphicsContext& aGc, const TPoint& aTopLeft, const TRect& aClipRect, MGraphicsDeviceMap* aMap ) const { TRect bitmapRect=aMap->TwipsToPixels(TRect(TPoint(),iSizeInTwips)); bitmapRect.Move(aTopLeft); aGc.Reset(); aGc.SetClippingRect(aClipRect); aGc.DrawBitmap(bitmapRect, iBitmap); }
//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); }