sl@0
|
1 |
// Copyright (c) 2002-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 |
// Simple stubs for testing purposes
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
@file
|
sl@0
|
20 |
@test
|
sl@0
|
21 |
@internalComponent Internal Symbian test code
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
#ifndef __TGRAPHICSCONTEXT_H__
|
sl@0
|
25 |
#define __TGRAPHICSCONTEXT_H__
|
sl@0
|
26 |
|
sl@0
|
27 |
#include <gdi.h>
|
sl@0
|
28 |
|
sl@0
|
29 |
/**
|
sl@0
|
30 |
*
|
sl@0
|
31 |
* Class to provide a dummy palette for test purposes
|
sl@0
|
32 |
*
|
sl@0
|
33 |
*/
|
sl@0
|
34 |
|
sl@0
|
35 |
|
sl@0
|
36 |
class CTestPalette2 : public CPalette
|
sl@0
|
37 |
{
|
sl@0
|
38 |
public:
|
sl@0
|
39 |
enum { KNumEntries = 4 };
|
sl@0
|
40 |
CTestPalette2()
|
sl@0
|
41 |
{
|
sl@0
|
42 |
iArray = iRgbArray;
|
sl@0
|
43 |
iNumEntries = KNumEntries;
|
sl@0
|
44 |
}
|
sl@0
|
45 |
~CTestPalette2();
|
sl@0
|
46 |
private:
|
sl@0
|
47 |
TRgb iRgbArray[KNumEntries];
|
sl@0
|
48 |
};
|
sl@0
|
49 |
|
sl@0
|
50 |
/**
|
sl@0
|
51 |
*
|
sl@0
|
52 |
* Class to provide a dummy graphics device for test purposes
|
sl@0
|
53 |
*
|
sl@0
|
54 |
*/
|
sl@0
|
55 |
|
sl@0
|
56 |
|
sl@0
|
57 |
class CTestGraphicsDevice : public CBitmapDevice
|
sl@0
|
58 |
{
|
sl@0
|
59 |
public:
|
sl@0
|
60 |
static CTestGraphicsDevice* NewL(TSize aSizeInPixels);
|
sl@0
|
61 |
~CTestGraphicsDevice();
|
sl@0
|
62 |
void SetHorizontalTwipsToPixels(TInt aTwipsToPixels);
|
sl@0
|
63 |
void SetVerticalTwipsToPixels(TInt aTwipsToPixels);
|
sl@0
|
64 |
TDisplayMode DisplayMode() const;
|
sl@0
|
65 |
TSize SizeInPixels() const;
|
sl@0
|
66 |
TSize SizeInTwips() const;
|
sl@0
|
67 |
TInt CreateContext(CGraphicsContext*& aGC);
|
sl@0
|
68 |
TInt NumTypefaces() const;
|
sl@0
|
69 |
void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const;
|
sl@0
|
70 |
TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const;
|
sl@0
|
71 |
void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const;
|
sl@0
|
72 |
void SetPalette(CPalette* aPalette);
|
sl@0
|
73 |
TInt GetPalette(CPalette*& aPalette) const;
|
sl@0
|
74 |
|
sl@0
|
75 |
// from CBitmapFont
|
sl@0
|
76 |
void GetPixel(TRgb& aColor,const TPoint& aPixel) const;
|
sl@0
|
77 |
void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode aDispMode) const;
|
sl@0
|
78 |
TInt AddFile(const TDesC& aName,TInt& aId);
|
sl@0
|
79 |
void RemoveFile(TInt aId);
|
sl@0
|
80 |
TInt GetNearestFontInPixels(CFont*& aFont,const TFontSpec& aFontSpec);
|
sl@0
|
81 |
TInt GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec);
|
sl@0
|
82 |
TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
|
sl@0
|
83 |
TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const;
|
sl@0
|
84 |
|
sl@0
|
85 |
// from MGraphicsDeviceMap from CBitmapFont
|
sl@0
|
86 |
TInt HorizontalTwipsToPixels(TInt aTwips) const;
|
sl@0
|
87 |
TInt VerticalTwipsToPixels(TInt aTwips) const;
|
sl@0
|
88 |
TInt HorizontalPixelsToTwips(TInt aPixels) const;
|
sl@0
|
89 |
TInt VerticalPixelsToTwips(TInt aPixels) const;
|
sl@0
|
90 |
TInt GetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec);
|
sl@0
|
91 |
TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
|
sl@0
|
92 |
TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
|
sl@0
|
93 |
void ReleaseFont(CFont* aFont);
|
sl@0
|
94 |
private:
|
sl@0
|
95 |
CTestGraphicsDevice(TSize aSizeInPixels);
|
sl@0
|
96 |
private:
|
sl@0
|
97 |
TSize iSize;
|
sl@0
|
98 |
TInt iHorizontalTwipsToPixels;
|
sl@0
|
99 |
TInt iVerticalTwipsToPixels;
|
sl@0
|
100 |
CTestPalette2* iPalette;
|
sl@0
|
101 |
};
|
sl@0
|
102 |
|
sl@0
|
103 |
|
sl@0
|
104 |
/**
|
sl@0
|
105 |
*
|
sl@0
|
106 |
* Class representing a line of displayed data
|
sl@0
|
107 |
*
|
sl@0
|
108 |
*/
|
sl@0
|
109 |
|
sl@0
|
110 |
|
sl@0
|
111 |
class TTestGCDisplayLine
|
sl@0
|
112 |
{
|
sl@0
|
113 |
public:
|
sl@0
|
114 |
TPoint iLinePos;
|
sl@0
|
115 |
TBuf16<80> iLineData;
|
sl@0
|
116 |
|
sl@0
|
117 |
void Set(const TPoint& aLinePos, const TDesC16& aLineData)
|
sl@0
|
118 |
{
|
sl@0
|
119 |
iLineData = aLineData;
|
sl@0
|
120 |
iLinePos = aLinePos;
|
sl@0
|
121 |
}
|
sl@0
|
122 |
|
sl@0
|
123 |
TPtrC16 LineData() const
|
sl@0
|
124 |
{
|
sl@0
|
125 |
return TPtrC16(iLineData.Ptr(), iLineData.Length());
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
const TPoint& Position() const
|
sl@0
|
129 |
{
|
sl@0
|
130 |
return iLinePos;
|
sl@0
|
131 |
}
|
sl@0
|
132 |
|
sl@0
|
133 |
};
|
sl@0
|
134 |
|
sl@0
|
135 |
/**
|
sl@0
|
136 |
*
|
sl@0
|
137 |
* Class to provide a dummy graphics context for test purposes
|
sl@0
|
138 |
*
|
sl@0
|
139 |
*/
|
sl@0
|
140 |
|
sl@0
|
141 |
class CTestGraphicsContext : public CGraphicsContext
|
sl@0
|
142 |
{
|
sl@0
|
143 |
public:
|
sl@0
|
144 |
enum TPanic
|
sl@0
|
145 |
{
|
sl@0
|
146 |
EUnimplemented,
|
sl@0
|
147 |
ETypefaceIndexOutOfRange,
|
sl@0
|
148 |
EUnknownFont
|
sl@0
|
149 |
};
|
sl@0
|
150 |
static void Panic(TInt aReason);
|
sl@0
|
151 |
CTestGraphicsContext(CTestGraphicsDevice* aGd);
|
sl@0
|
152 |
~CTestGraphicsContext();
|
sl@0
|
153 |
CGraphicsDevice* Device() const;
|
sl@0
|
154 |
void SetOrigin(const TPoint& aPos);
|
sl@0
|
155 |
void SetDrawMode(TDrawMode aDrawingMode);
|
sl@0
|
156 |
void SetClippingRect(const TRect& aRect);
|
sl@0
|
157 |
void CancelClippingRect();
|
sl@0
|
158 |
void Reset();
|
sl@0
|
159 |
void UseFont(const CFont* aFont);
|
sl@0
|
160 |
void DiscardFont();
|
sl@0
|
161 |
void SetUnderlineStyle(TFontUnderline aUnderlineStyle);
|
sl@0
|
162 |
void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle);
|
sl@0
|
163 |
void SetWordJustification(TInt aExcessWidth,TInt aNumGaps);
|
sl@0
|
164 |
void SetCharJustification(TInt aExcessWidth,TInt aNumChars);
|
sl@0
|
165 |
void SetPenColor(const TRgb& aColor);
|
sl@0
|
166 |
void SetPenStyle(TPenStyle aPenStyle);
|
sl@0
|
167 |
void SetPenSize(const TSize& aSize);
|
sl@0
|
168 |
void SetBrushColor(const TRgb& aColor);
|
sl@0
|
169 |
void SetBrushStyle(TBrushStyle aBrushStyle);
|
sl@0
|
170 |
void SetBrushOrigin(const TPoint& aOrigin);
|
sl@0
|
171 |
void UseBrushPattern(const CFbsBitmap* aBitmap);
|
sl@0
|
172 |
void DiscardBrushPattern();
|
sl@0
|
173 |
void MoveTo(const TPoint& aPoint);
|
sl@0
|
174 |
void MoveBy(const TPoint& aVector);
|
sl@0
|
175 |
void Plot(const TPoint& aPoint);
|
sl@0
|
176 |
void DrawArc(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd);
|
sl@0
|
177 |
void DrawLine(const TPoint& aPoint1,const TPoint& aPoint2);
|
sl@0
|
178 |
void DrawLineTo(const TPoint& aPoint);
|
sl@0
|
179 |
void DrawLineBy(const TPoint& aVector);
|
sl@0
|
180 |
void DrawPolyLine(const CArrayFix<TPoint>* aPointList);
|
sl@0
|
181 |
void DrawPolyLine(const TPoint* aPointList,TInt aNumPoints);
|
sl@0
|
182 |
void DrawPie(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd);
|
sl@0
|
183 |
void DrawEllipse(const TRect& aRect);
|
sl@0
|
184 |
void DrawRect(const TRect& aRect);
|
sl@0
|
185 |
void DrawRoundRect(const TRect& aRect,const TSize& aCornerSize);
|
sl@0
|
186 |
TInt DrawPolygon(const CArrayFix<TPoint>* aPointList,TFillRule aFillRule);
|
sl@0
|
187 |
TInt DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule);
|
sl@0
|
188 |
void DrawBitmap(const TPoint& aTopLeft,const CFbsBitmap* aSource);
|
sl@0
|
189 |
void DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource);
|
sl@0
|
190 |
void DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource,const TRect& aSourceRect);
|
sl@0
|
191 |
void DrawBitmapMasked(const TRect& aDestRect,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask);
|
sl@0
|
192 |
void DrawBitmapMasked(const TRect& aDestRect,const CWsBitmap* aBitmap,const TRect& aSourceRect,const CWsBitmap* aMaskBitmap,TBool aInvertMask);
|
sl@0
|
193 |
void DrawText(const TDesC& aText,const TPoint& aPosition);
|
sl@0
|
194 |
void DrawText(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TTextAlign aAlignment,
|
sl@0
|
195 |
TInt aLeftMargin);
|
sl@0
|
196 |
void DrawText(const TDesC& aText, const TPoint& aPosition,
|
sl@0
|
197 |
const TDrawTextParam&);
|
sl@0
|
198 |
|
sl@0
|
199 |
void MapColors(const TRect &aRect,const TRgb *aColors,TInt aNumPairs,TBool aMapForwards);
|
sl@0
|
200 |
TInt SetClippingRegion(const TRegion &aRegion);
|
sl@0
|
201 |
void CancelClippingRegion();
|
sl@0
|
202 |
void DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp);
|
sl@0
|
203 |
void DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0);
|
sl@0
|
204 |
|
sl@0
|
205 |
void ClearDrawnArea()
|
sl@0
|
206 |
{
|
sl@0
|
207 |
iDrawnArea.iTl.iX = iDrawnArea.iBr.iX = iDrawnArea.iTl.iY = iDrawnArea.iBr.iY = 0;
|
sl@0
|
208 |
}
|
sl@0
|
209 |
TRect DrawnArea() const
|
sl@0
|
210 |
{
|
sl@0
|
211 |
return iDrawnArea;
|
sl@0
|
212 |
}
|
sl@0
|
213 |
void ClearAreaDrawnWithCondition()
|
sl@0
|
214 |
{
|
sl@0
|
215 |
iAreaDrawnWithCondition.iTl.iX = iAreaDrawnWithCondition.iBr.iX
|
sl@0
|
216 |
= iAreaDrawnWithCondition.iTl.iY = iAreaDrawnWithCondition.iBr.iY = 0;
|
sl@0
|
217 |
}
|
sl@0
|
218 |
const TRect& AreaDrawnWithCondition() const
|
sl@0
|
219 |
{
|
sl@0
|
220 |
return iAreaDrawnWithCondition;
|
sl@0
|
221 |
}
|
sl@0
|
222 |
void AddRectToDrawnArea(const TRect& aRect);
|
sl@0
|
223 |
void AddPointToDrawnArea(const TPoint& aPoint);
|
sl@0
|
224 |
|
sl@0
|
225 |
const TTestGCDisplayLine& DisplayLine(TInt index)
|
sl@0
|
226 |
{
|
sl@0
|
227 |
return iLineArray[index];
|
sl@0
|
228 |
}
|
sl@0
|
229 |
private:
|
sl@0
|
230 |
CTestGraphicsDevice* iGd;
|
sl@0
|
231 |
TPoint iOrigin;
|
sl@0
|
232 |
TDrawMode iDrawMode;
|
sl@0
|
233 |
const CFont* iFont;
|
sl@0
|
234 |
TSize iPenSize;
|
sl@0
|
235 |
TPoint iCurrentPos;
|
sl@0
|
236 |
TRect iDrawnArea;
|
sl@0
|
237 |
TRect iAreaDrawnWithCondition;
|
sl@0
|
238 |
TInt iPenColorIndex;
|
sl@0
|
239 |
RArray<TTestGCDisplayLine> iLineArray;
|
sl@0
|
240 |
};
|
sl@0
|
241 |
|
sl@0
|
242 |
/**
|
sl@0
|
243 |
*
|
sl@0
|
244 |
* Class to provide a dummy font for test purposes
|
sl@0
|
245 |
*
|
sl@0
|
246 |
*/
|
sl@0
|
247 |
class CTestFont : public CFont
|
sl@0
|
248 |
{
|
sl@0
|
249 |
public:
|
sl@0
|
250 |
virtual TUid DoTypeUid() const;
|
sl@0
|
251 |
TInt DoHeightInPixels() const;
|
sl@0
|
252 |
TInt DoAscentInPixels() const;
|
sl@0
|
253 |
TInt DoCharWidthInPixels(TChar aChar) const;
|
sl@0
|
254 |
TInt DoTextWidthInPixels(const TDesC& aText) const;
|
sl@0
|
255 |
TInt DoBaselineOffsetInPixels() const;
|
sl@0
|
256 |
TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels) const;
|
sl@0
|
257 |
TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const;
|
sl@0
|
258 |
TInt DoMaxCharWidthInPixels() const;
|
sl@0
|
259 |
TInt DoMaxNormalCharWidthInPixels() const;
|
sl@0
|
260 |
TFontSpec DoFontSpecInTwips() const;
|
sl@0
|
261 |
TCharacterDataAvailability DoGetCharacterData(TUint aCode,
|
sl@0
|
262 |
TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const;
|
sl@0
|
263 |
};
|
sl@0
|
264 |
|
sl@0
|
265 |
|
sl@0
|
266 |
#endif /* __TGRAPHICSCONTEXT_H__ */
|