Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
34 Codes used by printer drivers.
53 Determines the raster mode used by printer drivers.
55 enum TFbsRasterGraphicsMode
57 /** Logical page orientation. */
58 EFbsLogicalPageOrientation = 0,
59 /** Physcial page orientation. */
60 EFbsPhysicalPageOrientation = 3
64 Enumerates resources used by printer drivers.
66 enum TPdrResourceId // Corresponds to IdentResource in PDRREADR.H
76 /** Set text colour. */
80 /** Normal text weighting. */
84 /** Normal text slant. */
86 /** Underline text. */
88 /** No text underline. */
90 /** Strike through text. */
92 /** No text strike through. */
98 /** Landscape view. */
100 /** Set the x-position of the printer head. */
102 /** Set the y-position of the printer head. */
104 /** Increment the x-position. */
106 /** Increment the y-position. */
108 /** Carriage return. */
110 /** Set the graphics colour. */
111 EPdrSetGraphicsColor,
112 /** Starting position of bitmap. */
114 /** End position of bitmap. */
118 /** End of scan line. */
120 /** Extra resource holder. */
122 /** Extra resource holder. */
124 /** Extra resource holder. */
126 /** Extra resource holder. */
128 /** Extra resource holder. */
130 /** Extra resource holder. */
132 /** Extra resource holder. */
134 /** Extra resource holder. */
139 Maximum length of a printer command string.
141 const TInt KMaxCommandStringLength = 0x40;
143 Defines a command string used by printer drivers.
145 typedef TBuf8<KMaxCommandStringLength> TCommandString;
147 // Forward declarations
149 class CPdrTranslates;
152 /** WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases.
154 class CInfoFont : public CFont
156 friend class CPdrTypefaceStore;
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;
166 CInfoFont(TInt aBaselineOffsetInPixels, const TFontSpec& aFontSpecInTwips, TInt aFontInfoHeightInTwips, TInt aHeightInPixels, CPdrTranslates* aTranslates, const TDesC8& aCommandString, CPdrDevice* aPdrDevice);
168 TInt Width(TInt aNum) const;
169 TInt Height(TInt aNum) const;
170 void CreateBandedFontIfRequired();
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;
184 TCommandString iCommandString;
185 TInt iBaselineOffsetInPixels;
186 TFontSpec iFontSpecInTwips;
187 TInt iFontInfoHeightInTwips;
188 TInt iHeightInPixels;
189 CFontInfo* iFontInfo;
190 CPdrTranslates* iTranslates;
191 CPdrDevice* iPdrDevice;
196 class CPageBuffer : public CActive
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();
210 CPageBuffer(CPrinterPort* aPrinterPort, TInt aGranularity);
214 TRequestStatus* iRequestStatus;
224 CPrinterPort* iPrinterPort;
226 RBufWriteStream iWriteStream;
228 CBufSeg* iWriteStreamBuffer;
232 /** WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases.
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;
242 TFontUnderline iUnderlineStyle;
244 TFontStrikethrough iStrikethroughStyle;
248 TCommandString iFontString;
250 TFontStyle iFontStyle;
254 // Forward declarations
256 class CPdrTypefaceStore;
261 class CPdrDevice : public CPrinterDevice
264 IMPORT_C CPdrDevice();
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();
292 IMPORT_C virtual TSize KPixelSizeInTwips() const;
297 CStreamStore* iStore;
299 TPrinterModelHeader iModel;
301 CPdrModelInfo* iModelInfo;
303 CPdrTypefaceStore* iTypefaceStore;
307 //Forward declarations
311 class CPdrControl : public CPrinterControl
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;}
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);
329 virtual void OutputBandL() = 0;
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);
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);
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
350 CPdrDevice* iPdrDevice;
352 CPageBuffer* iPageBuffer;
354 CPdrResources* iResources;
356 CBandedDevice* iBandedDevice;
358 CPageText* iPageText;
366 TTextFormat iTextFormat;
370 class CFbsDrvDevice : public CPdrDevice
373 IMPORT_C CFbsDrvDevice();
374 IMPORT_C ~CFbsDrvDevice();
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;
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);
391 // reserved virtual function space
392 IMPORT_C virtual void Reserved_1();
396 CFbsTypefaceStore* iFbsTypefaceStore;
398 CArrayFixFlat<TInt>* iGenTypefaceFontsList;
400 CArrayFixFlat<TInt>* iGenTypefaceFontsType;
402 TInt iFbsTypefaceCount;
404 TInt iPdrTypefaceCount;
412 class CFbsDrvControl : public CPdrControl
415 IMPORT_C static CFbsDrvControl* NewL(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId);
416 IMPORT_C ~CFbsDrvControl();
419 IMPORT_C virtual void OutputBandL();
421 IMPORT_C CFbsDrvControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort);
422 IMPORT_C void ConstructL(CStreamStore& aStore, TStreamId aResourcesStreamId);
423 IMPORT_C void SetPageSizeL();
425 IMPORT_C TBool TransformBuffer();
426 IMPORT_C TBool CompressBuffer();
429 // reserved virtual function space
430 IMPORT_C virtual void Reserved_1();
436 HBufC8* iCompressedScanLine;