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