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);
	}
}
Beispiel #2
0
/**
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;
	}
Beispiel #3
0
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);
}
Beispiel #4
0
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);
}
Beispiel #5
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);
	}
Beispiel #6
0
EXPORT_C void DrawUtils::ClearBetweenRects(CGraphicsContext& aGc,const TRect& aOuterRect,const TRect& aInnerRect)
/** Clears between two rectangles, using a solid brush style and no pen.

@param aGc The graphics context.
@param aOuterRect The outer rectangle.
@param aInnerRect The inner rectangle. */
    { // static
    aGc.SetPenStyle(CGraphicsContext::ENullPen);
    aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    DrawBetweenRects(aGc,aOuterRect,aInnerRect);
    aGc.SetPenStyle(CGraphicsContext::ESolidPen);
    aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
    }
//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);
	}
Beispiel #8
0
/** 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);
	}
//-----------------------------------------------------------------------------
//  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;
    }
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);
		}
	}
Beispiel #11
0
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);
    }
 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);
 }
Beispiel #13
0
void CPage::Draw(CGraphicsContext& aGc) const
{
	ASSERT(iLayout);

	TPoint point = iRect.iTl;
	point.iY += iTextHeight;

	aGc.UseFont(CCoeEnv::Static()->NormalFont());

	for (int i = iStartIndex ; i < iEndIndex && i < iWidgetGroupArray.Count() ; i++)
	{
		CWidgetGroup* wg = iWidgetGroupArray[i];
		wg->SetPoint(point);
		wg->Draw(aGc);
		//point.iY += iTextHeight;
		point.iY += wg->Height();
	}
	ASSERT(iScrollBar);
	iScrollBar->Draw(aGc);
}
Beispiel #14
0
EXPORT_C void DrawUtils::DrawText(CGraphicsContext& aGc,const TDesC& aString,const TRect& aBox,TInt aBaseLineOffset,
									 CGraphicsContext::TTextAlign aHoriz,TInt aMargin,const CFont* aFont)
/** Draws text inside a rectangle. 

@param aGc The graphics context.
@param aString The text string to draw. 
@param aBox The rectangle to draw the text in. 
@param aBaseLineOffset An offset from the top of the box to the text baseline. 
@param aHoriz The horizontal text alignment.
@param aMargin The margin around the text.
@param aFont The font to use. */
	{ // static
	if (aHoriz!=CGraphicsContext::ELeft)
        {
		const TInt extraWidth=aBox.Width()-aFont->TextWidthInPixels(aString)-aMargin;
        if (aHoriz==CGraphicsContext::ECenter)
            aMargin+=extraWidth/2;
		else
			aMargin=extraWidth;
        }
	aGc.DrawText(aString,aBox,aBaseLineOffset,CGraphicsContext::ELeft,aMargin);
	}
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));
		}
	}
}
Beispiel #16
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);
}
Beispiel #17
0
/** 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));
	}
Beispiel #18
0
/**
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);
	}