uiacceltk/hitchcock/plugins/openwfcrs/inc/directgdigcwrapper.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 // Copyright (c) 2008-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 __DIRECTGDIGCWRAPPER_H__
       
    17 #define __DIRECTGDIGCWRAPPER_H__
       
    18 
       
    19 #include <graphics/wsgraphicscontext.h>
       
    20 #include <graphics/directgdiimagetarget.h>
       
    21 #include <graphics/directgdicontext.h>
       
    22 #include <graphics/wsdrawablesourceprovider.h>
       
    23 #include <graphics/sgimage.h>
       
    24 #include <graphics/wscursor.h>
       
    25 
       
    26 
       
    27 /* 
       
    28  * Required by MWsFader implementation
       
    29  */
       
    30 struct TFadingParams
       
    31     {
       
    32     TUint8 blackMap;
       
    33     TUint8 whiteMap;
       
    34     };
       
    35 
       
    36 /**
       
    37 The purpose of this class is to wrap a @c CDirectGdiContext whenever an
       
    38 @c MWsGraphicsContext is needed.
       
    39 
       
    40 The methods doesn't do anything other than calling the corresponding method
       
    41 in @c MWsGraphicsContext.
       
    42 
       
    43 @see MWsGraphicsContext
       
    44 @see MWsDrawableSourceProvider
       
    45 @see CDirectGdiContext;
       
    46 
       
    47 @internalComponent
       
    48 */
       
    49 class CDirectGdiGcWrapper : public CBase, public MWsGraphicsContext, public MWsFader, public MWsDrawableSourceProvider, public MWsTextCursor
       
    50 	{
       
    51 public:
       
    52 	static CDirectGdiGcWrapper* NewL();
       
    53 	~CDirectGdiGcWrapper();
       
    54 	inline CDirectGdiContext& DirectGdiGc();
       
    55 
       
    56 public: //from MWsGraphicsContext
       
    57 	void BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap);
       
    58 	void BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect);
       
    59 	void BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask);
       
    60 	void BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, const TPoint& aMaskPos);
       
    61 	void ResetClippingRegion();
       
    62 	void Clear();
       
    63 	void Clear(const TRect& aRect);
       
    64 	void ResetBrushPattern();
       
    65 	void ResetFont();
       
    66 	void DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd);
       
    67 	void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd);
       
    68 	void DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap);
       
    69 	void DrawBitmap(const TRect& aDestRect,	const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect);
       
    70 	void DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask);
       
    71 	void DrawRoundRect(const TRect& aRect, const TSize& aEllipse);
       
    72 	void DrawPolyLine(const TArray<TPoint>& aPointList);
       
    73 	void DrawPolyLineNoEndPoint(const TArray<TPoint>& aPointList);
       
    74 	void DrawPolygon(const TArray<TPoint>& aPointList, TFillRule aFillRule=EAlternate);
       
    75 	void DrawEllipse(const TRect& aRect);
       
    76 	void DrawLine(const TPoint& aStart, const TPoint& aEnd);
       
    77 	void DrawLineTo(const TPoint& aPoint);
       
    78 	void DrawLineBy(const TPoint& aVector);
       
    79 	void DrawRect(const TRect& aRect);
       
    80 	void DrawText(const TDesC& aText,const TTextParameters* aParam);
       
    81 	void DrawText(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPosition);
       
    82 	void DrawText(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect);
       
    83 	void DrawText(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipFillRect,TInt aBaselineOffset,TTextAlign aHrz=ELeft,TInt aMargin=0);
       
    84 	void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,TBool aUp);
       
    85 	void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPosition,TBool aUp);
       
    86 	void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TBool aUp);
       
    87 	void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0);
       
    88 	void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TInt aBaselineOffset,TInt aTextWidth,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0);
       
    89 	void MoveTo(const TPoint& aPoint);
       
    90 	void MoveBy(const TPoint& aVector);
       
    91 	void Plot(const TPoint& aPoint);
       
    92 	void Reset();
       
    93 	void SetBrushColor(const TRgb& aColor);
       
    94 	void SetBrushOrigin(const TPoint& aOrigin);
       
    95 	void SetBrushStyle(TBrushStyle aBrushStyle);
       
    96 	void SetClippingRegion(const TRegion& aRegion);
       
    97 	void SetDrawMode(TDrawMode aDrawMode);
       
    98 	void SetOrigin(const TPoint& aPoint = TPoint(0, 0));
       
    99 	void SetPenColor(const TRgb& aColor);
       
   100 	void SetPenStyle(TPenStyle aPenStyle);
       
   101 	void SetPenSize(const TSize& aSize);
       
   102 	void SetTextShadowColor(const TRgb& aColor);
       
   103 	void SetCharJustification(TInt aExcessWidth, TInt aNumChars);
       
   104 	void SetWordJustification(TInt aExcessWidth, TInt aNumGaps);
       
   105 	void SetUnderlineStyle(TFontUnderline aUnderlineStyle);
       
   106 	void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle);
       
   107 	void SetBrushPattern(const CFbsBitmap& aBitmap);
       
   108 	void SetBrushPattern(TInt aFbsBitmapHandle);
       
   109 	void SetFont(const CFont* aFont);
       
   110 	void CopyRect(const TPoint& aOffset, const TRect& aRect);
       
   111 	void UpdateJustification(const TDesC& aText,const TTextParameters* aParam);
       
   112 	void UpdateJustificationVertical(const TDesC& aText,const TTextParameters* aParam,TBool aUp);
       
   113 	void SetFontNoDuplicate(const CFont* aFont);
       
   114 	TBool HasBrushPattern() const;
       
   115 	TBool HasFont() const;
       
   116 	TRgb BrushColor() const;
       
   117 	TRgb PenColor() const;
       
   118 	TRgb TextShadowColor() const;
       
   119 	
       
   120 	// Return current error status of MWsGraphicsContext
       
   121 	TInt GetError();
       
   122 	// Getters
       
   123 	TPoint Origin() const;
       
   124 	const TRegion& ClippingRegion();
       
   125 	// Save and retrieve gc settings
       
   126 	TInt Push();
       
   127 	void Pop();
       
   128 
       
   129 public: // MWsFader
       
   130 	void SetFadingParameters(const TDesC8& aData);
       
   131 	void FadeArea(const TRegion& aRegion);
       
   132 
       
   133 	//from MWsObjectProvider
       
   134 	TAny* ResolveObjectInterface(TUint aTypeId);
       
   135 
       
   136 	//from MWsDrawableSourceProvider
       
   137 	TInt CreateDrawableSource(const TSgDrawableId& aDrawableId, TAny*& aSource);
       
   138 	void CloseDrawableSource(TAny* aSource);
       
   139 	void DrawResource(const TAny* aSource, const TPoint& aPos, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone);
       
   140 	void DrawResource(const TAny* aSource, const TRect& aRect, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone);
       
   141 	void DrawResource(const TAny* aSource, const TRect& aRectDest, const TRect& aRectSrc, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone);
       
   142 	void DrawResource(const TAny* aSource, const TRect& aRect, const TDesC8& aParam);
       
   143 
       
   144 public: // from MWsTextCursor
       
   145 	void DrawTextCursor(const TTextCursorInfo& aTextCursorInfo);	
       
   146 	
       
   147 private:
       
   148 	void SetError(TInt aError);
       
   149 	
       
   150 private:
       
   151 	CDirectGdiContext* iContext;
       
   152 	TInt iErrorCode;
       
   153 	CBufBase* iGcBuf; // used for keeping state when drawing CWsGraphicDrawers
       
   154 	RRegionBuf<20> iClippingRegion; // Clipping region while doing drawing
       
   155 	TPoint iOrigin; // Window Origin + User defined gc origin
       
   156 	RPointerArray<RDirectGdiDrawableSource> iDrawableSources;
       
   157 	//Required by MWsFader implmentation
       
   158 	TRgb			iFadeColor;
       
   159 	const TUint16*	iLut;
       
   160 	};
       
   161 
       
   162 //
       
   163 // CDirectGdiGcWrapper
       
   164 //
       
   165 
       
   166 inline CDirectGdiContext& CDirectGdiGcWrapper::DirectGdiGc()
       
   167 	{return(*iContext);}
       
   168 
       
   169 
       
   170 
       
   171 #endif //__DIRECTGDIGCWRAPPER_H__