1.1 --- a/epoc32/include/bitdev.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/bitdev.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,255 @@
1.4 -bitdev.h
1.5 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// 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
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#ifndef __BITDEV_H__
1.21 +#define __BITDEV_H__
1.22 +
1.23 +#include <fbs.h>
1.24 +#include <bitbase.h>
1.25 +#include <bitstd.h>
1.26 +#include <graphicsaccelerator.h>
1.27 +
1.28 +/**
1.29 +Used by RectCompare()
1.30 +@internalComponent
1.31 +*/
1.32 +enum {EScanBufSize=0x80};
1.33 +
1.34 +class CFbsDrawDevice;
1.35 +class TSurfaceId;
1.36 +
1.37 +/**
1.38 +Screen device orientations.
1.39 +@internalTechnology
1.40 +@prototype
1.41 +*/
1.42 +enum TDeviceOrientation
1.43 + {
1.44 + EDeviceOrientationNormal = 1,
1.45 + EDeviceOrientation90CW = 2,
1.46 + EDeviceOrientation180 = 4,
1.47 + EDeviceOrientation270CW = 8
1.48 + };
1.49 +
1.50 +/** Abstract base class for graphics devices to which bitmaps and fonts can be
1.51 +drawn.
1.52 +
1.53 +The class implements the pure virtual CBitmapDevice functions and additionally
1.54 +provides:
1.55 +
1.56 +support for creating and enquiring about fonts
1.57 +
1.58 +comparing two device rectangles
1.59 +
1.60 +creating a graphics context for the device.
1.61 +
1.62 +CFbsBitmapDevice and CFbsScreenDevice are derived fom this class.
1.63 +
1.64 +@see CFbsBitmapDevice
1.65 +@see CFbsScreenDevice
1.66 +@publishedAll
1.67 +@released
1.68 +*/
1.69 +class CFbsDevice : public CBitmapDevice
1.70 + {
1.71 + friend class CFbsBitGc;
1.72 +public:
1.73 + IMPORT_C ~CFbsDevice();
1.74 + IMPORT_C TInt CreateContext(CFbsBitGc*& aGc);
1.75 + inline TInt CreateContext(CGraphicsContext*& aGc);
1.76 + IMPORT_C TDisplayMode DisplayMode() const;
1.77 + IMPORT_C TSize SizeInPixels() const;
1.78 + IMPORT_C TBool RectCompare(const TRect& aSourceRect,const CFbsDevice& aDevice,const TRect& aDeviceRect) const;
1.79 + IMPORT_C TInt AddFile(const TDesC& aName,TInt& aId);
1.80 + IMPORT_C void RemoveFile(TInt aId=0);
1.81 + IMPORT_C virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
1.82 + IMPORT_C virtual TInt GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec);
1.83 + IMPORT_C virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
1.84 + IMPORT_C virtual TInt GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec);
1.85 + IMPORT_C virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
1.86 + IMPORT_C virtual TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
1.87 + IMPORT_C TInt GetFontById(CFont*& aFont,TUid aFileId,const TAlgStyle& aStyle);
1.88 + inline TInt GetNearestFontInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec);
1.89 + inline TInt GetNearestFontInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec);
1.90 + inline TInt GetNearestFontToDesignHeightInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec);
1.91 + inline TInt GetNearestFontToDesignHeightInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec);
1.92 + inline TInt GetNearestFontToMaxHeightInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
1.93 + inline TInt GetNearestFontToMaxHeightInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight);
1.94 + inline TInt GetFontById(CFbsFont*& aFont,TUid aFileId,const TAlgStyle& aStyle);
1.95 + IMPORT_C void ReleaseFont(CFont* aFont);
1.96 + IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const;
1.97 + IMPORT_C TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const;
1.98 + IMPORT_C TInt NumTypefaces() const;
1.99 + IMPORT_C void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const;
1.100 + IMPORT_C TInt SetCustomPalette(const CPalette* aPalette);
1.101 + inline CGraphicsAccelerator* GraphicsAccelerator() const;
1.102 + inline CFbsBitGc::TGraphicsOrientation Orientation() const;
1.103 + IMPORT_C static TDisplayMode DisplayMode16M();
1.104 + IMPORT_C TInt SetScalingFactor(const TPoint& aOrigin,
1.105 + TInt aFactorX, TInt aFactorY,
1.106 + TInt aDivisorX, TInt aDivisorY);
1.107 + IMPORT_C void GetDrawRect(TRect& aRect) const;
1.108 + IMPORT_C TInt RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec, TInt& aId);
1.109 +protected:
1.110 + CFbsDevice();
1.111 + virtual void DrawingBegin(TBool /*aAlways*/ = EFalse) {}
1.112 + virtual void DrawingEnd(TBool /*aAlways*/ = EFalse) {}
1.113 +
1.114 + /**
1.115 + Sets the bit level.
1.116 + */
1.117 + virtual void SetBits() {}
1.118 +
1.119 + /**
1.120 + Cancels drawing the sprite.
1.121 + */
1.122 + virtual void CancelSprite() const {}
1.123 +
1.124 + /**
1.125 + Hides the sprite over the whole screen.
1.126 + @return TSpriteBase* A pointer to the hidden sprite. NULL in default implementation.
1.127 + */
1.128 + virtual TSpriteBase* HideSprite() const {return(NULL);}
1.129 +
1.130 + /**
1.131 + Hides the sprite within a particular region.
1.132 + @param aRect A rectangle within the clipping region.
1.133 + @param aClippingRegion The clipping region.
1.134 + @return TSpriteBase* A pointer to the hidden sprite. NULL in default implementation.
1.135 + */
1.136 + virtual TSpriteBase* HideSprite(const TRect&,const TRegion*) const {return(NULL);}
1.137 +
1.138 + /**
1.139 + Shows the specified sprite over the whole screen.
1.140 + @param aSprite The sprite which is to be shown.
1.141 + */
1.142 + virtual void ShowSprite(TSpriteBase*) const {}
1.143 +
1.144 + /**
1.145 + Shows the specified sprite within a particular region.
1.146 + @param aSprite The sprite which is to be shown.
1.147 + @param aRect A rectangle within the clipping region.
1.148 + @param aClippingRegion The clipping region
1.149 + */
1.150 + virtual void ShowSprite(TSpriteBase*,const TRect&,const TRegion*) const {}
1.151 + TInt GetNearestFbsFont(CFbsFont*& aFont,const TFontSpec& aFontSpec);
1.152 + void DoGetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,TDisplayMode aDispMode);
1.153 + void ReadLineDiffMode(TInt,TInt,TInt,TAny*,TDisplayMode) const;
1.154 + void TruncateRect(TRect& aRect);
1.155 + TBool SetOrientation(CFbsBitGc::TGraphicsOrientation aOrientation);
1.156 + void DrawingBegin(const CFbsBitmap* aBitmap, TBool aAlways = EFalse);
1.157 + void DrawingEnd(const CFbsBitmap* aBitmap, TBool aAlways = EFalse);
1.158 +protected:
1.159 + CFbsDrawDevice* iDrawDevice;
1.160 + RFbsSession* iFbs;
1.161 + CFbsTypefaceStore* iTypefaceStore;
1.162 + TInt iSpare;
1.163 + TBool iScreenDevice;
1.164 + TUint8* iBitBltMaskedBuffer;
1.165 + CGraphicsAccelerator* iGraphicsAccelerator;
1.166 + CFbsBitGc::TGraphicsOrientation iOrientation;
1.167 + };
1.168 +
1.169 +/** A graphics device interface that provides direct access to the screen, without
1.170 +the mediation of the window server.
1.171 +
1.172 +The interface adds sprite support to the CFbsDevice base class.
1.173 +@publishedAll
1.174 +@released
1.175 +*/
1.176 +class CFbsScreenDevice : public CFbsDevice
1.177 + {
1.178 +public:
1.179 + IMPORT_C static CFbsScreenDevice* NewL(const TDesC& aLibname,TDisplayMode aDispMode);
1.180 + IMPORT_C static CFbsScreenDevice* NewL(const TDesC& aLibname,TDisplayMode aDispMode, TRgb aWhite);
1.181 + IMPORT_C static CFbsScreenDevice* NewL(TInt aScreenNo, TDisplayMode aDispMode);
1.182 + IMPORT_C virtual ~CFbsScreenDevice();
1.183 + IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode aDispMode) const;
1.184 + IMPORT_C void GetPixel(TRgb& aColor,const TPoint& aPixel) const;
1.185 + IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixels) const;
1.186 + IMPORT_C TInt VerticalPixelsToTwips(TInt aPixels) const;
1.187 + IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwips) const;
1.188 + IMPORT_C TInt VerticalTwipsToPixels(TInt aTwips) const;
1.189 + IMPORT_C void SetAutoUpdate(TBool aValue);
1.190 + IMPORT_C void DrawSpriteBegin();
1.191 + IMPORT_C void DrawSpriteEnd();
1.192 + IMPORT_C void CancelSprite() const;
1.193 + IMPORT_C TSpriteBase* HideSprite() const;
1.194 + IMPORT_C TSpriteBase* HideSprite(const TRect& aRect,const TRegion* aClippingRegion) const;
1.195 + IMPORT_C void ShowSprite(TSpriteBase* aSprite) const;
1.196 + IMPORT_C void ShowSprite(TSpriteBase* aSprite,const TRect& aRect,const TRegion* aClippingRegion) const;
1.197 + IMPORT_C void ChangeScreenDevice(CFbsScreenDevice* aOldDevice);
1.198 + IMPORT_C void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const;
1.199 + IMPORT_C void SetPalette(CPalette* aPalette);
1.200 + IMPORT_C TInt GetPalette(CPalette*& aPalette) const;
1.201 + IMPORT_C void Update();
1.202 + IMPORT_C void Update(const TRegion& aRegion);
1.203 + IMPORT_C TSize SizeInTwips() const;
1.204 + IMPORT_C RHardwareBitmap HardwareBitmap();
1.205 + IMPORT_C const TUint32* Bits() const;
1.206 + IMPORT_C TInt Stride() const;
1.207 + IMPORT_C TInt ScreenNo() const;
1.208 + IMPORT_C TUint DeviceOrientationsAvailable() const; //< @internalTechnology
1.209 + IMPORT_C TBool SetDeviceOrientation(TDeviceOrientation aOrientation) const; //< @internalTechnology
1.210 + IMPORT_C void GetSurface(TSurfaceId& aSurface) const; //< @internalTechnology
1.211 + IMPORT_C TDeviceOrientation DeviceOrientation() const; //< @internalTechnology
1.212 +private:
1.213 + CFbsScreenDevice(TInt aScreenNo);
1.214 + void ConstructL(TInt aScreenNo, TDisplayMode aDispMode);
1.215 +private:
1.216 + TSpriteBase* iSprite;
1.217 + TBool iSpriteDraw;
1.218 + TInt iScreenNo;
1.219 + };
1.220 +
1.221 +/** A graphics device to which a bitmap managed by the font and bitmap server can
1.222 +be drawn.
1.223 +
1.224 +The class specialises the bitmap graphics device interface CBitmapDevice for
1.225 +drawing to in-memory bitmaps.
1.226 +@publishedAll
1.227 +@released
1.228 +*/
1.229 +class CFbsBitmapDevice : public CFbsDevice
1.230 + {
1.231 +public:
1.232 + IMPORT_C static CFbsBitmapDevice* NewL(CFbsBitmap* aFbsBitmap);
1.233 + IMPORT_C static CFbsBitmapDevice* NewL(CFbsBitmap* aFbsBitmap,const TDesC& aLibname);
1.234 + IMPORT_C virtual ~CFbsBitmapDevice();
1.235 + IMPORT_C TInt Resize(const TSize& aSize);
1.236 + IMPORT_C virtual void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode iDispMode) const;
1.237 + IMPORT_C virtual void GetPixel(TRgb& aColor,const TPoint& aPixel) const;
1.238 + IMPORT_C virtual TInt HorizontalPixelsToTwips(TInt aPixels) const;
1.239 + IMPORT_C virtual TInt VerticalPixelsToTwips(TInt aPixels) const;
1.240 + IMPORT_C virtual TInt HorizontalTwipsToPixels(TInt aTwips) const;
1.241 + IMPORT_C virtual TInt VerticalTwipsToPixels(TInt aTwips) const;
1.242 + IMPORT_C virtual TSize SizeInTwips() const;
1.243 + IMPORT_C virtual void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const;
1.244 + IMPORT_C virtual void SetPalette(CPalette* aPalette);
1.245 + IMPORT_C virtual TInt GetPalette(CPalette*& aPalette) const;
1.246 + IMPORT_C virtual void DrawingBegin(TBool aAlways = EFalse);
1.247 + IMPORT_C virtual void DrawingEnd(TBool aAlways = EFalse);
1.248 + IMPORT_C TInt SwapWidthAndHeight();
1.249 +private:
1.250 + CFbsBitmapDevice();
1.251 + virtual void SetBits();
1.252 + void ConstructL(CFbsBitmap* aFbsBitmap);
1.253 + void ConstructL(CFbsBitmap* aFbsBitmap,const TDesC& aLibname);
1.254 +private:
1.255 + CFbsBitGcBitmap* iFbsBmp;
1.256 + };
1.257 +
1.258 +#include <bitdev.inl>
1.259 +#endif