Example #1
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);
}
Example #2
0
void CHelloControl::Draw(const TRect& /* aRect */) const
	{
	// draw surrounding rectangle
	SystemGc().DrawRect(Rect());
	// calculate rectangle to draw into
	TRect rect = Rect();
	rect.Shrink(1, 1);
	// calculate vertical centering
	CFont *font = iMessageFont;
	TInt ascent = (rect.Height() - font->HeightInPixels()) / 2
			+ font->AscentInPixels();
	// draw text in rectangle
	CWindowGc& gc = SystemGc();
	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	gc.UseFont(iMessageFont);
	switch (Phase())
		{
		case 0:
			gc.DrawText(KTxtDrawCase0, rect, ascent, CGraphicsContext::ECenter,
					0);
			break;
		case 1:
			gc.DrawText(KTxtDrawCase1, rect, ascent, CGraphicsContext::ECenter,
					0);
			break;
		case 2:
			gc.DrawText(KTxtDrawCase2, rect, ascent, CGraphicsContext::ECenter,
					0);
			break;
		case 3:
			gc.DrawText(KTxtDrawCase3, rect, ascent, CGraphicsContext::ECenter,
					0);
			break;
		case 4:
			gc.DrawText(KTxtDrawCase4, rect, ascent, CGraphicsContext::ECenter,
					0);
			break;
		case 5:
			gc.DrawText(KTxtDrawCase5, rect, ascent, CGraphicsContext::ECenter,
					0);
			break;
		case 6:
			gc.DrawText(KTxtDrawCase6, rect, ascent, CGraphicsContext::ECenter,
					0);
			break;
		default:
			break;
		};
	}
void CPrimaryColoursWin::Draw()
	{
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
	iGc->SetPenStyle(CGraphicsContext::ESolidPen);
	iGc->SetPenColor(TRgb(255, 255, 255));
	iGc->SetBrushColor(TRgb(0, 0, 0));
	TSize winSize = Size();
	iGc->DrawRect(TRect(winSize));
	
	CFont* font;
	TFontSpec fontSpec(_L(""), 300);
	TheClient->iScreen->GetNearestFontInTwips(font, fontSpec);
	
	if (font)
		{
		iGc->UseFont(font);
		TRect r(TPoint(0, 0), Size());
		r.Shrink(kMinHeight, kMinHeight);
		iGc->DrawText(iDisplayText, r, font->AscentInPixels(), iGc->ECenter, 0);
		iGc->DiscardFont();
		TheClient->iScreen->ReleaseFont(font);
		}
	
	iNumColours = 0;
	TPoint lhsAbs = Win()->AbsPosition();
	
	for(TInt channelnum = 0, channelmul = 1, xoordinate = kPlotMargin; channelnum < KNumChannels; channelnum++, channelmul <<= 8, xoordinate += kPlotWithMargin)
		{
		TRgb lastPixel(255, 255, 255, 255);
		
		for(TInt colour = 0; colour < KNumColours; colour++)
			{
			if(!iBadPixels[channelnum][colour])
				{
				iGc->SetPenColor(TRgb(colour * channelmul));				
				}
			else
				{
				iGc->SetPenColor(TRgb(255, 255, 255));			
				}

			TPoint point = TPoint(xoordinate + (colour & 0x0f), kPlotMargin + (colour >> 4));
			iGc->Plot(point);
			}
		}
		
	iDrawn=ETrue;
	}