epoc32/include/bitdev.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.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 /**
    25 Used by RectCompare()
    26 @internalComponent
    27 */
    28 enum {EScanBufSize=0x80}; 
    29 
    30 class CFbsDrawDevice;
    31 class TSurfaceId;
    32 
    33 /**
    34 Screen device orientations.
    35 @internalTechnology
    36 @prototype
    37 */
    38 enum TDeviceOrientation
    39 	{
    40 	EDeviceOrientationNormal = 1,
    41 	EDeviceOrientation90CW = 2,
    42 	EDeviceOrientation180 = 4,
    43 	EDeviceOrientation270CW = 8
    44 	};
    45 
    46 /** Abstract base class for graphics devices to which bitmaps and fonts can be 
    47 drawn.
    48 
    49 The class implements the pure virtual CBitmapDevice functions and additionally 
    50 provides:
    51 
    52 support for creating and enquiring about fonts
    53 
    54 comparing two device rectangles
    55 
    56 creating a graphics context for the device.
    57 
    58 CFbsBitmapDevice and CFbsScreenDevice are derived fom this class.
    59 
    60 @see CFbsBitmapDevice
    61 @see CFbsScreenDevice 
    62 @publishedAll
    63 @released
    64 */
    65 class CFbsDevice : public CBitmapDevice
    66 	{
    67 	friend class CFbsBitGc;
    68 public:
    69 	IMPORT_C ~CFbsDevice();
    70 	IMPORT_C TInt CreateContext(CFbsBitGc*& aGc);
    71 	inline TInt CreateContext(CGraphicsContext*& aGc);
    72 	IMPORT_C TDisplayMode DisplayMode() const;
    73 	IMPORT_C TSize SizeInPixels() const;
    74 	IMPORT_C TBool RectCompare(const TRect& aSourceRect,const CFbsDevice& aDevice,const TRect& aDeviceRect) const;
    75 	IMPORT_C TInt AddFile(const TDesC& aName,TInt& aId);
    76 	IMPORT_C void RemoveFile(TInt aId=0);
    77 	IMPORT_C virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
    78 	IMPORT_C virtual TInt GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec);
    79 	IMPORT_C virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
    80 	IMPORT_C virtual TInt GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec);
    81 	IMPORT_C virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); 
    82 	IMPORT_C virtual TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
    83 	IMPORT_C TInt GetFontById(CFont*& aFont,TUid aFileId,const TAlgStyle& aStyle);
    84 	inline TInt GetNearestFontInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec);
    85 	inline TInt GetNearestFontInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec);
    86 	inline TInt GetNearestFontToDesignHeightInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec);
    87 	inline TInt GetNearestFontToDesignHeightInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec);
    88 	inline TInt GetNearestFontToMaxHeightInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
    89 	inline TInt GetNearestFontToMaxHeightInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
    90 	inline TInt GetFontById(CFbsFont*& aFont,TUid aFileId,const TAlgStyle& aStyle);
    91 	IMPORT_C void ReleaseFont(CFont* aFont);
    92 	IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const;
    93 	IMPORT_C TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const;
    94 	IMPORT_C TInt NumTypefaces() const;
    95 	IMPORT_C void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const;
    96 	IMPORT_C TInt SetCustomPalette(const CPalette* aPalette);
    97 	inline CGraphicsAccelerator* GraphicsAccelerator() const;
    98 	inline CFbsBitGc::TGraphicsOrientation Orientation() const;
    99 	IMPORT_C static TDisplayMode DisplayMode16M();
   100 	IMPORT_C TInt SetScalingFactor(const TPoint& aOrigin,
   101 								   TInt aFactorX, TInt aFactorY,
   102 								   TInt aDivisorX, TInt aDivisorY);
   103 	IMPORT_C void GetDrawRect(TRect& aRect) const;
   104 	IMPORT_C TInt RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec, TInt& aId);
   105 protected:
   106 	CFbsDevice();
   107 	virtual void DrawingBegin(TBool /*aAlways*/ = EFalse) {}
   108 	virtual void DrawingEnd(TBool /*aAlways*/ = EFalse) {}
   109 	
   110 	/**
   111 	Sets the bit level.
   112 	*/
   113 	virtual void SetBits() {}
   114 	
   115 	/**
   116 	Cancels drawing the sprite. 
   117 	*/
   118 	virtual void CancelSprite() const {}
   119 	
   120 	/**
   121 	Hides the sprite over the whole screen.
   122 	@return TSpriteBase* A pointer to the hidden sprite. NULL in default implementation.
   123 	*/
   124 	virtual TSpriteBase* HideSprite() const {return(NULL);}
   125 	
   126 	/**
   127 	Hides the sprite within a particular region.
   128 	@param aRect A rectangle within the clipping region.
   129 	@param aClippingRegion The clipping region. 
   130   	@return TSpriteBase* A pointer to the hidden sprite. NULL in default implementation.
   131 	*/
   132 	virtual TSpriteBase* HideSprite(const TRect&,const TRegion*) const {return(NULL);}
   133 	
   134 	/**
   135 	Shows the specified sprite over the whole screen.
   136 	@param aSprite The sprite which is to be shown. 
   137 	*/
   138 	virtual void ShowSprite(TSpriteBase*) const {}
   139 	
   140 	/**
   141 	Shows the specified sprite within a particular region.
   142 	@param aSprite The sprite which is to be shown. 
   143  	@param aRect A rectangle within the clipping region. 
   144  	@param aClippingRegion The clipping region 
   145  	*/
   146 	virtual void ShowSprite(TSpriteBase*,const TRect&,const TRegion*) const {}
   147 	TInt GetNearestFbsFont(CFbsFont*& aFont,const TFontSpec& aFontSpec);
   148 	void DoGetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,TDisplayMode aDispMode);
   149 	void ReadLineDiffMode(TInt,TInt,TInt,TAny*,TDisplayMode) const;
   150 	void TruncateRect(TRect& aRect);
   151 	TBool SetOrientation(CFbsBitGc::TGraphicsOrientation aOrientation);
   152 	void DrawingBegin(const CFbsBitmap* aBitmap, TBool aAlways = EFalse);
   153 	void DrawingEnd(const CFbsBitmap* aBitmap, TBool aAlways = EFalse);
   154 protected:
   155 	CFbsDrawDevice* iDrawDevice;
   156 	RFbsSession* iFbs;
   157 	CFbsTypefaceStore* iTypefaceStore;
   158 	TInt iSpare;
   159 	TBool iScreenDevice;
   160 	TUint8* iBitBltMaskedBuffer;
   161 	CGraphicsAccelerator* iGraphicsAccelerator;
   162 	CFbsBitGc::TGraphicsOrientation iOrientation;
   163 	};
   164 
   165 /** A graphics device interface that provides direct access to the screen, without 
   166 the mediation of the window server.
   167 
   168 The interface adds sprite support to the CFbsDevice base class. 
   169 @publishedAll
   170 @released
   171 */
   172 class CFbsScreenDevice : public CFbsDevice
   173 	{
   174 public:
   175 	IMPORT_C static CFbsScreenDevice* NewL(const TDesC& aLibname,TDisplayMode aDispMode);
   176 	IMPORT_C static CFbsScreenDevice* NewL(const TDesC& aLibname,TDisplayMode aDispMode, TRgb aWhite);
   177 	IMPORT_C static CFbsScreenDevice* NewL(TInt aScreenNo, TDisplayMode aDispMode);
   178 	IMPORT_C virtual ~CFbsScreenDevice();
   179 	IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode aDispMode) const;
   180 	IMPORT_C void GetPixel(TRgb& aColor,const TPoint& aPixel) const;
   181 	IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixels) const;
   182 	IMPORT_C TInt VerticalPixelsToTwips(TInt aPixels) const;
   183 	IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwips) const;
   184 	IMPORT_C TInt VerticalTwipsToPixels(TInt aTwips) const;
   185 	IMPORT_C void SetAutoUpdate(TBool aValue);
   186 	IMPORT_C void DrawSpriteBegin();
   187 	IMPORT_C void DrawSpriteEnd();
   188 	IMPORT_C void CancelSprite() const;
   189 	IMPORT_C TSpriteBase* HideSprite() const;
   190 	IMPORT_C TSpriteBase* HideSprite(const TRect& aRect,const TRegion* aClippingRegion) const;
   191 	IMPORT_C void ShowSprite(TSpriteBase* aSprite) const;
   192 	IMPORT_C void ShowSprite(TSpriteBase* aSprite,const TRect& aRect,const TRegion* aClippingRegion) const;
   193 	IMPORT_C void ChangeScreenDevice(CFbsScreenDevice* aOldDevice);
   194 	IMPORT_C void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const;
   195 	IMPORT_C void SetPalette(CPalette* aPalette);
   196 	IMPORT_C TInt GetPalette(CPalette*& aPalette) const;
   197 	IMPORT_C void Update();
   198 	IMPORT_C void Update(const TRegion& aRegion);
   199 	IMPORT_C TSize SizeInTwips() const;
   200 	IMPORT_C RHardwareBitmap HardwareBitmap();
   201 	IMPORT_C const TUint32* Bits() const;
   202 	IMPORT_C TInt Stride() const;
   203 	IMPORT_C TInt ScreenNo() const;
   204 	IMPORT_C TUint DeviceOrientationsAvailable() const;		//< @internalTechnology
   205 	IMPORT_C TBool SetDeviceOrientation(TDeviceOrientation aOrientation) const;	//< @internalTechnology
   206 	IMPORT_C void GetSurface(TSurfaceId& aSurface) const;		//< @internalTechnology
   207 	IMPORT_C TDeviceOrientation DeviceOrientation() const;		//< @internalTechnology
   208 private:
   209 	CFbsScreenDevice(TInt aScreenNo);
   210 	void ConstructL(TInt aScreenNo, TDisplayMode aDispMode);
   211 private:
   212 	TSpriteBase* iSprite;
   213 	TBool iSpriteDraw;
   214     TInt iScreenNo;
   215 	};
   216 
   217 /** A graphics device to which a bitmap managed by the font and bitmap server can 
   218 be drawn.
   219 
   220 The class specialises the bitmap graphics device interface CBitmapDevice for 
   221 drawing to in-memory bitmaps. 
   222 @publishedAll
   223 @released
   224 */
   225 class CFbsBitmapDevice : public CFbsDevice
   226 	{
   227 public:
   228 	IMPORT_C static CFbsBitmapDevice* NewL(CFbsBitmap* aFbsBitmap);
   229 	IMPORT_C static CFbsBitmapDevice* NewL(CFbsBitmap* aFbsBitmap,const TDesC& aLibname);
   230 	IMPORT_C virtual ~CFbsBitmapDevice();
   231 	IMPORT_C TInt Resize(const TSize& aSize);
   232 	IMPORT_C virtual void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode iDispMode) const;
   233 	IMPORT_C virtual void GetPixel(TRgb& aColor,const TPoint& aPixel) const;
   234 	IMPORT_C virtual TInt HorizontalPixelsToTwips(TInt aPixels) const;
   235 	IMPORT_C virtual TInt VerticalPixelsToTwips(TInt aPixels) const;
   236 	IMPORT_C virtual TInt HorizontalTwipsToPixels(TInt aTwips) const;
   237 	IMPORT_C virtual TInt VerticalTwipsToPixels(TInt aTwips) const;
   238 	IMPORT_C virtual TSize SizeInTwips() const;
   239 	IMPORT_C virtual void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const;
   240 	IMPORT_C virtual void SetPalette(CPalette* aPalette);
   241 	IMPORT_C virtual TInt GetPalette(CPalette*& aPalette) const;
   242 	IMPORT_C virtual void DrawingBegin(TBool aAlways = EFalse);
   243 	IMPORT_C virtual void DrawingEnd(TBool aAlways = EFalse);
   244 	IMPORT_C TInt SwapWidthAndHeight();
   245 private:
   246 	CFbsBitmapDevice();
   247 	virtual void SetBits();
   248 	void ConstructL(CFbsBitmap* aFbsBitmap);
   249 	void ConstructL(CFbsBitmap* aFbsBitmap,const TDesC& aLibname);
   250 private:
   251 	CFbsBitGcBitmap* iFbsBmp;
   252 	};
   253 
   254 #include <bitdev.inl>
   255 #endif