|
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 // |
|
15 |
|
16 #ifndef PDRSTORE_H |
|
17 #define PDRSTORE_H |
|
18 |
|
19 /** |
|
20 @file |
|
21 @publishedAll |
|
22 @released |
|
23 */ |
|
24 |
|
25 #include <s32mem.h> |
|
26 #include <gdi.h> |
|
27 #include <fbs.h> |
|
28 |
|
29 class CPdrControl; |
|
30 class CStreamStore; |
|
31 class CBandedDevice; |
|
32 |
|
33 /** |
|
34 Codes used by printer drivers. |
|
35 */ |
|
36 enum TFbsEncoding |
|
37 { |
|
38 /** No code. */ |
|
39 EFbsNone = 0, |
|
40 /** Run length. */ |
|
41 EFbsRunLength = 1, |
|
42 /** TIFF. */ |
|
43 EFbsTIFF = 2, |
|
44 /** Delta row. */ |
|
45 EFbsDeltaRow = 3, |
|
46 /** Reserved. */ |
|
47 EFbsReserved = 4, |
|
48 /** Adaptive. */ |
|
49 EFbsAdaptive = 5 |
|
50 }; |
|
51 |
|
52 /** |
|
53 Determines the raster mode used by printer drivers. |
|
54 */ |
|
55 enum TFbsRasterGraphicsMode |
|
56 { |
|
57 /** Logical page orientation. */ |
|
58 EFbsLogicalPageOrientation = 0, |
|
59 /** Physcial page orientation. */ |
|
60 EFbsPhysicalPageOrientation = 3 |
|
61 }; |
|
62 |
|
63 /** |
|
64 Enumerates resources used by printer drivers. |
|
65 */ |
|
66 enum TPdrResourceId // Corresponds to IdentResource in PDRREADR.H |
|
67 { |
|
68 /** Reset. */ |
|
69 EPdrReset, |
|
70 /** Set page size. */ |
|
71 EPdrSetPageSize, |
|
72 /** Preamble. */ |
|
73 EPdrPreAmble, |
|
74 /** Postamble. */ |
|
75 EPdrPostAmble, |
|
76 /** Set text colour. */ |
|
77 EPdrSetTextColor, |
|
78 /** Bold text. */ |
|
79 EPdrBoldOn, |
|
80 /** Normal text weighting. */ |
|
81 EPdrBoldOff, |
|
82 /** Italic text. */ |
|
83 EPdrItalicOn, |
|
84 /** Normal text slant. */ |
|
85 EPdrItalicOff, |
|
86 /** Underline text. */ |
|
87 EPdrUnderlineOn, |
|
88 /** No text underline. */ |
|
89 EPdrUnderlineOff, |
|
90 /** Strike through text. */ |
|
91 EPdrStrikethroughOn, |
|
92 /** No text strike through. */ |
|
93 EPdrStrikethroughOff, |
|
94 /** New page. */ |
|
95 EPdrNewPage, |
|
96 /** Portrait view. */ |
|
97 EPdrPortrait, |
|
98 /** Landscape view. */ |
|
99 EPdrLandscape, |
|
100 /** Set the x-position of the printer head. */ |
|
101 EPdrSetXPos, |
|
102 /** Set the y-position of the printer head. */ |
|
103 EPdrSetYPos, |
|
104 /** Increment the x-position. */ |
|
105 EPdrIncrementXPos, |
|
106 /** Increment the y-position. */ |
|
107 EPdrIncrementYPos, |
|
108 /** Carriage return. */ |
|
109 EPdrCarriageReturn, |
|
110 /** Set the graphics colour. */ |
|
111 EPdrSetGraphicsColor, |
|
112 /** Starting position of bitmap. */ |
|
113 EPdrBitmapStart, |
|
114 /** End position of bitmap. */ |
|
115 EPdrBitmapEnd, |
|
116 /** Scan line. */ |
|
117 EPdrScanLine, |
|
118 /** End of scan line. */ |
|
119 EPdrEndScanLine, |
|
120 /** Extra resource holder. */ |
|
121 EPdrResource1, |
|
122 /** Extra resource holder. */ |
|
123 EPdrResource2, |
|
124 /** Extra resource holder. */ |
|
125 EPdrResource3, |
|
126 /** Extra resource holder. */ |
|
127 EPdrResource4, |
|
128 /** Extra resource holder. */ |
|
129 EPdrResource5, |
|
130 /** Extra resource holder. */ |
|
131 EPdrResource6, |
|
132 /** Extra resource holder. */ |
|
133 EPdrResource7, |
|
134 /** Extra resource holder. */ |
|
135 EPdrResource8 |
|
136 }; |
|
137 |
|
138 /** |
|
139 Maximum length of a printer command string. |
|
140 */ |
|
141 const TInt KMaxCommandStringLength = 0x40; |
|
142 /** |
|
143 Defines a command string used by printer drivers. |
|
144 */ |
|
145 typedef TBuf8<KMaxCommandStringLength> TCommandString; |
|
146 |
|
147 // Forward declarations |
|
148 class CFontInfo; |
|
149 class CPdrTranslates; |
|
150 class CPdrDevice; |
|
151 |
|
152 /** WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases. |
|
153 */ |
|
154 class CInfoFont : public CFont |
|
155 { |
|
156 friend class CPdrTypefaceStore; |
|
157 public: |
|
158 // New functions |
|
159 IMPORT_C HBufC8* TranslateStringL(const TDesC& aString) const; |
|
160 IMPORT_C TPtrC8 CommandString() const; |
|
161 IMPORT_C TBool RepertoireContains(TChar aChar) const; |
|
162 IMPORT_C TBool AllCharsInFontRepertoire(const TDesC& aString, TInt& aFirstCharNotInRepertoire, TInt& aLength) const; |
|
163 inline CFontInfo* FontInfo() const {return iFontInfo;} |
|
164 CFont* RealFont() const; |
|
165 private: |
|
166 CInfoFont(TInt aBaselineOffsetInPixels, const TFontSpec& aFontSpecInTwips, TInt aFontInfoHeightInTwips, TInt aHeightInPixels, CPdrTranslates* aTranslates, const TDesC8& aCommandString, CPdrDevice* aPdrDevice); |
|
167 ~CInfoFont(); |
|
168 TInt Width(TInt aNum) const; |
|
169 TInt Height(TInt aNum) const; |
|
170 void CreateBandedFontIfRequired(); |
|
171 // From CFont |
|
172 IMPORT_C virtual TUid DoTypeUid() const; |
|
173 IMPORT_C virtual TInt DoHeightInPixels() const; |
|
174 IMPORT_C virtual TInt DoAscentInPixels() const; |
|
175 IMPORT_C virtual TInt DoCharWidthInPixels(TChar aChar) const; |
|
176 IMPORT_C virtual TInt DoTextWidthInPixels(const TDesC &aText) const; |
|
177 IMPORT_C virtual TInt DoBaselineOffsetInPixels() const; |
|
178 IMPORT_C virtual TInt DoTextCount(const TDesC &aText, TInt aWidthInPixels) const; |
|
179 IMPORT_C virtual TInt DoTextCount(const TDesC &aText, TInt aWidthInPixels, TInt &aExcessWidthInPixels) const; |
|
180 IMPORT_C virtual TInt DoMaxCharWidthInPixels() const; |
|
181 IMPORT_C virtual TInt DoMaxNormalCharWidthInPixels() const; |
|
182 IMPORT_C virtual TFontSpec DoFontSpecInTwips() const; |
|
183 private: |
|
184 TCommandString iCommandString; |
|
185 TInt iBaselineOffsetInPixels; |
|
186 TFontSpec iFontSpecInTwips; |
|
187 TInt iFontInfoHeightInTwips; |
|
188 TInt iHeightInPixels; |
|
189 CFontInfo* iFontInfo; |
|
190 CPdrTranslates* iTranslates; |
|
191 CPdrDevice* iPdrDevice; |
|
192 CFont* iRealFont; |
|
193 }; |
|
194 |
|
195 |
|
196 class CPageBuffer : public CActive |
|
197 { |
|
198 public: |
|
199 IMPORT_C static CPageBuffer* NewL(CPrinterPort* aPrinterPort); |
|
200 IMPORT_C static CPageBuffer* NewL(CPrinterPort* aPrinterPort, TInt aGranularity); |
|
201 IMPORT_C void StartFlush(TRequestStatus& aRequestStatus); |
|
202 IMPORT_C void AddBytesL(const TDesC8& aDes); |
|
203 IMPORT_C RWriteStream& CreateWriteStreamL(); |
|
204 IMPORT_C void CloseWriteStream(); |
|
205 IMPORT_C ~CPageBuffer(); |
|
206 void DoCancel(); |
|
207 void RunL(); |
|
208 private: |
|
209 void ConstructL(); |
|
210 CPageBuffer(CPrinterPort* aPrinterPort, TInt aGranularity); |
|
211 void Queue(); |
|
212 private: |
|
213 |
|
214 TRequestStatus* iRequestStatus; |
|
215 |
|
216 TInt iWritePos; |
|
217 |
|
218 TInt iGranularity; |
|
219 |
|
220 CBufSeg* iBuffer; |
|
221 |
|
222 TPtr8 iPtr; |
|
223 |
|
224 CPrinterPort* iPrinterPort; |
|
225 |
|
226 RBufWriteStream iWriteStream; |
|
227 |
|
228 CBufSeg* iWriteStreamBuffer; |
|
229 }; |
|
230 |
|
231 |
|
232 /** WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases. |
|
233 */ |
|
234 class TTextFormat |
|
235 { |
|
236 public: |
|
237 IMPORT_C TTextFormat(); |
|
238 IMPORT_C TTextFormat(const TFontUnderline anUnderlineStyle, const TFontStrikethrough aStrikethroughStyle, const TRgb& aColor, const TDesC8& aFontString, const TFontStyle& aFontStyle); |
|
239 IMPORT_C TBool operator == (const TTextFormat& aFormat) const; |
|
240 public: |
|
241 |
|
242 TFontUnderline iUnderlineStyle; |
|
243 |
|
244 TFontStrikethrough iStrikethroughStyle; |
|
245 |
|
246 TRgb iColor; |
|
247 |
|
248 TCommandString iFontString; |
|
249 |
|
250 TFontStyle iFontStyle; |
|
251 }; |
|
252 |
|
253 |
|
254 // Forward declarations |
|
255 class CPdrModelInfo; |
|
256 class CPdrTypefaceStore; |
|
257 |
|
258 /** |
|
259 @see CFbsDrvDevice |
|
260 */ |
|
261 class CPdrDevice : public CPrinterDevice |
|
262 { |
|
263 protected: |
|
264 IMPORT_C CPdrDevice(); |
|
265 public: |
|
266 IMPORT_C virtual ~CPdrDevice(); |
|
267 IMPORT_C void SelectPageSpecInTwips(const TPageSpec& aPageSpec); |
|
268 IMPORT_C TDisplayMode DisplayMode() const; |
|
269 IMPORT_C TSize SizeInPixels() const; |
|
270 IMPORT_C TSize SizeInTwips() const; |
|
271 IMPORT_C TRect PrintablePageInPixels() const; |
|
272 IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwips) const; |
|
273 IMPORT_C TInt VerticalTwipsToPixels(TInt aTwips) const; |
|
274 IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixels) const; |
|
275 IMPORT_C TInt VerticalPixelsToTwips(TInt aPixels) const; |
|
276 IMPORT_C TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec); |
|
277 IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont *&aFont, const TFontSpec &aFontSpec); |
|
278 IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont *&aFont, const TFontSpec &aFontSpec, TInt aMaxHeight); |
|
279 IMPORT_C TInt NumTypefaces() const; |
|
280 IMPORT_C void TypefaceSupport(TTypefaceSupport& aTypefaceSupport, TInt aTypefaceIndex) const; |
|
281 IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const; |
|
282 IMPORT_C void PaletteAttributes(TBool& aModifiable, TInt& aNumEntries) const; |
|
283 IMPORT_C void SetPalette(CPalette* aPalette); |
|
284 IMPORT_C TInt GetPalette(CPalette*& aPalette) const; |
|
285 IMPORT_C TPrinterModelEntry Model() const; |
|
286 IMPORT_C TInt Flags() const; |
|
287 IMPORT_C TInt SetModel(const TPrinterModelHeader& aModel, CStreamStore& aStore); |
|
288 IMPORT_C void ReleaseFont(CFont* aFont); |
|
289 IMPORT_C TPoint OffsetInPixels(); |
|
290 |
|
291 protected: |
|
292 IMPORT_C virtual TSize KPixelSizeInTwips() const; |
|
293 private: |
|
294 void DoSetModelL(); |
|
295 protected: |
|
296 |
|
297 CStreamStore* iStore; |
|
298 |
|
299 TPrinterModelHeader iModel; |
|
300 |
|
301 CPdrModelInfo* iModelInfo; |
|
302 |
|
303 CPdrTypefaceStore* iTypefaceStore; |
|
304 }; |
|
305 |
|
306 |
|
307 //Forward declarations |
|
308 class CPdrResources; |
|
309 class CPageText; |
|
310 |
|
311 class CPdrControl : public CPrinterControl |
|
312 { |
|
313 public: |
|
314 IMPORT_C ~CPdrControl(); |
|
315 IMPORT_C TInt CreateContext(CGraphicsContext*& aGC); |
|
316 IMPORT_C TInt BandsPerPage(); |
|
317 IMPORT_C TMoreOnPage QueueGetBand(TRequestStatus& aStatus, TBandAttributes& aBand); // returns affirmative if more to print on current page |
|
318 IMPORT_C void QueueEndPrint(TRequestStatus& aStatus); // Called at finish to flush buffer, tidy up printer etc. |
|
319 IMPORT_C void AbortPrint(); // tidy up synchronously in a short time |
|
320 IMPORT_C virtual void DrawTextL(const TPoint& aPoint, const TFontUnderline aUnderlineStyle, const TFontStrikethrough aStrikethroughStyle, const TRgb& aColor, const CInfoFont* aFont, const TDesC& aString); |
|
321 IMPORT_C TBool IsGraphicsBand() const; |
|
322 inline CBandedDevice* BandedDevice() const {return iBandedDevice;} |
|
323 protected: |
|
324 IMPORT_C CPdrControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort); |
|
325 IMPORT_C virtual void DoQueueGetBandL(); |
|
326 IMPORT_C virtual void DoQueueEndPrintL(); |
|
327 IMPORT_C void ConstructL(CStreamStore& aStore, TStreamId aStreamId); |
|
328 |
|
329 virtual void OutputBandL() = 0; |
|
330 |
|
331 IMPORT_C virtual void MoveToL(const TPoint& aPoint); |
|
332 IMPORT_C virtual void MoveByL(const TPoint& aVector); |
|
333 IMPORT_C virtual void OutputTextL(const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& aTextFormat, const TDesC8& aString); |
|
334 |
|
335 IMPORT_C virtual void SetPageSizeL(); |
|
336 IMPORT_C virtual void SetPageOrientationL(); |
|
337 IMPORT_C virtual void SetFontPostureL(const TFontPosture aPosture); |
|
338 IMPORT_C virtual void SetFontStrokeWeightL(const TFontStrokeWeight aStrokeWeight); |
|
339 IMPORT_C virtual void SetTextColorL(const TRgb& aColor); |
|
340 IMPORT_C virtual void CommandL(const TInt anId); |
|
341 |
|
342 IMPORT_C TBool TransformBuffer(); // These two functions are not implemented anywhere |
|
343 IMPORT_C TBool CompressBuffer(); // for this class. Nor do I believe they are defined |
|
344 // for a reason. But since they are part of the |
|
345 // existing interface of a DLL in a ROM I need to |
|
346 // patch. They get to stay there for the moment. CJC |
|
347 |
|
348 protected: |
|
349 |
|
350 CPdrDevice* iPdrDevice; |
|
351 |
|
352 CPageBuffer* iPageBuffer; |
|
353 |
|
354 CPdrResources* iResources; |
|
355 |
|
356 CBandedDevice* iBandedDevice; |
|
357 |
|
358 CPageText* iPageText; |
|
359 |
|
360 TInt iBandIndex; |
|
361 |
|
362 TInt iEntryIndex; |
|
363 |
|
364 TPoint iPosition; |
|
365 |
|
366 TTextFormat iTextFormat; |
|
367 }; |
|
368 |
|
369 |
|
370 class CFbsDrvDevice : public CPdrDevice |
|
371 { |
|
372 public: |
|
373 IMPORT_C CFbsDrvDevice(); |
|
374 IMPORT_C ~CFbsDrvDevice(); |
|
375 |
|
376 IMPORT_C TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec); |
|
377 IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont *&aFont, const TFontSpec &aFontSpec); |
|
378 IMPORT_C void ReleaseFont(CFont* aFont); |
|
379 IMPORT_C TInt NumTypefaces() const; |
|
380 IMPORT_C void TypefaceSupport(TTypefaceSupport& aTypefaceSupport, TInt aTypefaceIndex) const; |
|
381 IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const; |
|
382 |
|
383 IMPORT_C TInt CreateContext(CGraphicsContext*& aGc); |
|
384 IMPORT_C void CreateControlL(CPrinterPort* aPrinterPort); |
|
385 IMPORT_C TInt SetModel(const TPrinterModelHeader& aModel, CStreamStore& aStore); |
|
386 IMPORT_C void LoadTypeFaceList(); |
|
387 IMPORT_C TSize KPixelSizeInTwips() const; |
|
388 IMPORT_C void LoadTypeFaceListL(); |
|
389 IMPORT_C TInt SetModelL(const TPrinterModelHeader& aModel, CStreamStore& aStore); |
|
390 private: |
|
391 // reserved virtual function space |
|
392 IMPORT_C virtual void Reserved_1(); |
|
393 |
|
394 protected: |
|
395 |
|
396 CFbsTypefaceStore* iFbsTypefaceStore; |
|
397 |
|
398 CArrayFixFlat<TInt>* iGenTypefaceFontsList; |
|
399 |
|
400 CArrayFixFlat<TInt>* iGenTypefaceFontsType; |
|
401 |
|
402 TInt iFbsTypefaceCount; |
|
403 |
|
404 TInt iPdrTypefaceCount; |
|
405 |
|
406 private: |
|
407 |
|
408 TAny* iReserved; |
|
409 }; |
|
410 |
|
411 |
|
412 class CFbsDrvControl : public CPdrControl |
|
413 { |
|
414 public: |
|
415 IMPORT_C static CFbsDrvControl* NewL(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId); |
|
416 IMPORT_C ~CFbsDrvControl(); |
|
417 |
|
418 protected: |
|
419 IMPORT_C virtual void OutputBandL(); |
|
420 |
|
421 IMPORT_C CFbsDrvControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort); |
|
422 IMPORT_C void ConstructL(CStreamStore& aStore, TStreamId aResourcesStreamId); |
|
423 IMPORT_C void SetPageSizeL(); |
|
424 |
|
425 IMPORT_C TBool TransformBuffer(); |
|
426 IMPORT_C TBool CompressBuffer(); |
|
427 |
|
428 private: |
|
429 // reserved virtual function space |
|
430 IMPORT_C virtual void Reserved_1(); |
|
431 |
|
432 protected: |
|
433 |
|
434 HBufC8* iScanLine; |
|
435 |
|
436 HBufC8* iCompressedScanLine; |
|
437 |
|
438 private: |
|
439 |
|
440 TAny* iReserved; |
|
441 }; |
|
442 |
|
443 #endif |