|
1 // Copyright (c) 2007-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Declaration of a Graphics Device Interface (GDI) Context, which hooks |
|
15 // directly into a platform specific adaptation (typically hardware accelerated). |
|
16 // |
|
17 // |
|
18 |
|
19 #ifndef DIRECTGDICONTEXT_H |
|
20 #define DIRECTGDICONTEXT_H |
|
21 |
|
22 /** |
|
23 @file |
|
24 @publishedPartner |
|
25 @prototype |
|
26 */ |
|
27 |
|
28 #include <graphics/directgdifont.h> |
|
29 #include <graphics/directgditypes.h> |
|
30 #include <e32std.h> |
|
31 #include <e32def.h> |
|
32 |
|
33 // Forward declarations. |
|
34 // |
|
35 class CFbsBitmap; |
|
36 class RDirectGdiImageTarget; |
|
37 class MDirectGdiEngine; |
|
38 class CDirectGdiDriver; |
|
39 class RDirectGdiDrawableSource; |
|
40 |
|
41 |
|
42 /** |
|
43 This class typically delegates to a platform specific rendering engine |
|
44 which uses a generic interface and provides a platform specific mechanism. |
|
45 The rendering engine may or may not take advantage of hardware acceleration, |
|
46 depending on its implementation. |
|
47 |
|
48 @publishedPartner |
|
49 @prototype |
|
50 @deprecated |
|
51 |
|
52 @see CBitmapContext |
|
53 */ |
|
54 NONSHARABLE_CLASS(CDirectGdiContext): public CBase |
|
55 { |
|
56 public: |
|
57 IMPORT_C static CDirectGdiContext* NewL(CDirectGdiDriver& aDriver); |
|
58 IMPORT_C virtual ~CDirectGdiContext(); |
|
59 IMPORT_C TInt Activate(RDirectGdiImageTarget& aTarget); |
|
60 IMPORT_C void NoJustifyAutoUpdate(); |
|
61 IMPORT_C void SetJustifyAutoUpdate(); |
|
62 // The following are equivalent to CFbsBitGc functionality which maps |
|
63 // to client’s CWindowGc requests |
|
64 IMPORT_C void BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap); |
|
65 IMPORT_C void BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect); |
|
66 IMPORT_C void BitBltMasked(const TPoint& aDestPos, |
|
67 const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, |
|
68 const CFbsBitmap& aMaskBitmap, TBool aInvertMask); |
|
69 IMPORT_C void BitBltMasked(const TPoint& aDestPos, |
|
70 const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, |
|
71 const CFbsBitmap& aMaskBitmap, const TPoint& aMaskPos); |
|
72 IMPORT_C void ResetClippingRegion(); |
|
73 IMPORT_C void Clear(); |
|
74 IMPORT_C void Clear(const TRect& aRect); |
|
75 IMPORT_C void ResetBrushPattern(); |
|
76 IMPORT_C void ResetFont(); |
|
77 IMPORT_C void DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd); |
|
78 IMPORT_C void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd); |
|
79 IMPORT_C void DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap); |
|
80 IMPORT_C void DrawBitmap(const TRect& aDestRect, |
|
81 const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect); |
|
82 IMPORT_C void DrawBitmapMasked(const TRect& aDestRect, |
|
83 const CFbsBitmap& aSourceBitmap,const TRect& aSourceRect, |
|
84 const CFbsBitmap& aMaskBitmap, TBool aInvertMask); |
|
85 IMPORT_C void DrawRoundRect(const TRect& aRect, const TSize& aCornerSize); |
|
86 IMPORT_C void DrawPolyLine(const TArray<TPoint>& aPointList); |
|
87 IMPORT_C void DrawPolyLineNoEndPoint(const TArray<TPoint>& aPointList); |
|
88 IMPORT_C void DrawPolygon(const TArray<TPoint>& aPointList, DirectGdi::TFillRule aFillRule=DirectGdi::EAlternate); |
|
89 IMPORT_C void DrawEllipse(const TRect& aRect); |
|
90 IMPORT_C void DrawLine(const TPoint& aStart, const TPoint& aEnd); |
|
91 IMPORT_C void DrawLineTo(const TPoint& aPoint); |
|
92 IMPORT_C void DrawLineBy(const TPoint& aVector); |
|
93 IMPORT_C void DrawRect(const TRect& aRect); |
|
94 IMPORT_C void DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam); |
|
95 IMPORT_C void DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TPoint& aPosition); |
|
96 IMPORT_C void DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aClipRect); |
|
97 IMPORT_C void DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aClipFillRect, TInt aBaselineOffset, |
|
98 DirectGdi::TTextAlign aAlignment = DirectGdi::ELeft, TInt aMargin = 0); |
|
99 IMPORT_C void DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, TBool aUp); |
|
100 IMPORT_C void DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TPoint& aPosition, TBool aUp); |
|
101 IMPORT_C void DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aClipRect, TBool aUp); |
|
102 IMPORT_C void DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aClipRect, TInt aBaselineOffset, |
|
103 TBool aUp, DirectGdi::TTextAlign aVerticalAlignment = DirectGdi::ELeft, TInt aMargin = 0); |
|
104 IMPORT_C void DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect& aClipRect, TInt aBaselineOffset, |
|
105 TInt aTextWidth, TBool aUp, DirectGdi::TTextAlign aVerticalAlignment = DirectGdi::ELeft, TInt aMargin = 0); |
|
106 IMPORT_C void MoveTo(const TPoint& aPoint); |
|
107 IMPORT_C void MoveBy(const TPoint& aVector); |
|
108 IMPORT_C void Plot(const TPoint& aPoint); |
|
109 IMPORT_C void Reset(); |
|
110 IMPORT_C void SetBrushColor(const TRgb& aColor); |
|
111 IMPORT_C void SetBrushOrigin(const TPoint& aOrigin); |
|
112 IMPORT_C void SetBrushStyle(DirectGdi::TBrushStyle aBrushStyle); |
|
113 IMPORT_C void SetClippingRegion(const TRegion& aRegion); |
|
114 IMPORT_C void SetDrawMode(DirectGdi::TDrawMode aDrawMode); |
|
115 IMPORT_C void SetOrigin(const TPoint& aPoint = TPoint(0, 0)); |
|
116 IMPORT_C void SetPenColor(const TRgb& aColor); |
|
117 IMPORT_C void SetPenStyle(DirectGdi::TPenStyle aPenStyle); |
|
118 IMPORT_C void SetPenSize(const TSize& aSize); |
|
119 IMPORT_C void SetTextShadowColor(const TRgb& aColor); |
|
120 IMPORT_C void SetCharJustification(TInt aExcessWidth, TInt aNumChars); |
|
121 IMPORT_C void SetWordJustification(TInt aExcessWidth, TInt aNumGaps); |
|
122 IMPORT_C void SetUnderlineStyle(DirectGdi::TFontUnderline aUnderlineStyle); |
|
123 IMPORT_C void SetStrikethroughStyle(DirectGdi::TFontStrikethrough aStrikethroughStyle); |
|
124 IMPORT_C void SetBrushPattern(const CFbsBitmap& aBitmap); |
|
125 IMPORT_C void SetBrushPattern(TInt aFbsBitmapHandle); |
|
126 IMPORT_C void SetFont(const CFont* aFont); |
|
127 |
|
128 // CFbsBitGc functionality used by Wserv for its internal operations. Compatibility of these functions is not guaranteed in future releases. |
|
129 IMPORT_C void CopyRect(const TPoint& aOffset, const TRect& aRect); /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
130 IMPORT_C void CopySettings(const CDirectGdiContext& aGc); /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
131 IMPORT_C void UpdateJustification(const TDesC& aText, const DirectGdi::TTextParameters* aParam); /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
132 IMPORT_C void UpdateJustificationVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, TBool aUp); /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
133 IMPORT_C void SetFontNoDuplicate(const CDirectGdiFont* aFont); /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
134 IMPORT_C TBool HasBrushPattern() const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
135 IMPORT_C TBool HasFont() const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
136 IMPORT_C void ExternalizeL(RWriteStream& aWriteStream); /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
137 IMPORT_C void InternalizeL(RReadStream& aReadStream); /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
138 IMPORT_C TRgb BrushColor() const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
139 IMPORT_C TRgb PenColor() const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
140 IMPORT_C TRgb TextShadowColor() const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases.*/ |
|
141 |
|
142 // New functionality for image based resource |
|
143 IMPORT_C void DrawResource(const TPoint& aPos, |
|
144 const RDirectGdiDrawableSource& aSource, |
|
145 DirectGdi::TGraphicsRotation aRotation=DirectGdi::EGraphicsRotationNone); |
|
146 IMPORT_C void DrawResource(const TRect& aDestRect, |
|
147 const RDirectGdiDrawableSource& aSource, |
|
148 DirectGdi::TGraphicsRotation aRotation=DirectGdi::EGraphicsRotationNone); |
|
149 IMPORT_C void DrawResource(const TRect& aDestRect, |
|
150 const RDirectGdiDrawableSource& aSource, const TRect& aSrcRect, |
|
151 DirectGdi::TGraphicsRotation aRotation=DirectGdi::EGraphicsRotationNone); |
|
152 // New functionality for non-image based resource |
|
153 IMPORT_C void DrawResource(const TRect& aDestRect, |
|
154 const RDirectGdiDrawableSource& aSource, const TDesC8& aParam); |
|
155 IMPORT_C TInt GetInterface(TUid aInterfaceId, TAny*& aInterface); |
|
156 |
|
157 private: |
|
158 CDirectGdiContext(CDirectGdiDriver& aDirectGdiDriver); |
|
159 void ConstructL(); |
|
160 void CleanUpBrushPattern(); |
|
161 void DrawText(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TPoint& aPosition, DirectGdi::TTextAlign aAlignment, |
|
162 CFont::TTextDirection aDirection, const TRect* aClipRect = NULL, const TRect* aFillRect = NULL); |
|
163 void DoDrawText(CFont::TPositionParam& aParam, const TInt aEnd, const TRect& aClipRect); |
|
164 void DoDrawTextEx(CFont::TPositionParam& aParam, const TInt aEnd, const TRect& aClipRect, const TInt aUnderlineStrikethroughOffset); |
|
165 void CalculateClipRect2PlusBaselineOffsetAndMargin(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TPoint& aPosition, TBool aUp, |
|
166 TRect& aClipRect2, TInt& aBaselineOffset, TInt& aMargin); |
|
167 void DrawTextVertical(const TDesC& aText, const DirectGdi::TTextParameters* aParam, const TRect* aClipRect1, const TRect* aClipRect2, const TRect* aFillRect, |
|
168 TInt aBaselineOffset, TInt aTextWidth, TBool aUp, DirectGdi::TTextAlign aVert, TInt aMargin); |
|
169 void DoDrawTextVertical(CFont::TPositionParam& aParam, TBool aUp, const TInt aEnd, TRect& aClipRect); |
|
170 void DoBitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, |
|
171 const CFbsBitmap& aMaskBitmap, TBool aInvertMask, const TPoint& aMaskPos); |
|
172 TBool ValidateBitmap (const CFbsBitmap& aBitmap); |
|
173 TBool ValidateSourceAndMaskBitmaps (const CFbsBitmap& aSourceBitmap, const CFbsBitmap& aMaskBitmap); |
|
174 TRect IntersectBitmapWithRect(const CFbsBitmap& aBitmap, const TRect& aRect) const; |
|
175 void Rotate(TPoint& aPoint, const TPoint& aOrigin, TBool aUp); |
|
176 void GetUnderlineMetrics(TInt& aTop, TInt& aBottom); |
|
177 void GetStrikethroughMetrics(TInt& aTop, TInt& aBottom); |
|
178 void FillRect(const TRect& aRect, const TRgb& aColor, const TRect& aClipRect); |
|
179 TInt BaselineCorrection(); |
|
180 private: |
|
181 /** Engine that will perform the action for most operations. |
|
182 The implementation may take advantage of hardware acceleration. |
|
183 */ |
|
184 MDirectGdiEngine* iEngine; |
|
185 |
|
186 CDirectGdiDriver& iDriver; /**< For constructing and obtaining a reference to a rendering engine instance. */ |
|
187 TBool iActivated; /**< Flag for whether context has been successfully activated. */ |
|
188 RRegion iClippingRegion; /**< Local copy of clipping region.*/ |
|
189 TPoint iOrigin; /**< The origin of the drawing engine coordinate system. */ |
|
190 CDirectGdiFont iFont; /**< The current font. */ |
|
191 TInt iCharJustExcess; /**< Amount of space to be used for letterspacing. */ |
|
192 TInt iCharJustNum; /**< Number of glyph groups to be letterspaced. */ |
|
193 TInt iWordJustExcess; /**< Amount of space to be used for wordspacing. */ |
|
194 TInt iWordJustNum; /**< Number of spaces to be used for wordspacing. */ |
|
195 TPoint iLastPrintPosition; /**< Current text position. */ |
|
196 DirectGdi::TFontStrikethrough iStrikethrough; /**< Font stike-through flags. */ |
|
197 DirectGdi::TFontUnderline iUnderline; /**< Font underline flags. */ |
|
198 TRgb iPenColor; /**< The current pen colour. The default pen colour is black. */ |
|
199 TSize iPenSize; /**< The current pen size. */ |
|
200 DirectGdi::TPenStyle iPenStyle; /**< The current pen style. */ |
|
201 DirectGdi::TDrawMode iDrawMode; /**< The current drawing mode. */ |
|
202 TRgb iTextShadowColor; /**< Colour for text shadows. */ |
|
203 TRgb iBrushColor; /**< The current brush colour, the default brush colour is white. */ |
|
204 DirectGdi::TBrushStyle iBrushStyle; /**< The current brush style. */ |
|
205 CFbsBitmap iBrushPattern; /**< The currently selected brush pattern. */ |
|
206 TBool iBrushPatternUsed; |
|
207 TPoint iBrushOrigin; /**< The current brush origin. */ |
|
208 TBool iAutoUpdateJustification; |
|
209 }; |
|
210 |
|
211 #endif |