|
1 // Copyright (c) 1997-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 // Font and text classes used by printer drivers. |
|
15 |
|
16 #ifndef PDRSTOREFONT_H |
|
17 #define PDRSTOREFONT_H |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalAll - Internal to Symbian |
|
22 @released |
|
23 */ |
|
24 |
|
25 #include <s32mem.h> |
|
26 #include <gdi.h> |
|
27 |
|
28 |
|
29 class CFbsBitGc; |
|
30 class TPdrResource; |
|
31 class CPdrDevice; |
|
32 class CFontInfo; |
|
33 class CPdrTranslates; |
|
34 class CInfoFont; |
|
35 class CTypefaceFonts; |
|
36 class TTextFormat; |
|
37 |
|
38 |
|
39 class CPdrResources : public CBase |
|
40 { |
|
41 public: |
|
42 IMPORT_C CPdrResources(); |
|
43 IMPORT_C void RestoreL(CStreamStore& aStore, TStreamId aStreamId); |
|
44 IMPORT_C ~CPdrResources(); |
|
45 IMPORT_C TPtrC8 ResourceString(TInt anId) const; |
|
46 private: |
|
47 TInt iNumResources; |
|
48 |
|
49 TPdrResource* iResourceList; |
|
50 }; |
|
51 |
|
52 |
|
53 class TTypefaceFontsEntry |
|
54 { |
|
55 public: |
|
56 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
57 public: |
|
58 |
|
59 TStreamId iStreamId; |
|
60 |
|
61 TBool iNotInPortrait; |
|
62 |
|
63 TBool iNotInLandscape; |
|
64 }; |
|
65 |
|
66 |
|
67 class CPdrModelInfo : public CBase |
|
68 { |
|
69 public: |
|
70 IMPORT_C CPdrModelInfo(); |
|
71 IMPORT_C ~CPdrModelInfo(); |
|
72 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
73 public: |
|
74 |
|
75 TInt iFlags; |
|
76 |
|
77 TInt iKPixelWidthInTwips; |
|
78 |
|
79 TInt iKPixelHeightInTwips; |
|
80 |
|
81 TPoint iPortraitOffsetInPixels; |
|
82 |
|
83 TPoint iLandscapeOffsetInPixels; |
|
84 |
|
85 TMargins iMinMarginsInPixels; |
|
86 |
|
87 TDisplayMode iDisplayMode; |
|
88 |
|
89 TInt iNumTypefaceFonts; |
|
90 |
|
91 TTypefaceFontsEntry* iTypefaceFontsEntryList; |
|
92 |
|
93 TStreamId iResourcesStreamId; |
|
94 |
|
95 TStreamId iSpareStreamId; |
|
96 }; |
|
97 |
|
98 |
|
99 /** |
|
100 @internalTechnology |
|
101 */ |
|
102 class CPdrTypefaceStore : public CTypefaceStore |
|
103 { |
|
104 public: |
|
105 IMPORT_C static CPdrTypefaceStore* NewL(CStreamStore& aStore, TInt aNumTypefacesFonts, TTypefaceFontsEntry* aTypefaceFontsEntryList, TPageSpec::TPageOrientation aPageOrientation, TInt aKPixelHeightInTwips, CPdrDevice* aPdrDevice); |
|
106 IMPORT_C ~CPdrTypefaceStore(); |
|
107 // CTypefaceStore implementation |
|
108 IMPORT_C TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec); |
|
109 IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec); |
|
110 IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); |
|
111 IMPORT_C TInt NumTypefaces() const; |
|
112 IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const; |
|
113 IMPORT_C void TypefaceSupport(TTypefaceSupport &aTypefaceSupport, TInt aTypefaceIndex) const; |
|
114 IMPORT_C void SetPageOrientation(TPageSpec::TPageOrientation aPageOrientation); |
|
115 private: |
|
116 CPdrTypefaceStore(CStreamStore& aStore, TInt aKPixelHeightInTwips, CPdrDevice* aPdrDevice); |
|
117 void ConstructL(TInt aNumTypefacesFonts, TTypefaceFontsEntry* aTypefaceFontsEntryList, TPageSpec::TPageOrientation aPageOrientation); |
|
118 CFontInfo* FontInfoL(TStreamId aStreamId) const; |
|
119 CPdrTranslates* TranslatesL(TStreamId aStreamId) const; |
|
120 TInt GetNearestFontHeightIndex(TInt aTypefaceIndex, TInt aHeightInTwips) const; |
|
121 TFontStyle GetNearestFontStyle(TInt aTypefaceIndex, TInt aHeightIndex, const TFontStyle& aFontStyle) const; |
|
122 TBool IsFontLoaded(CFont*& aFont, const TFontSpec& aFontSpecInTwips, TInt aHeightInPixels) const; |
|
123 CInfoFont* NewFontL(TInt aBaselineOffsetInPixels, const TFontSpec& aFontSpecInTwips, TInt aFontInfoHeightInTwips, TInt aHeightInPixels, CPdrTranslates* aTranslates, const TDesC8& aCommandString, TStreamId aFontInfoStreamId); |
|
124 TInt VerticalTwipsToPixels(TInt aTwipsHeight) const; |
|
125 public: |
|
126 CPdrDevice* iPdrDevice; |
|
127 private: |
|
128 CStreamStore* iStore; |
|
129 TInt iKPixelHeightInTwips; |
|
130 CArrayPtr<CTypefaceFonts>* iTypefaceFontsList; |
|
131 CArrayPtr<CTypefaceFonts>* iPortraitTypefaceFontsList; |
|
132 CArrayPtr<CTypefaceFonts>* iLandscapeTypefaceFontsList; |
|
133 CArrayPtr<CTypefaceFonts>* iCurrentTypefaceFontsList; |
|
134 CArrayPtr<CPdrTranslates>* iTranslatesList; |
|
135 CArrayPtr<CFontInfo>* iFontInfoList; |
|
136 }; |
|
137 |
|
138 class CPageTextEntry : public CBase |
|
139 { |
|
140 public: |
|
141 IMPORT_C CPageTextEntry(const TPoint& aDrawPos, TInt aHeightInPixels, TInt aTextWidthInPixels, HBufC8* aText, TTextFormat* aTextFormat); |
|
142 IMPORT_C ~CPageTextEntry(); |
|
143 IMPORT_C TPoint TopTextPos(); |
|
144 public: |
|
145 |
|
146 TPoint iDrawPos; |
|
147 |
|
148 TInt iHeightInPixels; |
|
149 |
|
150 TInt iTextWidthInPixels; |
|
151 |
|
152 HBufC8* iText; |
|
153 |
|
154 TTextFormat* iTextFormat; |
|
155 }; |
|
156 |
|
157 |
|
158 class CPageText : public CBase |
|
159 { |
|
160 private: |
|
161 CPageText(); |
|
162 void ConstructL(); |
|
163 public: |
|
164 IMPORT_C static CPageText* NewL(); |
|
165 IMPORT_C ~CPageText(); |
|
166 IMPORT_C void Reset(); |
|
167 IMPORT_C void AddEntryL(const TPoint& aPoint, const TFontUnderline aUnderlineStyle, const TFontStrikethrough aStrikethroughStyle, const TRgb& aColor, const CInfoFont* aFont, const TDesC& aString); |
|
168 IMPORT_C TInt NumEntries(); |
|
169 IMPORT_C CPageTextEntry* operator [] (TInt anIndex); |
|
170 /** This function is internal only, and is not intended for use. */ |
|
171 inline TInt MaxFontHeightInPixels() const {return iMaxFontHeightInPixels;} |
|
172 private: |
|
173 |
|
174 TInt iMaxFontHeightInPixels; |
|
175 |
|
176 CArrayPtr<TTextFormat>* iTextFormatList; |
|
177 |
|
178 CArrayPtr<CPageTextEntry>* iPageTextEntryList; |
|
179 }; |
|
180 |
|
181 |
|
182 class CPdrGc : public CGraphicsContext |
|
183 { |
|
184 private: |
|
185 CPdrGc(CPdrDevice* aDevice); |
|
186 void ConstructL(); |
|
187 public: |
|
188 static CPdrGc* NewL(CPdrDevice* aDevice); |
|
189 IMPORT_C ~CPdrGc(); |
|
190 |
|
191 IMPORT_C CGraphicsDevice* Device() const; |
|
192 IMPORT_C void SetOrigin(const TPoint& aPos = TPoint(0, 0)); |
|
193 IMPORT_C void SetDrawMode(TDrawMode aDrawingMode); |
|
194 IMPORT_C void SetClippingRect(const TRect& aRect); |
|
195 IMPORT_C void CancelClippingRect(); |
|
196 IMPORT_C void Reset(); |
|
197 |
|
198 IMPORT_C void UseFont(const CFont* aFont); |
|
199 IMPORT_C void DiscardFont(); |
|
200 |
|
201 IMPORT_C void SetUnderlineStyle(TFontUnderline aUnderlineStyle); |
|
202 IMPORT_C void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle); |
|
203 IMPORT_C void SetWordJustification(TInt aExcessWidth, TInt aNumGaps); |
|
204 IMPORT_C void SetCharJustification(TInt aExcessWidth, TInt aNumChars); |
|
205 |
|
206 IMPORT_C void SetPenColor(const TRgb& aColor); |
|
207 IMPORT_C void SetPenStyle(TPenStyle aPenStyle); |
|
208 IMPORT_C void SetPenSize(const TSize& aSize = TSize(1, 1)); |
|
209 |
|
210 IMPORT_C void SetBrushColor(const TRgb& aColor); |
|
211 IMPORT_C void SetBrushStyle(TBrushStyle aBrushStyle); |
|
212 IMPORT_C void SetBrushOrigin(const TPoint& aOrigin); |
|
213 IMPORT_C void UseBrushPattern(const CFbsBitmap* aBitmap); |
|
214 IMPORT_C void DiscardBrushPattern(); |
|
215 |
|
216 IMPORT_C void MoveTo(const TPoint& aPoint); |
|
217 IMPORT_C void MoveBy(const TPoint& aVector); |
|
218 IMPORT_C void Plot(const TPoint& aPoint); |
|
219 |
|
220 IMPORT_C void DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd); |
|
221 IMPORT_C void DrawLine(const TPoint& aPoint1, const TPoint& aPoint2); |
|
222 IMPORT_C void DrawLineTo(const TPoint& aPoint); |
|
223 IMPORT_C void DrawLineBy(const TPoint& aVector); |
|
224 IMPORT_C void DrawPolyLine(const CArrayFix<TPoint>* aPointList); |
|
225 IMPORT_C void DrawPolyLine(const TPoint* aPointList, TInt aNumPoints); |
|
226 |
|
227 IMPORT_C void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd); |
|
228 IMPORT_C void DrawEllipse(const TRect& aRect); |
|
229 IMPORT_C void DrawRect(const TRect& aRect); |
|
230 IMPORT_C void DrawRoundRect(const TRect& aRect, const TSize& aCornerSize); |
|
231 IMPORT_C TInt DrawPolygon(const CArrayFix<TPoint>* aPointList, TFillRule aFillRule = EAlternate); |
|
232 IMPORT_C TInt DrawPolygon(const TPoint* aPointList, TInt aNumPoints, TFillRule aFillRule = EAlternate); |
|
233 |
|
234 IMPORT_C void DrawBitmap(const TPoint& aTopLeft, const CFbsBitmap* aSource); |
|
235 IMPORT_C void DrawBitmap(const TRect& aDestRect, const CFbsBitmap* aSource); |
|
236 IMPORT_C void DrawBitmap(const TRect& aDestRect, const CFbsBitmap* aSource, const TRect& aSourceRect); |
|
237 IMPORT_C void DrawBitmapMasked(const TRect& aDestRect,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask); |
|
238 IMPORT_C void DrawBitmapMasked(const TRect& aDestRect,const CWsBitmap* aBitmap,const TRect& aSourceRect,const CWsBitmap* aMaskBitmap,TBool aInvertMask); |
|
239 |
|
240 IMPORT_C void DrawText(const TDesC& aString, const TPoint& aPosition); |
|
241 IMPORT_C void DrawTextL(const TDesC& aString, const TPoint& aPosition); |
|
242 IMPORT_C void DrawText(const TDesC& aString, const TRect& aBox, TInt aBaselineOffset, TTextAlign aHoriz = ELeft, TInt aLeftMrg = 0); |
|
243 |
|
244 IMPORT_C void MapColors(const TRect& aRect,const TRgb* aColors,TInt aNumPairs,TBool aMapForwards); |
|
245 IMPORT_C TInt SetClippingRegion(const TRegion &aRegion); |
|
246 IMPORT_C void CancelClippingRegion(); |
|
247 IMPORT_C void DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp); |
|
248 IMPORT_C void DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0); |
|
249 IMPORT_C TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt); |
|
250 IMPORT_C TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp, const TRect& aSrcRect, const CWsBitmap* aAlphaBmp, const TPoint& aAlphaPt); |
|
251 |
|
252 private: |
|
253 CPdrControl* PdrControl() const; |
|
254 |
|
255 private: |
|
256 |
|
257 CPdrDevice* iPdrDevice; |
|
258 |
|
259 CFbsBitGc* iBandedGc; |
|
260 |
|
261 CFbsFont* iFbsFont; |
|
262 |
|
263 CFont* iBandedFont; |
|
264 |
|
265 CInfoFont* iFont; |
|
266 |
|
267 TPoint iOrigin; |
|
268 |
|
269 TPoint iPosition; |
|
270 |
|
271 TFontUnderline iUnderlineStyle; |
|
272 |
|
273 TFontStrikethrough iStrikethroughStyle; |
|
274 |
|
275 TRect iClippingRect; // Relative to absolute origin |
|
276 |
|
277 TInt iWordExcessWidthInPixels; |
|
278 |
|
279 TInt iNumGaps; |
|
280 |
|
281 TInt iCharExcessWidthInPixels; |
|
282 |
|
283 TInt iNumChars; |
|
284 |
|
285 TRgb iPenColor; |
|
286 |
|
287 TBool iPrintTextUsingBitmaps; |
|
288 }; |
|
289 |
|
290 |
|
291 |
|
292 #endif // PDRSTOREFONT_H |