os/graphics/windowing/windowserver/test/tauto/DLLDRAW.H
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Lots of different Drawing Commands
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
	gc->SetBrushColor(TRgb::Gray4(2));
sl@0
    19
	gc->Clear();
sl@0
    20
	gc->SetBrushColor(TRgb::Gray4(0));
sl@0
    21
	gc->Clear(TRect(2,2,20,5));
sl@0
    22
	gc->DrawRect(TRect(size));
sl@0
    23
	gc->SetBrushOrigin(TPoint(1,2));
sl@0
    24
	gc->SetBrushStyle(CGraphicsContext::EForwardDiagonalHatchBrush);
sl@0
    25
	gc->DrawRect(TRect(30,2,60,8));
sl@0
    26
	gc->SetBrushOrigin(TPoint(0,0));
sl@0
    27
	gc->UseBrushPattern(aBitmap);
sl@0
    28
	gc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
sl@0
    29
	gc->DrawRect(TRect(60,2,90,8));
sl@0
    30
	gc->SetBrushStyle(CGraphicsContext::ENullBrush);
sl@0
    31
	gc->DiscardBrushPattern();
sl@0
    32
//
sl@0
    33
	gc->SetPenColor(TRgb::Gray4(1));
sl@0
    34
	gc->DrawLine(TPoint(10,12),TPoint(22,20));
sl@0
    35
	gc->SetPenSize(TSize(4,2));
sl@0
    36
	gc->DrawLine(TPoint(22,10),TPoint(40,20));
sl@0
    37
	gc->SetPenStyle(CGraphicsContext::EDottedPen);
sl@0
    38
	gc->SetPenSize(TSize(1,1));
sl@0
    39
	gc->SetPenColor(TRgb::Gray4(0));
sl@0
    40
	gc->DrawLine(TPoint(40,11),TPoint(60,20));
sl@0
    41
	gc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
    42
	gc->Plot(TPoint(60,10));
sl@0
    43
//
sl@0
    44
	gc->BitBlt(TPoint(size.AsPoint()-TPoint(20,20)),aBitmap);
sl@0
    45
	gc->BitBlt(TPoint(10,30),aBitmap,TRect(0,1,8,9));
sl@0
    46
	gc->BitBltMasked(TPoint(10,40),aBitmap,TRect(1,2,8,9),aMaskBitmap,ETrue);
sl@0
    47
	gc->BitBltMasked(TPoint(20,40),aBitmap,TRect(0,0,9,9),aMaskBitmap,EFalse);
sl@0
    48
 	gc->SetOrigin(TPoint(5,50));
sl@0
    49
	gc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
sl@0
    50
	gc->SetPenColor(TRgb::Gray4(3));
sl@0
    51
 	gc->SetClippingRect(TRect(0,0,20,15));
sl@0
    52
	//gc->DrawArc(TRect(0,0,20,15),TPoint(10,0),TPoint(1,8));
sl@0
    53
 	gc->CancelClippingRect();
sl@0
    54
	gc->SetDrawMode(CGraphicsContext::EDrawModePEN);
sl@0
    55
	gc->SetPenColor(TRgb::Gray4(0));
sl@0
    56
	gc->MoveTo(TPoint(25,0));
sl@0
    57
	gc->DrawLineTo(TPoint(40,5));
sl@0
    58
	gc->DrawLineBy(TPoint(-20,10));
sl@0
    59
//
sl@0
    60
	CArrayFixFlat<TPoint>* polyLineArray=new(ELeave) CArrayFixFlat<TPoint>(4);
sl@0
    61
	CleanupStack::PushL(polyLineArray);
sl@0
    62
	polyLineArray->AppendL(TPoint(8,0));
sl@0
    63
	polyLineArray->AppendL(TPoint(16,10));
sl@0
    64
	polyLineArray->AppendL(TPoint(0,3));
sl@0
    65
	polyLineArray->AppendL(TPoint(16,3));
sl@0
    66
	polyLineArray->AppendL(TPoint(0,10));
sl@0
    67
	polyLineArray->AppendL(TPoint(8,0));
sl@0
    68
	gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
    69
	gc->SetOrigin(TPoint(50,50));
sl@0
    70
	gc->DrawPolyLine(polyLineArray);
sl@0
    71
	gc->SetOrigin(TPoint(75,50));
sl@0
    72
	gc->DrawPolyLine(&(polyLineArray->At(0)),polyLineArray->Count());
sl@0
    73
	polyLineArray->Delete(5);
sl@0
    74
	gc->SetOrigin(TPoint(0,65));
sl@0
    75
	gc->DrawPolygon(polyLineArray,CGraphicsContext::EWinding);
sl@0
    76
	gc->SetOrigin(TPoint(25,65));
sl@0
    77
	gc->DrawPolygon(&(polyLineArray->At(0)),polyLineArray->Count(),CGraphicsContext::EWinding);
sl@0
    78
	gc->SetOrigin(TPoint(50,65));
sl@0
    79
	gc->DrawPolygon(polyLineArray,CGraphicsContext::EAlternate);
sl@0
    80
	gc->SetOrigin(TPoint(75,65));
sl@0
    81
	gc->DrawPolygon(&(polyLineArray->At(0)),polyLineArray->Count(),CGraphicsContext::EAlternate);
sl@0
    82
	CleanupStack::PopAndDestroy();
sl@0
    83
	gc->SetBrushStyle(CGraphicsContext::ENullBrush);
sl@0
    84
	gc->SetOrigin(TPoint(0,0));
sl@0
    85
//
sl@0
    86
	gc->DrawPie(TRect(5,80,30,100),TPoint(10,65),TPoint(35,80));
sl@0
    87
	gc->DrawEllipse(TRect(35,80,60,100));
sl@0
    88
	gc->DrawRoundRect(TRect(65,80,80,100),TSize(5,3));
sl@0
    89
	gc->DrawBitmap(TRect(10,105,40,120),aBitmap);
sl@0
    90
	gc->DrawBitmap(TRect(45,105,105,125),aBitmap,TRect(5,5,25,20));
sl@0
    91
//gc->DrawBitmap(TRect(110,40,205,125),aBitmap,TRect(5,5,25,20));
sl@0
    92
	if (aExtraDrawBitMap)
sl@0
    93
		gc->DrawBitmap(TPoint(110,70),aBitmap);
sl@0
    94
//
sl@0
    95
	gc->UseFont(aFont);
sl@0
    96
	TInt height=aFont->HeightInPixels();
sl@0
    97
	TInt ascent=aFont->AscentInPixels();
sl@0
    98
	TInt ypos=5;
sl@0
    99
	TInt xpos=100;
sl@0
   100
	gc->DrawText(_L("Test1"),TPoint(xpos,ypos+ascent));
sl@0
   101
	gc->DrawText(_L("Test2"),TRect(xpos,ypos+height,xpos+50,5+height*2),ascent);
sl@0
   102
	gc->DrawText(_L("Test3"),TRect(xpos,ypos+height*2,xpos+80,5+height*3),ascent,CGraphicsContext::ERight,10);
sl@0
   103
//
sl@0
   104
	ypos+=ascent+height*3;
sl@0
   105
	gc->SetUnderlineStyle(EUnderlineOn);
sl@0
   106
	gc->DrawText(_L("ULine"),TPoint(xpos,ypos));
sl@0
   107
	gc->SetUnderlineStyle(EUnderlineOff);
sl@0
   108
//
sl@0
   109
	gc->SetStrikethroughStyle(EStrikethroughOn);
sl@0
   110
	gc->DrawText(_L("Strike"),TPoint(xpos+50,ypos));
sl@0
   111
	gc->SetStrikethroughStyle(EStrikethroughOff);
sl@0
   112
	gc->SetCharJustification(15,3);
sl@0
   113
	gc->DrawText(_L("abc"),TPoint(xpos+100,ypos));
sl@0
   114
//
sl@0
   115
	gc->SetWordJustification(10,1);
sl@0
   116
	gc->DrawText(_L("Two Words"),TPoint(xpos+5,ypos+height));
sl@0
   117
//
sl@0
   118
	xpos = 80;
sl@0
   119
	ypos = 40;
sl@0
   120
	RRegion clipRegion(2);
sl@0
   121
//
sl@0
   122
	clipRegion.AddRect(TRect(xpos, ypos+10, xpos+30, ypos+20));
sl@0
   123
	clipRegion.AddRect(TRect(xpos, ypos+30, xpos+30, ypos+40));
sl@0
   124
	gc->SetClippingRegion(clipRegion);
sl@0
   125
//
sl@0
   126
	gc->DrawTextVertical(_L("Vertical Text"), TPoint(xpos+10, ypos+10), EFalse);
sl@0
   127
	gc->DrawTextVertical(_L("Vertical Text Box"), TRect(xpos+40, ypos+10, xpos+60, ypos+100), 15, EFalse);
sl@0
   128
//
sl@0
   129
	gc->CancelClippingRegion();
sl@0
   130
	clipRegion.Close();
sl@0
   131
//
sl@0
   132
	gc->AlphaBlendBitmaps(TPoint(xpos+60, ypos+100), aBitmap, TRect(0, 0, 20,20), aMaskBitmap, TPoint(0, 0));
sl@0
   133
//
sl@0
   134
	gc->SetPenColor(TRgb::Gray4(3));
sl@0
   135
	gc->SetBrushColor(TRgb::Gray4(0));
sl@0
   136
	gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   137
	xpos = 0;
sl@0
   138
	ypos = 120;
sl@0
   139
	TRect mapColorRect(xpos, ypos, xpos+20, ypos+20);
sl@0
   140
	gc->DrawRect(mapColorRect);
sl@0
   141
	TRgb colours[4] = { TRgb::Gray4(3), TRgb::Gray4(0), TRgb::Gray4(0), TRgb::Gray4(3) };
sl@0
   142
	gc->MapColors(mapColorRect, colours, 2, ETrue);
sl@0
   143
//
sl@0
   144
	gc->DiscardFont();