/** Draw the picture onto the graphics context. @param aGc The graphics context. @param aTopLeft Coordinates of the top left corner pixel of the picture. @param aRect A clipping rectangle that defines the area to draw the picture. @param aDevice The device map for the graphics device. It provides the scaling to apply to the picture. @param aPicture The drawable object. @see CPicture::Draw */ EXPORT_C void MTmCustom::DrawPicture(CGraphicsContext& aGc, const TPoint& aTopLeft, const TRect& aRect, MGraphicsDeviceMap& aDevice, const CPicture& aPicture) const { aGc.SetClippingRect(aRect); aPicture.Draw(aGc, aTopLeft, aRect, &aDevice); }
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); }
void CHlpPicture::Draw(CGraphicsContext& aGc, const TPoint& aTopLeft, const TRect& aClipRect, MGraphicsDeviceMap* aMap) const { if (iImageCountForPicture != KHlpModelMaximumNumberOfImagesForV6Point2Files) { // If there is only one image to represent this image, then we revert to using // the scaling code, as per v6.0 and 6.1 TSize size; GetSizeInPixels(aMap, size); TRect destRect(aTopLeft, size); TMargins cropMargins; GetCropInTwips(cropMargins); TSize originalSize; GetOriginalSizeInTwips(originalSize); TRect sourceRect(TPoint(cropMargins.iLeft,cropMargins.iTop), TPoint(originalSize.iWidth-cropMargins.iRight,originalSize.iHeight-cropMargins.iBottom)); sourceRect = CCoeEnv::Static()->ScreenDevice()->TwipsToPixels(sourceRect); aGc.SetClippingRect(aClipRect); aGc.DrawBitmap(destRect, iImage, sourceRect); } else { // There are (by default anyway) 3 images available for use at various zoom states, // hence we must ensure that we don't scale the bitmap. TMargins cropMargins; GetCropInTwips(cropMargins); TRect sourceRect; TRect destRect; TSize size(iImage->SizeInPixels()); destRect = TRect(aTopLeft, size); sourceRect = TRect(TPoint(cropMargins.iLeft, cropMargins.iTop), TPoint(size.iWidth - cropMargins.iRight, size.iHeight - cropMargins.iBottom)); aGc.SetClippingRect(aClipRect); aGc.DrawBitmap(destRect, iImage, sourceRect); } }
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); }