sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Lots of different Drawing Commands sl@0: // sl@0: // sl@0: sl@0: gc->SetBrushColor(TRgb::Gray4(2)); sl@0: gc->Clear(); sl@0: gc->SetBrushColor(TRgb::Gray4(0)); sl@0: gc->Clear(TRect(2,2,20,5)); sl@0: gc->DrawRect(TRect(size)); sl@0: gc->SetBrushOrigin(TPoint(1,2)); sl@0: gc->SetBrushStyle(CGraphicsContext::EForwardDiagonalHatchBrush); sl@0: gc->DrawRect(TRect(30,2,60,8)); sl@0: gc->SetBrushOrigin(TPoint(0,0)); sl@0: gc->UseBrushPattern(aBitmap); sl@0: gc->SetBrushStyle(CGraphicsContext::EPatternedBrush); sl@0: gc->DrawRect(TRect(60,2,90,8)); sl@0: gc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: gc->DiscardBrushPattern(); sl@0: // sl@0: gc->SetPenColor(TRgb::Gray4(1)); sl@0: gc->DrawLine(TPoint(10,12),TPoint(22,20)); sl@0: gc->SetPenSize(TSize(4,2)); sl@0: gc->DrawLine(TPoint(22,10),TPoint(40,20)); sl@0: gc->SetPenStyle(CGraphicsContext::EDottedPen); sl@0: gc->SetPenSize(TSize(1,1)); sl@0: gc->SetPenColor(TRgb::Gray4(0)); sl@0: gc->DrawLine(TPoint(40,11),TPoint(60,20)); sl@0: gc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: gc->Plot(TPoint(60,10)); sl@0: // sl@0: gc->BitBlt(TPoint(size.AsPoint()-TPoint(20,20)),aBitmap); sl@0: gc->BitBlt(TPoint(10,30),aBitmap,TRect(0,1,8,9)); sl@0: gc->BitBltMasked(TPoint(10,40),aBitmap,TRect(1,2,8,9),aMaskBitmap,ETrue); sl@0: gc->BitBltMasked(TPoint(20,40),aBitmap,TRect(0,0,9,9),aMaskBitmap,EFalse); sl@0: gc->SetOrigin(TPoint(5,50)); sl@0: gc->SetDrawMode(CGraphicsContext::EDrawModeXOR); sl@0: gc->SetPenColor(TRgb::Gray4(3)); sl@0: gc->SetClippingRect(TRect(0,0,20,15)); sl@0: //gc->DrawArc(TRect(0,0,20,15),TPoint(10,0),TPoint(1,8)); sl@0: gc->CancelClippingRect(); sl@0: gc->SetDrawMode(CGraphicsContext::EDrawModePEN); sl@0: gc->SetPenColor(TRgb::Gray4(0)); sl@0: gc->MoveTo(TPoint(25,0)); sl@0: gc->DrawLineTo(TPoint(40,5)); sl@0: gc->DrawLineBy(TPoint(-20,10)); sl@0: // sl@0: CArrayFixFlat* polyLineArray=new(ELeave) CArrayFixFlat(4); sl@0: CleanupStack::PushL(polyLineArray); sl@0: polyLineArray->AppendL(TPoint(8,0)); sl@0: polyLineArray->AppendL(TPoint(16,10)); sl@0: polyLineArray->AppendL(TPoint(0,3)); sl@0: polyLineArray->AppendL(TPoint(16,3)); sl@0: polyLineArray->AppendL(TPoint(0,10)); sl@0: polyLineArray->AppendL(TPoint(8,0)); sl@0: gc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: gc->SetOrigin(TPoint(50,50)); sl@0: gc->DrawPolyLine(polyLineArray); sl@0: gc->SetOrigin(TPoint(75,50)); sl@0: gc->DrawPolyLine(&(polyLineArray->At(0)),polyLineArray->Count()); sl@0: polyLineArray->Delete(5); sl@0: gc->SetOrigin(TPoint(0,65)); sl@0: gc->DrawPolygon(polyLineArray,CGraphicsContext::EWinding); sl@0: gc->SetOrigin(TPoint(25,65)); sl@0: gc->DrawPolygon(&(polyLineArray->At(0)),polyLineArray->Count(),CGraphicsContext::EWinding); sl@0: gc->SetOrigin(TPoint(50,65)); sl@0: gc->DrawPolygon(polyLineArray,CGraphicsContext::EAlternate); sl@0: gc->SetOrigin(TPoint(75,65)); sl@0: gc->DrawPolygon(&(polyLineArray->At(0)),polyLineArray->Count(),CGraphicsContext::EAlternate); sl@0: CleanupStack::PopAndDestroy(); sl@0: gc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: gc->SetOrigin(TPoint(0,0)); sl@0: // sl@0: gc->DrawPie(TRect(5,80,30,100),TPoint(10,65),TPoint(35,80)); sl@0: gc->DrawEllipse(TRect(35,80,60,100)); sl@0: gc->DrawRoundRect(TRect(65,80,80,100),TSize(5,3)); sl@0: gc->DrawBitmap(TRect(10,105,40,120),aBitmap); sl@0: gc->DrawBitmap(TRect(45,105,105,125),aBitmap,TRect(5,5,25,20)); sl@0: //gc->DrawBitmap(TRect(110,40,205,125),aBitmap,TRect(5,5,25,20)); sl@0: if (aExtraDrawBitMap) sl@0: gc->DrawBitmap(TPoint(110,70),aBitmap); sl@0: // sl@0: gc->UseFont(aFont); sl@0: TInt height=aFont->HeightInPixels(); sl@0: TInt ascent=aFont->AscentInPixels(); sl@0: TInt ypos=5; sl@0: TInt xpos=100; sl@0: gc->DrawText(_L("Test1"),TPoint(xpos,ypos+ascent)); sl@0: gc->DrawText(_L("Test2"),TRect(xpos,ypos+height,xpos+50,5+height*2),ascent); sl@0: gc->DrawText(_L("Test3"),TRect(xpos,ypos+height*2,xpos+80,5+height*3),ascent,CGraphicsContext::ERight,10); sl@0: // sl@0: ypos+=ascent+height*3; sl@0: gc->SetUnderlineStyle(EUnderlineOn); sl@0: gc->DrawText(_L("ULine"),TPoint(xpos,ypos)); sl@0: gc->SetUnderlineStyle(EUnderlineOff); sl@0: // sl@0: gc->SetStrikethroughStyle(EStrikethroughOn); sl@0: gc->DrawText(_L("Strike"),TPoint(xpos+50,ypos)); sl@0: gc->SetStrikethroughStyle(EStrikethroughOff); sl@0: gc->SetCharJustification(15,3); sl@0: gc->DrawText(_L("abc"),TPoint(xpos+100,ypos)); sl@0: // sl@0: gc->SetWordJustification(10,1); sl@0: gc->DrawText(_L("Two Words"),TPoint(xpos+5,ypos+height)); sl@0: // sl@0: xpos = 80; sl@0: ypos = 40; sl@0: RRegion clipRegion(2); sl@0: // sl@0: clipRegion.AddRect(TRect(xpos, ypos+10, xpos+30, ypos+20)); sl@0: clipRegion.AddRect(TRect(xpos, ypos+30, xpos+30, ypos+40)); sl@0: gc->SetClippingRegion(clipRegion); sl@0: // sl@0: gc->DrawTextVertical(_L("Vertical Text"), TPoint(xpos+10, ypos+10), EFalse); sl@0: gc->DrawTextVertical(_L("Vertical Text Box"), TRect(xpos+40, ypos+10, xpos+60, ypos+100), 15, EFalse); sl@0: // sl@0: gc->CancelClippingRegion(); sl@0: clipRegion.Close(); sl@0: // sl@0: gc->AlphaBlendBitmaps(TPoint(xpos+60, ypos+100), aBitmap, TRect(0, 0, 20,20), aMaskBitmap, TPoint(0, 0)); sl@0: // sl@0: gc->SetPenColor(TRgb::Gray4(3)); sl@0: gc->SetBrushColor(TRgb::Gray4(0)); sl@0: gc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: xpos = 0; sl@0: ypos = 120; sl@0: TRect mapColorRect(xpos, ypos, xpos+20, ypos+20); sl@0: gc->DrawRect(mapColorRect); sl@0: TRgb colours[4] = { TRgb::Gray4(3), TRgb::Gray4(0), TRgb::Gray4(0), TRgb::Gray4(3) }; sl@0: gc->MapColors(mapColorRect, colours, 2, ETrue); sl@0: // sl@0: gc->DiscardFont();