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