sl@0: // Copyright (c) 1997-2010 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: // Font and text classes used by printer drivers. sl@0: sl@0: #ifndef PDRSTOREFONT_H sl@0: #define PDRSTOREFONT_H sl@0: sl@0: /** sl@0: @file sl@0: @internalAll - Internal to Symbian sl@0: @released sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: sl@0: class CFbsBitGc; sl@0: class TPdrResource; sl@0: class CPdrDevice; sl@0: class CFontInfo; sl@0: class CPdrTranslates; sl@0: class CInfoFont; sl@0: class CTypefaceFonts; sl@0: class TTextFormat; sl@0: class CPdrControl; sl@0: class CFbsFont; sl@0: sl@0: sl@0: class CPdrResources : public CBase sl@0: { sl@0: public: sl@0: IMPORT_C CPdrResources(); sl@0: IMPORT_C void RestoreL(CStreamStore& aStore, TStreamId aStreamId); sl@0: IMPORT_C ~CPdrResources(); sl@0: IMPORT_C TPtrC8 ResourceString(TInt anId) const; sl@0: private: sl@0: TInt iNumResources; sl@0: sl@0: TPdrResource* iResourceList; sl@0: }; sl@0: sl@0: sl@0: class TTypefaceFontsEntry sl@0: { sl@0: public: sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: public: sl@0: sl@0: TStreamId iStreamId; sl@0: sl@0: TBool iNotInPortrait; sl@0: sl@0: TBool iNotInLandscape; sl@0: }; sl@0: sl@0: sl@0: class CPdrModelInfo : public CBase sl@0: { sl@0: public: sl@0: IMPORT_C CPdrModelInfo(); sl@0: IMPORT_C ~CPdrModelInfo(); sl@0: IMPORT_C void InternalizeL(RReadStream& aStream); sl@0: public: sl@0: sl@0: TInt iFlags; sl@0: sl@0: TInt iKPixelWidthInTwips; sl@0: sl@0: TInt iKPixelHeightInTwips; sl@0: sl@0: TPoint iPortraitOffsetInPixels; sl@0: sl@0: TPoint iLandscapeOffsetInPixels; sl@0: sl@0: TMargins iMinMarginsInPixels; sl@0: sl@0: TDisplayMode iDisplayMode; sl@0: sl@0: TInt iNumTypefaceFonts; sl@0: sl@0: TTypefaceFontsEntry* iTypefaceFontsEntryList; sl@0: sl@0: TStreamId iResourcesStreamId; sl@0: sl@0: TStreamId iSpareStreamId; sl@0: }; sl@0: sl@0: sl@0: /** sl@0: @internalTechnology sl@0: */ sl@0: class CPdrTypefaceStore : public CTypefaceStore sl@0: { sl@0: public: sl@0: IMPORT_C static CPdrTypefaceStore* NewL(CStreamStore& aStore, TInt aNumTypefacesFonts, TTypefaceFontsEntry* aTypefaceFontsEntryList, TPageSpec::TPageOrientation aPageOrientation, TInt aKPixelHeightInTwips, CPdrDevice* aPdrDevice); sl@0: IMPORT_C ~CPdrTypefaceStore(); sl@0: // CTypefaceStore implementation 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 TInt FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const; sl@0: IMPORT_C void TypefaceSupport(TTypefaceSupport &aTypefaceSupport, TInt aTypefaceIndex) const; sl@0: IMPORT_C void SetPageOrientation(TPageSpec::TPageOrientation aPageOrientation); sl@0: private: sl@0: CPdrTypefaceStore(CStreamStore& aStore, TInt aKPixelHeightInTwips, CPdrDevice* aPdrDevice); sl@0: void ConstructL(TInt aNumTypefacesFonts, TTypefaceFontsEntry* aTypefaceFontsEntryList, TPageSpec::TPageOrientation aPageOrientation); sl@0: CFontInfo* FontInfoL(TStreamId aStreamId) const; sl@0: CPdrTranslates* TranslatesL(TStreamId aStreamId) const; sl@0: TInt GetNearestFontHeightIndex(TInt aTypefaceIndex, TInt aHeightInTwips) const; sl@0: TFontStyle GetNearestFontStyle(TInt aTypefaceIndex, TInt aHeightIndex, const TFontStyle& aFontStyle) const; sl@0: TBool IsFontLoaded(CFont*& aFont, const TFontSpec& aFontSpecInTwips, TInt aHeightInPixels) const; sl@0: CInfoFont* NewFontL(TInt aBaselineOffsetInPixels, const TFontSpec& aFontSpecInTwips, TInt aFontInfoHeightInTwips, TInt aHeightInPixels, CPdrTranslates* aTranslates, const TDesC8& aCommandString, TStreamId aFontInfoStreamId); sl@0: TInt VerticalTwipsToPixels(TInt aTwipsHeight) const; sl@0: public: sl@0: CPdrDevice* iPdrDevice; sl@0: private: sl@0: CStreamStore* iStore; sl@0: TInt iKPixelHeightInTwips; sl@0: CArrayPtr* iTypefaceFontsList; sl@0: CArrayPtr* iPortraitTypefaceFontsList; sl@0: CArrayPtr* iLandscapeTypefaceFontsList; sl@0: CArrayPtr* iCurrentTypefaceFontsList; sl@0: CArrayPtr* iTranslatesList; sl@0: CArrayPtr* iFontInfoList; sl@0: }; sl@0: sl@0: class CPageTextEntry : public CBase sl@0: { sl@0: public: sl@0: IMPORT_C CPageTextEntry(const TPoint& aDrawPos, TInt aHeightInPixels, TInt aTextWidthInPixels, HBufC8* aText, TTextFormat* aTextFormat); sl@0: IMPORT_C ~CPageTextEntry(); sl@0: IMPORT_C TPoint TopTextPos(); sl@0: public: sl@0: sl@0: TPoint iDrawPos; sl@0: sl@0: TInt iHeightInPixels; sl@0: sl@0: TInt iTextWidthInPixels; sl@0: sl@0: HBufC8* iText; sl@0: sl@0: TTextFormat* iTextFormat; sl@0: }; sl@0: sl@0: sl@0: class CPageText : public CBase sl@0: { sl@0: private: sl@0: CPageText(); sl@0: void ConstructL(); sl@0: public: sl@0: IMPORT_C static CPageText* NewL(); sl@0: IMPORT_C ~CPageText(); sl@0: IMPORT_C void Reset(); sl@0: IMPORT_C void AddEntryL(const TPoint& aPoint, const TFontUnderline aUnderlineStyle, const TFontStrikethrough aStrikethroughStyle, const TRgb& aColor, const CInfoFont* aFont, const TDesC& aString); sl@0: IMPORT_C TInt NumEntries(); sl@0: IMPORT_C CPageTextEntry* operator [] (TInt anIndex); sl@0: /** This function is internal only, and is not intended for use. */ sl@0: inline TInt MaxFontHeightInPixels() const {return iMaxFontHeightInPixels;} sl@0: private: sl@0: sl@0: TInt iMaxFontHeightInPixels; sl@0: sl@0: CArrayPtr* iTextFormatList; sl@0: sl@0: CArrayPtr* iPageTextEntryList; sl@0: }; sl@0: sl@0: sl@0: class CPdrGc : public CGraphicsContext sl@0: { sl@0: private: sl@0: CPdrGc(CPdrDevice* aDevice); sl@0: void ConstructL(); sl@0: public: sl@0: static CPdrGc* NewL(CPdrDevice* aDevice); sl@0: IMPORT_C ~CPdrGc(); sl@0: sl@0: IMPORT_C CGraphicsDevice* Device() const; sl@0: IMPORT_C void SetOrigin(const TPoint& aPos = TPoint(0, 0)); sl@0: IMPORT_C void SetDrawMode(TDrawMode aDrawingMode); sl@0: IMPORT_C void SetClippingRect(const TRect& aRect); sl@0: IMPORT_C void CancelClippingRect(); sl@0: IMPORT_C void Reset(); sl@0: sl@0: IMPORT_C void UseFont(const CFont* aFont); sl@0: IMPORT_C void DiscardFont(); sl@0: sl@0: IMPORT_C void SetUnderlineStyle(TFontUnderline aUnderlineStyle); sl@0: IMPORT_C void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle); sl@0: IMPORT_C void SetWordJustification(TInt aExcessWidth, TInt aNumGaps); sl@0: IMPORT_C void SetCharJustification(TInt aExcessWidth, TInt aNumChars); sl@0: sl@0: IMPORT_C void SetPenColor(const TRgb& aColor); sl@0: IMPORT_C void SetPenStyle(TPenStyle aPenStyle); sl@0: IMPORT_C void SetPenSize(const TSize& aSize = TSize(1, 1)); sl@0: sl@0: IMPORT_C void SetBrushColor(const TRgb& aColor); sl@0: IMPORT_C void SetBrushStyle(TBrushStyle aBrushStyle); sl@0: IMPORT_C void SetBrushOrigin(const TPoint& aOrigin); sl@0: IMPORT_C void UseBrushPattern(const CFbsBitmap* aBitmap); sl@0: IMPORT_C void DiscardBrushPattern(); sl@0: sl@0: IMPORT_C void MoveTo(const TPoint& aPoint); sl@0: IMPORT_C void MoveBy(const TPoint& aVector); sl@0: IMPORT_C void Plot(const TPoint& aPoint); sl@0: sl@0: IMPORT_C void DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd); sl@0: IMPORT_C void DrawLine(const TPoint& aPoint1, const TPoint& aPoint2); sl@0: IMPORT_C void DrawLineTo(const TPoint& aPoint); sl@0: IMPORT_C void DrawLineBy(const TPoint& aVector); sl@0: IMPORT_C void DrawPolyLine(const CArrayFix* aPointList); sl@0: IMPORT_C void DrawPolyLine(const TPoint* aPointList, TInt aNumPoints); sl@0: sl@0: IMPORT_C void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd); sl@0: IMPORT_C void DrawEllipse(const TRect& aRect); sl@0: IMPORT_C void DrawRect(const TRect& aRect); sl@0: IMPORT_C void DrawRoundRect(const TRect& aRect, const TSize& aCornerSize); sl@0: IMPORT_C TInt DrawPolygon(const CArrayFix* aPointList, TFillRule aFillRule = EAlternate); sl@0: IMPORT_C TInt DrawPolygon(const TPoint* aPointList, TInt aNumPoints, TFillRule aFillRule = EAlternate); sl@0: sl@0: IMPORT_C void DrawBitmap(const TPoint& aTopLeft, const CFbsBitmap* aSource); sl@0: IMPORT_C void DrawBitmap(const TRect& aDestRect, const CFbsBitmap* aSource); sl@0: IMPORT_C void DrawBitmap(const TRect& aDestRect, const CFbsBitmap* aSource, const TRect& aSourceRect); sl@0: IMPORT_C void DrawBitmapMasked(const TRect& aDestRect,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask); sl@0: IMPORT_C void DrawBitmapMasked(const TRect& aDestRect,const CWsBitmap* aBitmap,const TRect& aSourceRect,const CWsBitmap* aMaskBitmap,TBool aInvertMask); sl@0: sl@0: IMPORT_C void DrawText(const TDesC& aString, const TPoint& aPosition); sl@0: IMPORT_C void DrawTextL(const TDesC& aString, const TPoint& aPosition); sl@0: IMPORT_C void DrawText(const TDesC& aString, const TRect& aBox, TInt aBaselineOffset, TTextAlign aHoriz = ELeft, TInt aLeftMrg = 0); sl@0: sl@0: IMPORT_C void MapColors(const TRect& aRect,const TRgb* aColors,TInt aNumPairs,TBool aMapForwards); sl@0: IMPORT_C TInt SetClippingRegion(const TRegion &aRegion); sl@0: IMPORT_C void CancelClippingRegion(); sl@0: IMPORT_C void DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp); sl@0: IMPORT_C void DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0); sl@0: IMPORT_C TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt); sl@0: IMPORT_C TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp, const TRect& aSrcRect, const CWsBitmap* aAlphaBmp, const TPoint& aAlphaPt); sl@0: sl@0: private: sl@0: CPdrControl* PdrControl() const; sl@0: sl@0: private: sl@0: sl@0: CPdrDevice* iPdrDevice; sl@0: sl@0: CFbsBitGc* iBandedGc; sl@0: sl@0: CFbsFont* iFbsFont; sl@0: sl@0: CFont* iBandedFont; sl@0: sl@0: CInfoFont* iFont; sl@0: sl@0: TPoint iOrigin; sl@0: sl@0: TPoint iPosition; sl@0: sl@0: TFontUnderline iUnderlineStyle; sl@0: sl@0: TFontStrikethrough iStrikethroughStyle; sl@0: sl@0: TRect iClippingRect; // Relative to absolute origin sl@0: sl@0: TInt iWordExcessWidthInPixels; sl@0: sl@0: TInt iNumGaps; sl@0: sl@0: TInt iCharExcessWidthInPixels; sl@0: sl@0: TInt iNumChars; sl@0: sl@0: TRgb iPenColor; sl@0: sl@0: TBool iPrintTextUsingBitmaps; sl@0: }; sl@0: sl@0: sl@0: sl@0: #endif // PDRSTOREFONT_H