First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __DIRECTGDIGCWRAPPER_H__
17 #define __DIRECTGDIGCWRAPPER_H__
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>
28 * Required by MWsFader implementation
37 The purpose of this class is to wrap a @c CDirectGdiContext whenever an
38 @c MWsGraphicsContext is needed.
40 The methods doesn't do anything other than calling the corresponding method
41 in @c MWsGraphicsContext.
43 @see MWsGraphicsContext
44 @see MWsDrawableSourceProvider
45 @see CDirectGdiContext;
49 class CDirectGdiGcWrapper : public CBase, public MWsGraphicsContext, public MWsFader, public MWsDrawableSourceProvider, public MWsTextCursor
52 static CDirectGdiGcWrapper* NewL();
53 ~CDirectGdiGcWrapper();
54 inline CDirectGdiContext& DirectGdiGc();
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();
63 void Clear(const TRect& aRect);
64 void ResetBrushPattern();
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);
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;
120 // Return current error status of MWsGraphicsContext
123 TPoint Origin() const;
124 const TRegion& ClippingRegion();
125 // Save and retrieve gc settings
130 void SetFadingParameters(const TDesC8& aData);
131 void FadeArea(const TRegion& aRegion);
133 //from MWsObjectProvider
134 TAny* ResolveObjectInterface(TUint aTypeId);
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);
144 public: // from MWsTextCursor
145 void DrawTextCursor(const TTextCursorInfo& aTextCursorInfo);
148 void SetError(TInt aError);
151 CDirectGdiContext* iContext;
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
163 // CDirectGdiGcWrapper
166 inline CDirectGdiContext& CDirectGdiGcWrapper::DirectGdiGc()
171 #endif //__DIRECTGDIGCWRAPPER_H__