|
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 __BITDEV_H__ |
|
17 #define __BITDEV_H__ |
|
18 |
|
19 #include <fbs.h> |
|
20 #include <bitbase.h> |
|
21 #include <bitstd.h> |
|
22 #include <graphicsaccelerator.h> |
|
23 |
|
24 class CFbsDrawDevice; |
|
25 class TSurfaceId; |
|
26 |
|
27 /** Screen device orientations. |
|
28 |
|
29 WARNING: Enumeration for internal use ONLY. Compatibility is not guaranteed in future releases. |
|
30 |
|
31 @publishedAll |
|
32 @released |
|
33 */ |
|
34 enum TDeviceOrientation |
|
35 { |
|
36 EDeviceOrientationNormal = 1, |
|
37 EDeviceOrientation90CW = 2, |
|
38 EDeviceOrientation180 = 4, |
|
39 EDeviceOrientation270CW = 8 |
|
40 }; |
|
41 |
|
42 /** Abstract base class for graphics devices to which bitmaps and fonts can be |
|
43 drawn. |
|
44 |
|
45 The class implements the pure virtual CBitmapDevice functions and additionally |
|
46 provides: |
|
47 |
|
48 support for creating and enquiring about fonts |
|
49 |
|
50 comparing two device rectangles |
|
51 |
|
52 creating a graphics context for the device. |
|
53 |
|
54 CFbsBitmapDevice and CFbsScreenDevice are derived fom this class. |
|
55 |
|
56 @see CFbsBitmapDevice |
|
57 @see CFbsScreenDevice |
|
58 @publishedAll |
|
59 @released |
|
60 */ |
|
61 class CFbsDevice : public CBitmapDevice |
|
62 { |
|
63 friend class CFbsBitGc; |
|
64 public: |
|
65 IMPORT_C ~CFbsDevice(); |
|
66 IMPORT_C TInt CreateContext(CFbsBitGc*& aGc); |
|
67 inline TInt CreateContext(CGraphicsContext*& aGc); |
|
68 IMPORT_C TDisplayMode DisplayMode() const; |
|
69 IMPORT_C TSize SizeInPixels() const; |
|
70 IMPORT_C TBool RectCompare(const TRect& aSourceRect,const CFbsDevice& aDevice,const TRect& aDeviceRect) const; |
|
71 IMPORT_C TInt AddFile(const TDesC& aName,TInt& aId); |
|
72 IMPORT_C void RemoveFile(TInt aId=0); |
|
73 IMPORT_C virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec); |
|
74 IMPORT_C virtual TInt GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec); |
|
75 IMPORT_C virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec); |
|
76 IMPORT_C virtual TInt GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec); |
|
77 IMPORT_C virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); |
|
78 IMPORT_C virtual TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); |
|
79 IMPORT_C TInt GetFontById(CFont*& aFont,TUid aFileId,const TAlgStyle& aStyle); |
|
80 inline TInt GetNearestFontInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec); |
|
81 inline TInt GetNearestFontInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec); |
|
82 inline TInt GetNearestFontToDesignHeightInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec); |
|
83 inline TInt GetNearestFontToDesignHeightInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec); |
|
84 inline TInt GetNearestFontToMaxHeightInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); |
|
85 inline TInt GetNearestFontToMaxHeightInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); |
|
86 inline TInt GetFontById(CFbsFont*& aFont,TUid aFileId,const TAlgStyle& aStyle); |
|
87 IMPORT_C void ReleaseFont(CFont* aFont); |
|
88 IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const; |
|
89 IMPORT_C TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const; |
|
90 IMPORT_C TInt NumTypefaces() const; |
|
91 IMPORT_C void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const; |
|
92 IMPORT_C TInt SetCustomPalette(const CPalette* aPalette); |
|
93 inline CGraphicsAccelerator* GraphicsAccelerator() const; |
|
94 inline CFbsBitGc::TGraphicsOrientation Orientation() const; |
|
95 IMPORT_C static TDisplayMode DisplayMode16M(); |
|
96 IMPORT_C TInt SetScalingFactor(const TPoint& aOrigin, |
|
97 TInt aFactorX, TInt aFactorY, |
|
98 TInt aDivisorX, TInt aDivisorY); |
|
99 IMPORT_C void GetDrawRect(TRect& aRect) const; |
|
100 IMPORT_C TInt RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec, TInt& aId); |
|
101 IMPORT_C TInt SetDrawDeviceOffset(const TPoint& aOrigin); |
|
102 |
|
103 protected: |
|
104 CFbsDevice(); |
|
105 virtual void DrawingBegin(TBool /*aAlways*/ = EFalse) {} |
|
106 virtual void DrawingEnd(TBool /*aAlways*/ = EFalse) {} |
|
107 |
|
108 /** |
|
109 Sets the bit level. |
|
110 */ |
|
111 virtual void SetBits() {} |
|
112 |
|
113 /** |
|
114 This method has been deprecated. Sprites are no longer supported in BitGDI. |
|
115 Calling this method has no effect. |
|
116 @deprecated |
|
117 */ |
|
118 virtual void CancelSprite() const {} |
|
119 |
|
120 /** |
|
121 This method has been deprecated. Sprites are no longer supported in BitGDI. |
|
122 Calling this method has no effect. |
|
123 @return TSpriteBase* NULL. |
|
124 @deprecated |
|
125 */ |
|
126 virtual TSpriteBase* HideSprite() const {return(NULL);} |
|
127 |
|
128 /** |
|
129 This method has been deprecated. Sprites are no longer supported in BitGDI. |
|
130 Calling this method has no effect. |
|
131 @param aRect Ignored. |
|
132 @param aClippingRegion Ignored. |
|
133 @return TSpriteBase* NULL. |
|
134 @deprecated |
|
135 */ |
|
136 virtual TSpriteBase* HideSprite(const TRect&,const TRegion*) const {return(NULL);} |
|
137 |
|
138 /** |
|
139 This method has been deprecated. Sprites are no longer supported in BitGDI. |
|
140 Calling this method has no effect. |
|
141 @param aSprite Ignored. |
|
142 @deprecated |
|
143 */ |
|
144 virtual void ShowSprite(TSpriteBase*) const {} |
|
145 |
|
146 /** |
|
147 This method has been deprecated. Sprites are no longer supported in BitGDI. |
|
148 Calling this method has no effect. |
|
149 @param aSprite Ignored. |
|
150 @param aRect Ignored. |
|
151 @param aClippingRegion Ignored. |
|
152 @deprecated |
|
153 */ |
|
154 virtual void ShowSprite(TSpriteBase*,const TRect&,const TRegion*) const {} |
|
155 TInt GetNearestFbsFont(CFbsFont*& aFont,const TFontSpec& aFontSpec); |
|
156 void DoGetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,TDisplayMode aDispMode); |
|
157 void ReadLineDiffMode(TInt,TInt,TInt,TAny*,TDisplayMode) const; |
|
158 void TruncateRect(TRect& aRect); |
|
159 TBool SetOrientation(CFbsBitGc::TGraphicsOrientation aOrientation); |
|
160 void DrawingBegin(const CFbsBitmap* aBitmap, TBool aAlways = EFalse); |
|
161 void DrawingEnd(const CFbsBitmap* aBitmap, TBool aAlways = EFalse); |
|
162 protected: |
|
163 CFbsDrawDevice* iDrawDevice; |
|
164 RFbsSession* iFbs; |
|
165 CFbsTypefaceStore* iTypefaceStore; |
|
166 TInt iSpare; |
|
167 TBool iScreenDevice; |
|
168 TUint8* iBitBltMaskedBuffer; |
|
169 CGraphicsAccelerator* iGraphicsAccelerator; |
|
170 CFbsBitGc::TGraphicsOrientation iOrientation; |
|
171 }; |
|
172 |
|
173 /** A graphics device interface that provides direct access to the screen, without |
|
174 the mediation of the window server. |
|
175 |
|
176 @publishedAll |
|
177 @released |
|
178 */ |
|
179 class CFbsScreenDevice : public CFbsDevice |
|
180 { |
|
181 public: |
|
182 IMPORT_C static CFbsScreenDevice* NewL(const TDesC& aLibname,TDisplayMode aDispMode); |
|
183 IMPORT_C static CFbsScreenDevice* NewL(const TDesC& aLibname,TDisplayMode aDispMode, TRgb aWhite); |
|
184 IMPORT_C static CFbsScreenDevice* NewL(TInt aScreenNo, TDisplayMode aDispMode); |
|
185 IMPORT_C virtual ~CFbsScreenDevice(); |
|
186 IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode aDispMode) const; |
|
187 IMPORT_C void GetPixel(TRgb& aColor,const TPoint& aPixel) const; |
|
188 IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixels) const; |
|
189 IMPORT_C TInt VerticalPixelsToTwips(TInt aPixels) const; |
|
190 IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwips) const; |
|
191 IMPORT_C TInt VerticalTwipsToPixels(TInt aTwips) const; |
|
192 IMPORT_C void SetAutoUpdate(TBool aValue); |
|
193 IMPORT_C void DrawSpriteBegin(); //< @deprecated |
|
194 IMPORT_C void DrawSpriteEnd(); //< @deprecated |
|
195 IMPORT_C void CancelSprite() const; //< @deprecated |
|
196 IMPORT_C TSpriteBase* HideSprite() const; //< @deprecated |
|
197 IMPORT_C TSpriteBase* HideSprite(const TRect& aRect,const TRegion* aClippingRegion) const; //< @deprecated |
|
198 IMPORT_C void ShowSprite(TSpriteBase* aSprite) const; //< @deprecated |
|
199 IMPORT_C void ShowSprite(TSpriteBase* aSprite,const TRect& aRect,const TRegion* aClippingRegion) const; //< @deprecated |
|
200 IMPORT_C void ChangeScreenDevice(CFbsScreenDevice* aOldDevice); |
|
201 IMPORT_C void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const; |
|
202 IMPORT_C void SetPalette(CPalette* aPalette); |
|
203 IMPORT_C TInt GetPalette(CPalette*& aPalette) const; |
|
204 IMPORT_C void Update(); |
|
205 IMPORT_C void Update(const TRegion& aRegion); |
|
206 IMPORT_C TSize SizeInTwips() const; |
|
207 IMPORT_C RHardwareBitmap HardwareBitmap(); |
|
208 IMPORT_C const TUint32* Bits() const; |
|
209 IMPORT_C TInt Stride() const; |
|
210 IMPORT_C TInt ScreenNo() const; |
|
211 IMPORT_C TUint DeviceOrientationsAvailable() const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. */ |
|
212 IMPORT_C TBool SetDeviceOrientation(TDeviceOrientation aOrientation) const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. */ |
|
213 IMPORT_C void GetSurface(TSurfaceId& aSurface) const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. */ |
|
214 IMPORT_C TDeviceOrientation DeviceOrientation() const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. */ |
|
215 private: |
|
216 CFbsScreenDevice(TInt aScreenNo); |
|
217 void ConstructL(TInt aScreenNo, TDisplayMode aDispMode); |
|
218 private: |
|
219 TInt iSpare1_CFbsScreenDevice; |
|
220 TInt iSpare2_CFbsScreenDevice; |
|
221 TInt iScreenNo; |
|
222 }; |
|
223 |
|
224 /** A graphics device to which a bitmap managed by the font and bitmap server can |
|
225 be drawn. |
|
226 |
|
227 The class specialises the bitmap graphics device interface CBitmapDevice for |
|
228 drawing to in-memory bitmaps. |
|
229 @publishedAll |
|
230 @released |
|
231 */ |
|
232 class CFbsBitmapDevice : public CFbsDevice |
|
233 { |
|
234 public: |
|
235 IMPORT_C static CFbsBitmapDevice* NewL(CFbsBitmap* aFbsBitmap); |
|
236 IMPORT_C static CFbsBitmapDevice* NewL(CFbsBitmap* aFbsBitmap,const TDesC& aLibname); |
|
237 IMPORT_C virtual ~CFbsBitmapDevice(); |
|
238 IMPORT_C TInt Resize(const TSize& aSize); |
|
239 IMPORT_C virtual void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode iDispMode) const; |
|
240 IMPORT_C virtual void GetPixel(TRgb& aColor,const TPoint& aPixel) const; |
|
241 IMPORT_C virtual TInt HorizontalPixelsToTwips(TInt aPixels) const; |
|
242 IMPORT_C virtual TInt VerticalPixelsToTwips(TInt aPixels) const; |
|
243 IMPORT_C virtual TInt HorizontalTwipsToPixels(TInt aTwips) const; |
|
244 IMPORT_C virtual TInt VerticalTwipsToPixels(TInt aTwips) const; |
|
245 IMPORT_C virtual TSize SizeInTwips() const; |
|
246 IMPORT_C virtual void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const; |
|
247 IMPORT_C virtual void SetPalette(CPalette* aPalette); |
|
248 IMPORT_C virtual TInt GetPalette(CPalette*& aPalette) const; |
|
249 IMPORT_C virtual void DrawingBegin(TBool aAlways = EFalse); |
|
250 IMPORT_C virtual void DrawingEnd(TBool aAlways = EFalse); |
|
251 IMPORT_C TInt SwapWidthAndHeight(); |
|
252 |
|
253 private: |
|
254 CFbsBitmapDevice(); |
|
255 virtual void SetBits(); |
|
256 void ConstructL(CFbsBitmap* aFbsBitmap); |
|
257 void ConstructL(CFbsBitmap* aFbsBitmap,const TDesC& aLibname); |
|
258 private: |
|
259 CFbsBitGcBitmap* iFbsBmp; |
|
260 }; |
|
261 |
|
262 #include <bitdev.inl> |
|
263 #endif |