sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef PDRSTORE_H sl@0: #define PDRSTORE_H sl@0: sl@0: /** sl@0: @file sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: class CPdrControl; sl@0: class CStreamStore; sl@0: class CBandedDevice; sl@0: sl@0: /** sl@0: Codes used by printer drivers. sl@0: */ sl@0: enum TFbsEncoding sl@0: { sl@0: /** No code. */ sl@0: EFbsNone = 0, sl@0: /** Run length. */ sl@0: EFbsRunLength = 1, sl@0: /** TIFF. */ sl@0: EFbsTIFF = 2, sl@0: /** Delta row. */ sl@0: EFbsDeltaRow = 3, sl@0: /** Reserved. */ sl@0: EFbsReserved = 4, sl@0: /** Adaptive. */ sl@0: EFbsAdaptive = 5 sl@0: }; sl@0: sl@0: /** sl@0: Determines the raster mode used by printer drivers. sl@0: */ sl@0: enum TFbsRasterGraphicsMode sl@0: { sl@0: /** Logical page orientation. */ sl@0: EFbsLogicalPageOrientation = 0, sl@0: /** Physcial page orientation. */ sl@0: EFbsPhysicalPageOrientation = 3 sl@0: }; sl@0: sl@0: /** sl@0: Enumerates resources used by printer drivers. sl@0: */ sl@0: enum TPdrResourceId // Corresponds to IdentResource in PDRREADR.H sl@0: { sl@0: /** Reset. */ sl@0: EPdrReset, sl@0: /** Set page size. */ sl@0: EPdrSetPageSize, sl@0: /** Preamble. */ sl@0: EPdrPreAmble, sl@0: /** Postamble. */ sl@0: EPdrPostAmble, sl@0: /** Set text colour. */ sl@0: EPdrSetTextColor, sl@0: /** Bold text. */ sl@0: EPdrBoldOn, sl@0: /** Normal text weighting. */ sl@0: EPdrBoldOff, sl@0: /** Italic text. */ sl@0: EPdrItalicOn, sl@0: /** Normal text slant. */ sl@0: EPdrItalicOff, sl@0: /** Underline text. */ sl@0: EPdrUnderlineOn, sl@0: /** No text underline. */ sl@0: EPdrUnderlineOff, sl@0: /** Strike through text. */ sl@0: EPdrStrikethroughOn, sl@0: /** No text strike through. */ sl@0: EPdrStrikethroughOff, sl@0: /** New page. */ sl@0: EPdrNewPage, sl@0: /** Portrait view. */ sl@0: EPdrPortrait, sl@0: /** Landscape view. */ sl@0: EPdrLandscape, sl@0: /** Set the x-position of the printer head. */ sl@0: EPdrSetXPos, sl@0: /** Set the y-position of the printer head. */ sl@0: EPdrSetYPos, sl@0: /** Increment the x-position. */ sl@0: EPdrIncrementXPos, sl@0: /** Increment the y-position. */ sl@0: EPdrIncrementYPos, sl@0: /** Carriage return. */ sl@0: EPdrCarriageReturn, sl@0: /** Set the graphics colour. */ sl@0: EPdrSetGraphicsColor, sl@0: /** Starting position of bitmap. */ sl@0: EPdrBitmapStart, sl@0: /** End position of bitmap. */ sl@0: EPdrBitmapEnd, sl@0: /** Scan line. */ sl@0: EPdrScanLine, sl@0: /** End of scan line. */ sl@0: EPdrEndScanLine, sl@0: /** Extra resource holder. */ sl@0: EPdrResource1, sl@0: /** Extra resource holder. */ sl@0: EPdrResource2, sl@0: /** Extra resource holder. */ sl@0: EPdrResource3, sl@0: /** Extra resource holder. */ sl@0: EPdrResource4, sl@0: /** Extra resource holder. */ sl@0: EPdrResource5, sl@0: /** Extra resource holder. */ sl@0: EPdrResource6, sl@0: /** Extra resource holder. */ sl@0: EPdrResource7, sl@0: /** Extra resource holder. */ sl@0: EPdrResource8 sl@0: }; sl@0: sl@0: /** sl@0: Maximum length of a printer command string. sl@0: */ sl@0: const TInt KMaxCommandStringLength = 0x40; sl@0: /** sl@0: Defines a command string used by printer drivers. sl@0: */ sl@0: typedef TBuf8 TCommandString; sl@0: sl@0: // Forward declarations sl@0: class CFontInfo; sl@0: class CPdrTranslates; sl@0: class CPdrDevice; sl@0: sl@0: /** WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases. sl@0: */ sl@0: class CInfoFont : public CFont sl@0: { sl@0: friend class CPdrTypefaceStore; sl@0: public: sl@0: // New functions sl@0: IMPORT_C HBufC8* TranslateStringL(const TDesC& aString) const; sl@0: IMPORT_C TPtrC8 CommandString() const; sl@0: IMPORT_C TBool RepertoireContains(TChar aChar) const; sl@0: IMPORT_C TBool AllCharsInFontRepertoire(const TDesC& aString, TInt& aFirstCharNotInRepertoire, TInt& aLength) const; sl@0: inline CFontInfo* FontInfo() const {return iFontInfo;} sl@0: CFont* RealFont() const; sl@0: private: sl@0: CInfoFont(TInt aBaselineOffsetInPixels, const TFontSpec& aFontSpecInTwips, TInt aFontInfoHeightInTwips, TInt aHeightInPixels, CPdrTranslates* aTranslates, const TDesC8& aCommandString, CPdrDevice* aPdrDevice); sl@0: ~CInfoFont(); sl@0: TInt Width(TInt aNum) const; sl@0: TInt Height(TInt aNum) const; sl@0: void CreateBandedFontIfRequired(); sl@0: // From CFont sl@0: IMPORT_C virtual TUid DoTypeUid() const; sl@0: IMPORT_C virtual TInt DoHeightInPixels() const; sl@0: IMPORT_C virtual TInt DoAscentInPixels() const; sl@0: IMPORT_C virtual TInt DoCharWidthInPixels(TChar aChar) const; sl@0: IMPORT_C virtual TInt DoTextWidthInPixels(const TDesC &aText) const; sl@0: IMPORT_C virtual TInt DoBaselineOffsetInPixels() const; sl@0: IMPORT_C virtual TInt DoTextCount(const TDesC &aText, TInt aWidthInPixels) const; sl@0: IMPORT_C virtual TInt DoTextCount(const TDesC &aText, TInt aWidthInPixels, TInt &aExcessWidthInPixels) const; sl@0: IMPORT_C virtual TInt DoMaxCharWidthInPixels() const; sl@0: IMPORT_C virtual TInt DoMaxNormalCharWidthInPixels() const; sl@0: IMPORT_C virtual TFontSpec DoFontSpecInTwips() const; sl@0: private: sl@0: TCommandString iCommandString; sl@0: TInt iBaselineOffsetInPixels; sl@0: TFontSpec iFontSpecInTwips; sl@0: TInt iFontInfoHeightInTwips; sl@0: TInt iHeightInPixels; sl@0: CFontInfo* iFontInfo; sl@0: CPdrTranslates* iTranslates; sl@0: CPdrDevice* iPdrDevice; sl@0: CFont* iRealFont; sl@0: }; sl@0: sl@0: sl@0: class CPageBuffer : public CActive sl@0: { sl@0: public: sl@0: IMPORT_C static CPageBuffer* NewL(CPrinterPort* aPrinterPort); sl@0: IMPORT_C static CPageBuffer* NewL(CPrinterPort* aPrinterPort, TInt aGranularity); sl@0: IMPORT_C void StartFlush(TRequestStatus& aRequestStatus); sl@0: IMPORT_C void AddBytesL(const TDesC8& aDes); sl@0: IMPORT_C RWriteStream& CreateWriteStreamL(); sl@0: IMPORT_C void CloseWriteStream(); sl@0: IMPORT_C ~CPageBuffer(); sl@0: void DoCancel(); sl@0: void RunL(); sl@0: private: sl@0: void ConstructL(); sl@0: CPageBuffer(CPrinterPort* aPrinterPort, TInt aGranularity); sl@0: void Queue(); sl@0: private: sl@0: sl@0: TRequestStatus* iRequestStatus; sl@0: sl@0: TInt iWritePos; sl@0: sl@0: TInt iGranularity; sl@0: sl@0: CBufSeg* iBuffer; sl@0: sl@0: TPtr8 iPtr; sl@0: sl@0: CPrinterPort* iPrinterPort; sl@0: sl@0: RBufWriteStream iWriteStream; sl@0: sl@0: CBufSeg* iWriteStreamBuffer; sl@0: }; sl@0: sl@0: sl@0: /** WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases. sl@0: */ sl@0: class TTextFormat sl@0: { sl@0: public: sl@0: IMPORT_C TTextFormat(); sl@0: IMPORT_C TTextFormat(const TFontUnderline anUnderlineStyle, const TFontStrikethrough aStrikethroughStyle, const TRgb& aColor, const TDesC8& aFontString, const TFontStyle& aFontStyle); sl@0: IMPORT_C TBool operator == (const TTextFormat& aFormat) const; sl@0: public: sl@0: sl@0: TFontUnderline iUnderlineStyle; sl@0: sl@0: TFontStrikethrough iStrikethroughStyle; sl@0: sl@0: TRgb iColor; sl@0: sl@0: TCommandString iFontString; sl@0: sl@0: TFontStyle iFontStyle; sl@0: }; sl@0: sl@0: sl@0: // Forward declarations sl@0: class CPdrModelInfo; sl@0: class CPdrTypefaceStore; sl@0: sl@0: /** sl@0: @see CFbsDrvDevice sl@0: */ sl@0: class CPdrDevice : public CPrinterDevice sl@0: { sl@0: protected: sl@0: IMPORT_C CPdrDevice(); sl@0: public: sl@0: IMPORT_C virtual ~CPdrDevice(); sl@0: IMPORT_C void SelectPageSpecInTwips(const TPageSpec& aPageSpec); sl@0: IMPORT_C TDisplayMode DisplayMode() const; sl@0: IMPORT_C TSize SizeInPixels() const; sl@0: IMPORT_C TSize SizeInTwips() const; sl@0: IMPORT_C TRect PrintablePageInPixels() const; sl@0: IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwips) const; sl@0: IMPORT_C TInt VerticalTwipsToPixels(TInt aTwips) const; sl@0: IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixels) const; sl@0: IMPORT_C TInt VerticalPixelsToTwips(TInt aPixels) const; sl@0: IMPORT_C TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec); sl@0: IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont *&aFont, const TFontSpec &aFontSpec); sl@0: IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont *&aFont, const TFontSpec &aFontSpec, TInt aMaxHeight); sl@0: IMPORT_C TInt NumTypefaces() const; sl@0: IMPORT_C void TypefaceSupport(TTypefaceSupport& aTypefaceSupport, TInt aTypefaceIndex) const; sl@0: IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const; sl@0: IMPORT_C void PaletteAttributes(TBool& aModifiable, TInt& aNumEntries) const; sl@0: IMPORT_C void SetPalette(CPalette* aPalette); sl@0: IMPORT_C TInt GetPalette(CPalette*& aPalette) const; sl@0: IMPORT_C TPrinterModelEntry Model() const; sl@0: IMPORT_C TInt Flags() const; sl@0: IMPORT_C TInt SetModel(const TPrinterModelHeader& aModel, CStreamStore& aStore); sl@0: IMPORT_C void ReleaseFont(CFont* aFont); sl@0: IMPORT_C TPoint OffsetInPixels(); sl@0: sl@0: protected: sl@0: IMPORT_C virtual TSize KPixelSizeInTwips() const; sl@0: private: sl@0: void DoSetModelL(); sl@0: protected: sl@0: sl@0: CStreamStore* iStore; sl@0: sl@0: TPrinterModelHeader iModel; sl@0: sl@0: CPdrModelInfo* iModelInfo; sl@0: sl@0: CPdrTypefaceStore* iTypefaceStore; sl@0: }; sl@0: sl@0: sl@0: //Forward declarations sl@0: class CPdrResources; sl@0: class CPageText; sl@0: sl@0: class CPdrControl : public CPrinterControl sl@0: { sl@0: public: sl@0: IMPORT_C ~CPdrControl(); sl@0: IMPORT_C TInt CreateContext(CGraphicsContext*& aGC); sl@0: IMPORT_C TInt BandsPerPage(); sl@0: IMPORT_C TMoreOnPage QueueGetBand(TRequestStatus& aStatus, TBandAttributes& aBand); // returns affirmative if more to print on current page sl@0: IMPORT_C void QueueEndPrint(TRequestStatus& aStatus); // Called at finish to flush buffer, tidy up printer etc. sl@0: IMPORT_C void AbortPrint(); // tidy up synchronously in a short time sl@0: IMPORT_C virtual void DrawTextL(const TPoint& aPoint, const TFontUnderline aUnderlineStyle, const TFontStrikethrough aStrikethroughStyle, const TRgb& aColor, const CInfoFont* aFont, const TDesC& aString); sl@0: IMPORT_C TBool IsGraphicsBand() const; sl@0: inline CBandedDevice* BandedDevice() const {return iBandedDevice;} sl@0: protected: sl@0: IMPORT_C CPdrControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort); sl@0: IMPORT_C virtual void DoQueueGetBandL(); sl@0: IMPORT_C virtual void DoQueueEndPrintL(); sl@0: IMPORT_C void ConstructL(CStreamStore& aStore, TStreamId aStreamId); sl@0: sl@0: virtual void OutputBandL() = 0; sl@0: sl@0: IMPORT_C virtual void MoveToL(const TPoint& aPoint); sl@0: IMPORT_C virtual void MoveByL(const TPoint& aVector); sl@0: IMPORT_C virtual void OutputTextL(const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& aTextFormat, const TDesC8& aString); sl@0: sl@0: IMPORT_C virtual void SetPageSizeL(); sl@0: IMPORT_C virtual void SetPageOrientationL(); sl@0: IMPORT_C virtual void SetFontPostureL(const TFontPosture aPosture); sl@0: IMPORT_C virtual void SetFontStrokeWeightL(const TFontStrokeWeight aStrokeWeight); sl@0: IMPORT_C virtual void SetTextColorL(const TRgb& aColor); sl@0: IMPORT_C virtual void CommandL(const TInt anId); sl@0: sl@0: IMPORT_C TBool TransformBuffer(); // These two functions are not implemented anywhere sl@0: IMPORT_C TBool CompressBuffer(); // for this class. Nor do I believe they are defined sl@0: // for a reason. But since they are part of the sl@0: // existing interface of a DLL in a ROM I need to sl@0: // patch. They get to stay there for the moment. CJC sl@0: sl@0: protected: sl@0: sl@0: CPdrDevice* iPdrDevice; sl@0: sl@0: CPageBuffer* iPageBuffer; sl@0: sl@0: CPdrResources* iResources; sl@0: sl@0: CBandedDevice* iBandedDevice; sl@0: sl@0: CPageText* iPageText; sl@0: sl@0: TInt iBandIndex; sl@0: sl@0: TInt iEntryIndex; sl@0: sl@0: TPoint iPosition; sl@0: sl@0: TTextFormat iTextFormat; sl@0: }; sl@0: sl@0: sl@0: class CFbsDrvDevice : public CPdrDevice sl@0: { sl@0: public: sl@0: IMPORT_C CFbsDrvDevice(); sl@0: IMPORT_C ~CFbsDrvDevice(); sl@0: sl@0: IMPORT_C TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec); sl@0: IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont *&aFont, const TFontSpec &aFontSpec); sl@0: IMPORT_C void ReleaseFont(CFont* aFont); sl@0: IMPORT_C TInt NumTypefaces() const; sl@0: IMPORT_C void TypefaceSupport(TTypefaceSupport& aTypefaceSupport, TInt aTypefaceIndex) const; sl@0: IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const; sl@0: sl@0: IMPORT_C TInt CreateContext(CGraphicsContext*& aGc); sl@0: IMPORT_C void CreateControlL(CPrinterPort* aPrinterPort); sl@0: IMPORT_C TInt SetModel(const TPrinterModelHeader& aModel, CStreamStore& aStore); sl@0: IMPORT_C void LoadTypeFaceList(); sl@0: IMPORT_C TSize KPixelSizeInTwips() const; sl@0: IMPORT_C void LoadTypeFaceListL(); sl@0: IMPORT_C TInt SetModelL(const TPrinterModelHeader& aModel, CStreamStore& aStore); sl@0: private: sl@0: // reserved virtual function space sl@0: IMPORT_C virtual void Reserved_1(); sl@0: sl@0: protected: sl@0: sl@0: CFbsTypefaceStore* iFbsTypefaceStore; sl@0: sl@0: CArrayFixFlat* iGenTypefaceFontsList; sl@0: sl@0: CArrayFixFlat* iGenTypefaceFontsType; sl@0: sl@0: TInt iFbsTypefaceCount; sl@0: sl@0: TInt iPdrTypefaceCount; sl@0: sl@0: private: sl@0: sl@0: TAny* iReserved; sl@0: }; sl@0: sl@0: sl@0: class CFbsDrvControl : public CPdrControl sl@0: { sl@0: public: sl@0: IMPORT_C static CFbsDrvControl* NewL(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId); sl@0: IMPORT_C ~CFbsDrvControl(); sl@0: sl@0: protected: sl@0: IMPORT_C virtual void OutputBandL(); sl@0: sl@0: IMPORT_C CFbsDrvControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort); sl@0: IMPORT_C void ConstructL(CStreamStore& aStore, TStreamId aResourcesStreamId); sl@0: IMPORT_C void SetPageSizeL(); sl@0: sl@0: IMPORT_C TBool TransformBuffer(); sl@0: IMPORT_C TBool CompressBuffer(); sl@0: sl@0: private: sl@0: // reserved virtual function space sl@0: IMPORT_C virtual void Reserved_1(); sl@0: sl@0: protected: sl@0: sl@0: HBufC8* iScanLine; sl@0: sl@0: HBufC8* iCompressedScanLine; sl@0: sl@0: private: sl@0: sl@0: TAny* iReserved; sl@0: }; sl@0: sl@0: #endif