sl@0: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __BITDEV_H__ sl@0: #define __BITDEV_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: class CFbsDrawDevice; sl@0: class TSurfaceId; sl@0: sl@0: /** Screen device orientations. sl@0: sl@0: WARNING: Enumeration for internal use ONLY. Compatibility is not guaranteed in future releases. sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: enum TDeviceOrientation sl@0: { sl@0: EDeviceOrientationNormal = 1, sl@0: EDeviceOrientation90CW = 2, sl@0: EDeviceOrientation180 = 4, sl@0: EDeviceOrientation270CW = 8 sl@0: }; sl@0: sl@0: /** Abstract base class for graphics devices to which bitmaps and fonts can be sl@0: drawn. sl@0: sl@0: The class implements the pure virtual CBitmapDevice functions and additionally sl@0: provides: sl@0: sl@0: support for creating and enquiring about fonts sl@0: sl@0: comparing two device rectangles sl@0: sl@0: creating a graphics context for the device. sl@0: sl@0: CFbsBitmapDevice and CFbsScreenDevice are derived fom this class. sl@0: sl@0: @see CFbsBitmapDevice sl@0: @see CFbsScreenDevice sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CFbsDevice : public CBitmapDevice sl@0: { sl@0: friend class CFbsBitGc; sl@0: public: sl@0: IMPORT_C ~CFbsDevice(); sl@0: IMPORT_C TInt CreateContext(CFbsBitGc*& aGc); sl@0: inline TInt CreateContext(CGraphicsContext*& aGc); sl@0: IMPORT_C TDisplayMode DisplayMode() const; sl@0: IMPORT_C TSize SizeInPixels() const; sl@0: IMPORT_C TBool RectCompare(const TRect& aSourceRect,const CFbsDevice& aDevice,const TRect& aDeviceRect) const; sl@0: IMPORT_C TInt AddFile(const TDesC& aName,TInt& aId); sl@0: IMPORT_C void RemoveFile(TInt aId=0); sl@0: IMPORT_C virtual TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec); sl@0: IMPORT_C virtual TInt GetNearestFontInPixels(CFont*& aFont, const TFontSpec& aFontSpec); sl@0: IMPORT_C virtual TInt GetNearestFontToDesignHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec); sl@0: IMPORT_C virtual TInt GetNearestFontToDesignHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec); sl@0: IMPORT_C virtual TInt GetNearestFontToMaxHeightInTwips(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); sl@0: IMPORT_C virtual TInt GetNearestFontToMaxHeightInPixels(CFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); sl@0: IMPORT_C TInt GetFontById(CFont*& aFont,TUid aFileId,const TAlgStyle& aStyle); sl@0: inline TInt GetNearestFontInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec); sl@0: inline TInt GetNearestFontInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec); sl@0: inline TInt GetNearestFontToDesignHeightInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec); sl@0: inline TInt GetNearestFontToDesignHeightInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec); sl@0: inline TInt GetNearestFontToMaxHeightInTwips(CFbsFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); sl@0: inline TInt GetNearestFontToMaxHeightInPixels(CFbsFont*& aFont, const TFontSpec& aFontSpec, TInt aMaxHeight); sl@0: inline TInt GetFontById(CFbsFont*& aFont,TUid aFileId,const TAlgStyle& aStyle); sl@0: IMPORT_C void ReleaseFont(CFont* aFont); sl@0: IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const; sl@0: IMPORT_C TInt FontHeightInPixels(TInt aTypefaceIndex,TInt aHeightIndex) const; sl@0: IMPORT_C TInt NumTypefaces() const; sl@0: IMPORT_C void TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const; sl@0: IMPORT_C TInt SetCustomPalette(const CPalette* aPalette); sl@0: inline CGraphicsAccelerator* GraphicsAccelerator() const; sl@0: inline CFbsBitGc::TGraphicsOrientation Orientation() const; sl@0: IMPORT_C static TDisplayMode DisplayMode16M(); sl@0: IMPORT_C TInt SetScalingFactor(const TPoint& aOrigin, sl@0: TInt aFactorX, TInt aFactorY, sl@0: TInt aDivisorX, TInt aDivisorY); sl@0: IMPORT_C void GetDrawRect(TRect& aRect) const; sl@0: IMPORT_C TInt RegisterLinkedTypeface(const CLinkedTypefaceSpecification& aLinkedTypefaceSpec, TInt& aId); sl@0: IMPORT_C TInt SetDrawDeviceOffset(const TPoint& aOrigin); sl@0: sl@0: protected: sl@0: CFbsDevice(); sl@0: virtual void DrawingBegin(TBool /*aAlways*/ = EFalse) {} sl@0: virtual void DrawingEnd(TBool /*aAlways*/ = EFalse) {} sl@0: sl@0: /** sl@0: Sets the bit level. sl@0: */ sl@0: virtual void SetBits() {} sl@0: sl@0: /** sl@0: This method has been deprecated. Sprites are no longer supported in BitGDI. sl@0: Calling this method has no effect. sl@0: @deprecated sl@0: */ sl@0: virtual void CancelSprite() const {} sl@0: sl@0: /** sl@0: This method has been deprecated. Sprites are no longer supported in BitGDI. sl@0: Calling this method has no effect. sl@0: @return TSpriteBase* NULL. sl@0: @deprecated sl@0: */ sl@0: virtual TSpriteBase* HideSprite() const {return(NULL);} sl@0: sl@0: /** sl@0: This method has been deprecated. Sprites are no longer supported in BitGDI. sl@0: Calling this method has no effect. sl@0: @param aRect Ignored. sl@0: @param aClippingRegion Ignored. sl@0: @return TSpriteBase* NULL. sl@0: @deprecated sl@0: */ sl@0: virtual TSpriteBase* HideSprite(const TRect&,const TRegion*) const {return(NULL);} sl@0: sl@0: /** sl@0: This method has been deprecated. Sprites are no longer supported in BitGDI. sl@0: Calling this method has no effect. sl@0: @param aSprite Ignored. sl@0: @deprecated sl@0: */ sl@0: virtual void ShowSprite(TSpriteBase*) const {} sl@0: sl@0: /** sl@0: This method has been deprecated. Sprites are no longer supported in BitGDI. sl@0: Calling this method has no effect. sl@0: @param aSprite Ignored. sl@0: @param aRect Ignored. sl@0: @param aClippingRegion Ignored. sl@0: @deprecated sl@0: */ sl@0: virtual void ShowSprite(TSpriteBase*,const TRect&,const TRegion*) const {} sl@0: TInt GetNearestFbsFont(CFbsFont*& aFont,const TFontSpec& aFontSpec); sl@0: void DoGetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,TDisplayMode aDispMode); sl@0: void ReadLineDiffMode(TInt,TInt,TInt,TAny*,TDisplayMode) const; sl@0: void TruncateRect(TRect& aRect); sl@0: TBool SetOrientation(CFbsBitGc::TGraphicsOrientation aOrientation); sl@0: void DrawingBegin(const CFbsBitmap* aBitmap, TBool aAlways = EFalse); sl@0: void DrawingEnd(const CFbsBitmap* aBitmap, TBool aAlways = EFalse); sl@0: protected: sl@0: CFbsDrawDevice* iDrawDevice; sl@0: RFbsSession* iFbs; sl@0: CFbsTypefaceStore* iTypefaceStore; sl@0: TInt iSpare; sl@0: TBool iScreenDevice; sl@0: TUint8* iBitBltMaskedBuffer; sl@0: CGraphicsAccelerator* iGraphicsAccelerator; sl@0: CFbsBitGc::TGraphicsOrientation iOrientation; sl@0: }; sl@0: sl@0: /** A graphics device interface that provides direct access to the screen, without sl@0: the mediation of the window server. sl@0: sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CFbsScreenDevice : public CFbsDevice sl@0: { sl@0: public: sl@0: IMPORT_C static CFbsScreenDevice* NewL(const TDesC& aLibname,TDisplayMode aDispMode); sl@0: IMPORT_C static CFbsScreenDevice* NewL(const TDesC& aLibname,TDisplayMode aDispMode, TRgb aWhite); sl@0: IMPORT_C static CFbsScreenDevice* NewL(TInt aScreenNo, TDisplayMode aDispMode); sl@0: IMPORT_C virtual ~CFbsScreenDevice(); sl@0: IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode aDispMode) const; sl@0: IMPORT_C void GetPixel(TRgb& aColor,const TPoint& aPixel) const; sl@0: IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixels) const; sl@0: IMPORT_C TInt VerticalPixelsToTwips(TInt aPixels) const; sl@0: IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwips) const; sl@0: IMPORT_C TInt VerticalTwipsToPixels(TInt aTwips) const; sl@0: IMPORT_C void SetAutoUpdate(TBool aValue); sl@0: IMPORT_C void DrawSpriteBegin(); //< @deprecated sl@0: IMPORT_C void DrawSpriteEnd(); //< @deprecated sl@0: IMPORT_C void CancelSprite() const; //< @deprecated sl@0: IMPORT_C TSpriteBase* HideSprite() const; //< @deprecated sl@0: IMPORT_C TSpriteBase* HideSprite(const TRect& aRect,const TRegion* aClippingRegion) const; //< @deprecated sl@0: IMPORT_C void ShowSprite(TSpriteBase* aSprite) const; //< @deprecated sl@0: IMPORT_C void ShowSprite(TSpriteBase* aSprite,const TRect& aRect,const TRegion* aClippingRegion) const; //< @deprecated sl@0: IMPORT_C void ChangeScreenDevice(CFbsScreenDevice* aOldDevice); sl@0: IMPORT_C void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const; sl@0: IMPORT_C void SetPalette(CPalette* aPalette); sl@0: IMPORT_C TInt GetPalette(CPalette*& aPalette) const; sl@0: IMPORT_C void Update(); sl@0: IMPORT_C void Update(const TRegion& aRegion); sl@0: IMPORT_C TSize SizeInTwips() const; sl@0: IMPORT_C RHardwareBitmap HardwareBitmap(); sl@0: IMPORT_C const TUint32* Bits() const; sl@0: IMPORT_C TInt Stride() const; sl@0: IMPORT_C TInt ScreenNo() const; sl@0: IMPORT_C TUint DeviceOrientationsAvailable() const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: IMPORT_C TBool SetDeviceOrientation(TDeviceOrientation aOrientation) const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: IMPORT_C void GetSurface(TSurfaceId& aSurface) const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: IMPORT_C TDeviceOrientation DeviceOrientation() const; /**< WARNING: Function for internal use ONLY. Compatibility is not guaranteed in future releases. */ sl@0: private: sl@0: CFbsScreenDevice(TInt aScreenNo); sl@0: void ConstructL(TInt aScreenNo, TDisplayMode aDispMode); sl@0: private: sl@0: TInt iSpare1_CFbsScreenDevice; sl@0: TInt iSpare2_CFbsScreenDevice; sl@0: TInt iScreenNo; sl@0: }; sl@0: sl@0: /** A graphics device to which a bitmap managed by the font and bitmap server can sl@0: be drawn. sl@0: sl@0: The class specialises the bitmap graphics device interface CBitmapDevice for sl@0: drawing to in-memory bitmaps. sl@0: @publishedAll sl@0: @released sl@0: */ sl@0: class CFbsBitmapDevice : public CFbsDevice sl@0: { sl@0: public: sl@0: IMPORT_C static CFbsBitmapDevice* NewL(CFbsBitmap* aFbsBitmap); sl@0: IMPORT_C static CFbsBitmapDevice* NewL(CFbsBitmap* aFbsBitmap,const TDesC& aLibname); sl@0: IMPORT_C virtual ~CFbsBitmapDevice(); sl@0: IMPORT_C TInt Resize(const TSize& aSize); sl@0: IMPORT_C virtual void GetScanLine(TDes8& aBuf,const TPoint& aStartPixel,TInt aLength,TDisplayMode iDispMode) const; sl@0: IMPORT_C virtual void GetPixel(TRgb& aColor,const TPoint& aPixel) const; sl@0: IMPORT_C virtual TInt HorizontalPixelsToTwips(TInt aPixels) const; sl@0: IMPORT_C virtual TInt VerticalPixelsToTwips(TInt aPixels) const; sl@0: IMPORT_C virtual TInt HorizontalTwipsToPixels(TInt aTwips) const; sl@0: IMPORT_C virtual TInt VerticalTwipsToPixels(TInt aTwips) const; sl@0: IMPORT_C virtual TSize SizeInTwips() const; sl@0: IMPORT_C virtual void PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const; sl@0: IMPORT_C virtual void SetPalette(CPalette* aPalette); sl@0: IMPORT_C virtual TInt GetPalette(CPalette*& aPalette) const; sl@0: IMPORT_C virtual void DrawingBegin(TBool aAlways = EFalse); sl@0: IMPORT_C virtual void DrawingEnd(TBool aAlways = EFalse); sl@0: IMPORT_C TInt SwapWidthAndHeight(); sl@0: sl@0: private: sl@0: CFbsBitmapDevice(); sl@0: virtual void SetBits(); sl@0: void ConstructL(CFbsBitmap* aFbsBitmap); sl@0: void ConstructL(CFbsBitmap* aFbsBitmap,const TDesC& aLibname); sl@0: private: sl@0: CFbsBitGcBitmap* iFbsBmp; sl@0: }; sl@0: sl@0: #include sl@0: #endif