示例#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
// ---------------------------------------------------------
// 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);
	}
示例#3
0
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);
		}
	}
//-----------------------------------------------------------------------------
//  CBrowserViewImagesListBox::CreateIconL(
//                                      CFbsBitmap* aBitmap, TBool aShrinkIt )
//-----------------------------------------------------------------------------
//
CGulIcon* CBrowserViewImagesListBox::CreateIconL(
                                        CFbsBitmap* aBitmap, TBool aShrinkIt)
    {
    CGulIcon* icon = NULL;

    // create icon
    if(aShrinkIt)
        {
        CFbsBitmap* bmp = new(ELeave)CFbsBitmap;
        CleanupStack::PushL(bmp);
        User::LeaveIfError(bmp->Create(TSize(42,32), EColor16M));
    
        // create bitmap device
        CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(bmp);
        CleanupStack::PushL(dev);
    
        // create graphics context for bitmap device
        CGraphicsContext* ctx = NULL;
        User::LeaveIfError( dev->CreateContext(ctx) );
        CleanupStack::PushL(ctx);
    
        // calculate aspect ratio
        TSize targetSize = Fit(aBitmap->SizeInPixels(), bmp->SizeInPixels());
        // copy bitmap to temporary bitmap
        ctx->DrawBitmap(TRect(TPoint(0,0), targetSize), aBitmap, TRect(TPoint(0,0), aBitmap->SizeInPixels()));

        CleanupStack::PopAndDestroy(2);   // ctx, dev

        icon = CGulIcon::NewL(bmp); // bmp is owned, no mask used
        CleanupStack::Pop();  // bmp
        delete aBitmap;
        } 
    else 
        {
        icon = CGulIcon::NewL(aBitmap); // bitmap is owned, no mask used
        }

    return icon;
    }