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