Update contrib.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Simple stubs for testing purposes
21 @internalComponent Internal Symbian test code
24 #ifndef __TGRAPHICSCONTEXT_H__
25 #define __TGRAPHICSCONTEXT_H__
31 * Class to provide a dummy palette for test purposes
36 class CTestPalette2 : public CPalette
39 enum { KNumEntries = 4 };
43 iNumEntries = KNumEntries;
47 TRgb iRgbArray[KNumEntries];
52 * Class to provide a dummy graphics device for test purposes
57 class CTestGraphicsDevice : public CBitmapDevice
60 static CTestGraphicsDevice* NewL(TSize aSizeInPixels);
61 ~CTestGraphicsDevice();
62 void SetHorizontalTwipsToPixels(TInt aTwipsToPixels);
63 void SetVerticalTwipsToPixels(TInt aTwipsToPixels);
64 TDisplayMode DisplayMode() const;
65 TSize SizeInPixels() const;
66 TSize SizeInTwips() const;
67 TInt CreateContext(CGraphicsContext*& aGC);
68 TInt NumTypefaces() const;
69 void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const;
70 TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const;
71 void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const;
72 void SetPalette(CPalette* aPalette);
73 TInt GetPalette(CPalette*& aPalette) const;
76 void GetPixel(TRgb& aColor,const TPoint& aPixel) const;
77 void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode aDispMode) const;
78 TInt AddFile(const TDesC& aName,TInt& aId);
79 void RemoveFile(TInt aId);
80 TInt GetNearestFontInPixels(CFont*& aFont,const TFontSpec& aFontSpec);
81 TInt GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec);
82 TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
83 TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const;
85 // from MGraphicsDeviceMap from CBitmapFont
86 TInt HorizontalTwipsToPixels(TInt aTwips) const;
87 TInt VerticalTwipsToPixels(TInt aTwips) const;
88 TInt HorizontalPixelsToTwips(TInt aPixels) const;
89 TInt VerticalPixelsToTwips(TInt aPixels) const;
90 TInt GetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec);
91 TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
92 TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
93 void ReleaseFont(CFont* aFont);
95 CTestGraphicsDevice(TSize aSizeInPixels);
98 TInt iHorizontalTwipsToPixels;
99 TInt iVerticalTwipsToPixels;
100 CTestPalette2* iPalette;
106 * Class representing a line of displayed data
111 class TTestGCDisplayLine
115 TBuf16<80> iLineData;
117 void Set(const TPoint& aLinePos, const TDesC16& aLineData)
119 iLineData = aLineData;
123 TPtrC16 LineData() const
125 return TPtrC16(iLineData.Ptr(), iLineData.Length());
128 const TPoint& Position() const
137 * Class to provide a dummy graphics context for test purposes
141 class CTestGraphicsContext : public CGraphicsContext
147 ETypefaceIndexOutOfRange,
150 static void Panic(TInt aReason);
151 CTestGraphicsContext(CTestGraphicsDevice* aGd);
152 ~CTestGraphicsContext();
153 CGraphicsDevice* Device() const;
154 void SetOrigin(const TPoint& aPos);
155 void SetDrawMode(TDrawMode aDrawingMode);
156 void SetClippingRect(const TRect& aRect);
157 void CancelClippingRect();
159 void UseFont(const CFont* aFont);
161 void SetUnderlineStyle(TFontUnderline aUnderlineStyle);
162 void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle);
163 void SetWordJustification(TInt aExcessWidth,TInt aNumGaps);
164 void SetCharJustification(TInt aExcessWidth,TInt aNumChars);
165 void SetPenColor(const TRgb& aColor);
166 void SetPenStyle(TPenStyle aPenStyle);
167 void SetPenSize(const TSize& aSize);
168 void SetBrushColor(const TRgb& aColor);
169 void SetBrushStyle(TBrushStyle aBrushStyle);
170 void SetBrushOrigin(const TPoint& aOrigin);
171 void UseBrushPattern(const CFbsBitmap* aBitmap);
172 void DiscardBrushPattern();
173 void MoveTo(const TPoint& aPoint);
174 void MoveBy(const TPoint& aVector);
175 void Plot(const TPoint& aPoint);
176 void DrawArc(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd);
177 void DrawLine(const TPoint& aPoint1,const TPoint& aPoint2);
178 void DrawLineTo(const TPoint& aPoint);
179 void DrawLineBy(const TPoint& aVector);
180 void DrawPolyLine(const CArrayFix<TPoint>* aPointList);
181 void DrawPolyLine(const TPoint* aPointList,TInt aNumPoints);
182 void DrawPie(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd);
183 void DrawEllipse(const TRect& aRect);
184 void DrawRect(const TRect& aRect);
185 void DrawRoundRect(const TRect& aRect,const TSize& aCornerSize);
186 TInt DrawPolygon(const CArrayFix<TPoint>* aPointList,TFillRule aFillRule);
187 TInt DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule);
188 void DrawBitmap(const TPoint& aTopLeft,const CFbsBitmap* aSource);
189 void DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource);
190 void DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource,const TRect& aSourceRect);
191 void DrawBitmapMasked(const TRect& aDestRect,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask);
192 void DrawBitmapMasked(const TRect& aDestRect,const CWsBitmap* aBitmap,const TRect& aSourceRect,const CWsBitmap* aMaskBitmap,TBool aInvertMask);
193 void DrawText(const TDesC& aText,const TPoint& aPosition);
194 void DrawText(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TTextAlign aAlignment,
196 void DrawText(const TDesC& aText, const TPoint& aPosition,
197 const TDrawTextParam&);
199 void MapColors(const TRect &aRect,const TRgb *aColors,TInt aNumPairs,TBool aMapForwards);
200 TInt SetClippingRegion(const TRegion &aRegion);
201 void CancelClippingRegion();
202 void DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp);
203 void DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0);
205 void ClearDrawnArea()
207 iDrawnArea.iTl.iX = iDrawnArea.iBr.iX = iDrawnArea.iTl.iY = iDrawnArea.iBr.iY = 0;
209 TRect DrawnArea() const
213 void ClearAreaDrawnWithCondition()
215 iAreaDrawnWithCondition.iTl.iX = iAreaDrawnWithCondition.iBr.iX
216 = iAreaDrawnWithCondition.iTl.iY = iAreaDrawnWithCondition.iBr.iY = 0;
218 const TRect& AreaDrawnWithCondition() const
220 return iAreaDrawnWithCondition;
222 void AddRectToDrawnArea(const TRect& aRect);
223 void AddPointToDrawnArea(const TPoint& aPoint);
225 const TTestGCDisplayLine& DisplayLine(TInt index)
227 return iLineArray[index];
230 CTestGraphicsDevice* iGd;
237 TRect iAreaDrawnWithCondition;
239 RArray<TTestGCDisplayLine> iLineArray;
244 * Class to provide a dummy font for test purposes
247 class CTestFont : public CFont
250 virtual TUid DoTypeUid() const;
251 TInt DoHeightInPixels() const;
252 TInt DoAscentInPixels() const;
253 TInt DoCharWidthInPixels(TChar aChar) const;
254 TInt DoTextWidthInPixels(const TDesC& aText) const;
255 TInt DoBaselineOffsetInPixels() const;
256 TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels) const;
257 TInt DoTextCount(const TDesC& aText,TInt aWidthInPixels,TInt& aExcessWidthInPixels) const;
258 TInt DoMaxCharWidthInPixels() const;
259 TInt DoMaxNormalCharWidthInPixels() const;
260 TFontSpec DoFontSpecInTwips() const;
261 TCharacterDataAvailability DoGetCharacterData(TUint aCode,
262 TOpenFontCharMetrics& aMetrics,const TUint8*& aBitmap,TSize& aBitmapSize) const;
266 #endif /* __TGRAPHICSCONTEXT_H__ */