windowing/windowserver/inc/Graphics/wsgraphicscontext.h
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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 // Interface for Render Stage Abstract Graphics Context
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @publishedPartner
       
    20  @prototype
       
    21 */
       
    22 
       
    23 #ifndef __WSGRAPHICSCONTEXT_H__
       
    24 #define __WSGRAPHICSCONTEXT_H__
       
    25 
       
    26 #include <w32std.h>
       
    27 #include <graphics/wsgraphicdrawerinterface.h>
       
    28 
       
    29 /** Render Stage abstract graphics context.
       
    30 
       
    31 This interface is provided by Render Stages.  It abstracts the graphics context
       
    32 of the pixel target.  The intention is to allow Render Stages to intercept
       
    33 draw operations so that they can be batched (to reduce flickering), modified
       
    34 (to provide transition effects), or re-directed (to alternate back-end
       
    35 architectures).
       
    36 
       
    37 @publishedPartner
       
    38 @prototype
       
    39 */
       
    40 class MWsGraphicsContext : public MWsObjectProvider
       
    41 	{
       
    42 public:
       
    43 	DECLARE_WS_TYPE_ID(KMWsGraphicsContext)
       
    44 	/** Text alignment.
       
    45 	@publishedPartner
       
    46 	@prototype
       
    47 	*/
       
    48 	enum TTextAlign
       
    49 		{
       
    50 		/** Text is left-aligned. */
       
    51 		ELeft,
       
    52 		/** Text is centred. */
       
    53 		ECenter,
       
    54 		/** Text is right-aligned. */
       
    55 		ERight
       
    56 		};
       
    57 
       
    58 	/** 
       
    59 	Brush styles. 
       
    60 	@publishedPartner
       
    61 	@prototype
       
    62 	*/
       
    63 	enum TBrushStyle
       
    64 		{
       
    65 		/** The brush fill has no effect (default). */
       
    66 		ENullBrush,
       
    67 		/** The brush fills with a solid single colour, determined by 
       
    68 		SetBrushColor() and the drawing mode. */
       
    69 		ESolidBrush,
       
    70 		/** The brush fills with a selected bitmap pattern, set by 
       
    71 		UseBrushPattern(). */
       
    72 		EPatternedBrush,
       
    73 		/** The brush fills with vertical hatching  lines going from top to 
       
    74 		bottom. */
       
    75 		EVerticalHatchBrush,
       
    76 		/** The brush fills with diagonal hatching lines going from bottom 
       
    77 		left to top right. */
       
    78 		EForwardDiagonalHatchBrush,
       
    79 		/** The brush fills with horizontal hatching lines going from left 
       
    80 		to right. */
       
    81 		EHorizontalHatchBrush,
       
    82 		/** The brush fills with rearward diagonal hatching lines going from top 
       
    83 		left to bottom right. */
       
    84 		ERearwardDiagonalHatchBrush,
       
    85 		/** The brush fills with horizontal and vertical hatching  lines going 
       
    86 		from left to right plus lines going from top to bottom  giving the 
       
    87 		effect of a grid of small squares */
       
    88 		ESquareCrossHatchBrush,
       
    89 		/** The brush fills with forward diagonal and rearward diagonal hatching 
       
    90 		lines going from bottom left to top right plus lines going from top left 
       
    91 		to bottom right giving the effect of a grid of small diamonds. */
       
    92 		EDiamondCrossHatchBrush
       
    93 		};
       
    94 
       
    95 	/** 
       
    96 	Drawing modes. The drawing modes define the way that the pen and brush colors are
       
    97 	drawn, EDrawModePEN means do alpha blending if appropriate, EDrawModeWriteAlpha means 
       
    98 	don't do alpha blending.
       
    99 
       
   100 	@see SetDrawMode()
       
   101 	@publishedPartner
       
   102 	@prototype
       
   103 	*/
       
   104 	enum TDrawMode
       
   105 		{		
       
   106 		/** Uses both pen and brush colour as they are. */
       
   107 		EDrawModePEN=32,		
       
   108 		/** Writes alpha information in the source directly into the destination, rather than blending. */
       
   109 		EDrawModeWriteAlpha=64
       
   110 		};
       
   111 
       
   112 	/** 
       
   113 	Pen styles. The screen pattern unit in each definition below describes the 
       
   114 	pattern drawn by the line 1 represents a pixel drawn, 0 represents a 
       
   115 	pixel that is not affected. 
       
   116 	@publishedPartner
       
   117 	@prototype
       
   118 	*/
       
   119 	enum TPenStyle
       
   120 		{
       
   121 		/** The pen does not draw. Screen pattern unit = 00... */
       
   122 		ENullPen,
       
   123 		/** A solid line (default). Screen pattern unit = 11... */
       
   124 		ESolidPen,
       
   125 		/** A dotted line. Screen pattern unit = 1000... */
       
   126 		EDottedPen,
       
   127 		/** A dashed line. Screen pattern unit = 111000... */
       
   128 		EDashedPen,
       
   129 		/** A line of alternating dashes and dots. Screen pattern unit = 
       
   130 		1111001100... */
       
   131 		EDotDashPen,
       
   132 		/** A line of alternating single dashes and pairs of dots. Screen 
       
   133 		pattern unit = 11110011001100... */
       
   134 		EDotDotDashPen
       
   135 		};
       
   136 
       
   137 	/** 
       
   138 	Rules used to fill self-intersecting polygons. 
       
   139 
       
   140 	The filling of a polygon proceeds as follows: for a given point in the 
       
   141 	polygon, then:
       
   142 
       
   143 	if the rule is TFillRule::EAlternate (default) and it has an odd winding 
       
   144 	number, then fill the surrounding area.
       
   145 
       
   146 	if the rule is TFillRule::EWinding and it has a winding number greater than 
       
   147 	zero, then fill the surrounding area. 
       
   148 	@publishedPartner
       
   149 	@prototype
       
   150 	*/
       
   151 	enum TFillRule
       
   152 		{
       
   153 		/** Only fill areas with odd winding numbers. */
       
   154 		EAlternate,
       
   155 		/** Fill areas with winding numbers greater than zero. */
       
   156 		EWinding
       
   157 		};
       
   158 
       
   159 	/**
       
   160 	Font underline flags. 
       
   161 	@publishedPartner
       
   162 	@prototype
       
   163 	*/
       
   164 	enum TFontUnderline
       
   165 		{
       
   166 		/** Font is not underlined. */
       
   167 		EUnderlineOff,
       
   168 		/** Font is underlined. */
       
   169 		EUnderlineOn
       
   170 		};
       
   171 
       
   172 	/**
       
   173 	Font strike-through flags. 
       
   174 	@publishedPartner
       
   175 	@prototype
       
   176 	*/
       
   177 	enum TFontStrikethrough
       
   178 		{
       
   179 		/** Font is not struck-through. */
       
   180 		EStrikethroughOff,
       
   181 		/** Font is struck-through. */
       
   182 		EStrikethroughOn
       
   183 		};
       
   184 
       
   185 	/**
       
   186 	Parameters used in drawing text within supplied context.
       
   187 	It is used by MWsGraphicsContext::DrawText() and MWsGraphicsContext::DrawTextVertical() family of API's
       
   188 	to draw text from iStart to iEnd withing the supplied text descriptor.
       
   189 	
       
   190 	@publishedPartner
       
   191 	@prototype
       
   192 	*/
       
   193 	class TTextParameters
       
   194 		{
       
   195 	public:
       
   196 		TTextParameters():
       
   197 			iStart(0),
       
   198 			iEnd(KMaxTInt),
       
   199 			iFlags(0)
       
   200 				{
       
   201 				}
       
   202 		TInt iStart;
       
   203 		TInt iEnd;
       
   204 		TUint16 iFlags;
       
   205 		/* Reserved for future use */
       
   206 		TAny* iReserved1;
       
   207 		TAny* iReserved2;
       
   208 		TAny* iReserved3;
       
   209 		TAny* iReserved4;
       
   210 		};
       
   211 	
       
   212 public:
       
   213 	// The following are equivalent to CFbsBitGc functionality which maps 
       
   214 	// to client’s CWindowGc requests
       
   215 	virtual void BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap) = 0;
       
   216 	virtual void BitBlt(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap,	const TRect& aSourceRect) = 0;
       
   217 	virtual void BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask) = 0;
       
   218 	virtual void BitBltMasked(const TPoint& aDestPos, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, const TPoint& aMaskPos) = 0;
       
   219 	virtual void ResetClippingRegion() = 0;
       
   220 	virtual void Clear() = 0;
       
   221 	virtual void Clear(const TRect& aRect) = 0;
       
   222 	virtual void ResetBrushPattern() = 0;
       
   223 	virtual void ResetFont() = 0;
       
   224 	virtual void DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd) = 0;
       
   225 	virtual void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd) = 0;
       
   226 	virtual void DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap) = 0;
       
   227 	virtual void DrawBitmap(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap, const TRect& aSourceRect) = 0;
       
   228 	virtual void DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap& aSourceBitmap,const TRect& aSourceRect, const CFbsBitmap& aMaskBitmap, TBool aInvertMask) = 0;
       
   229 	virtual void DrawRoundRect(const TRect& aRect, const TSize& aEllipse) = 0;
       
   230 	virtual void DrawPolyLine(const TArray<TPoint>& aPointList) = 0; 
       
   231 	virtual void DrawPolyLineNoEndPoint(const TArray<TPoint>& aPointList) = 0;  
       
   232 	virtual void DrawPolygon(const TArray<TPoint>& aPointList, TFillRule aFillRule=EAlternate) = 0;
       
   233 	virtual void DrawEllipse(const TRect& aRect) = 0;
       
   234 	virtual void DrawLine(const TPoint& aStart, const TPoint& aEnd) = 0;
       
   235 	virtual void DrawLineTo(const TPoint& aPoint) = 0;
       
   236 	virtual void DrawLineBy(const TPoint& aVector) = 0;
       
   237 	virtual void DrawRect(const TRect& aRect) = 0;
       
   238 	virtual void DrawText(const TDesC& aText,const TTextParameters* aParam) = 0;
       
   239 	virtual void DrawText(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPosition) = 0;
       
   240 	virtual void DrawText(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect) = 0;
       
   241 	virtual void DrawText(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipFillRect,TInt aBaselineOffset,TTextAlign aHrz=ELeft,TInt aMargin=0) = 0;
       
   242 	virtual void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,TBool aUp) = 0;
       
   243 	virtual void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TPoint& aPosition,TBool aUp) = 0;
       
   244 	virtual void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TBool aUp) = 0;
       
   245 	virtual void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0) = 0;
       
   246 	virtual void DrawTextVertical(const TDesC& aText,const TTextParameters* aParam,const TRect& aClipRect,TInt aBaselineOffset,TInt aTextWidth,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0) = 0;
       
   247 	virtual void MoveTo(const TPoint& aPoint) = 0;
       
   248 	virtual void MoveBy(const TPoint& aVector) = 0;
       
   249 	virtual void Plot(const TPoint& aPoint) = 0;
       
   250 	virtual void Reset() = 0;
       
   251 	virtual void SetBrushColor(const TRgb& aColor) = 0;
       
   252 	virtual void SetBrushOrigin(const TPoint& aOrigin) = 0;
       
   253 	virtual void SetBrushStyle(TBrushStyle aBrushStyle) = 0;
       
   254 	virtual void SetClippingRegion(const TRegion& aRegion) = 0;
       
   255 	virtual void SetDrawMode(TDrawMode aDrawMode) = 0;
       
   256 	virtual void SetOrigin(const TPoint& aPoint = TPoint(0, 0)) = 0;
       
   257 	virtual void SetPenColor(const TRgb& aColor) = 0;
       
   258 	virtual void SetPenStyle(TPenStyle aPenStyle) = 0;
       
   259 	virtual void SetPenSize(const TSize& aSize) = 0;
       
   260 	virtual void SetTextShadowColor(const TRgb& aColor) = 0;
       
   261 	virtual void SetCharJustification(TInt aExcessWidth, TInt aNumChars) = 0;
       
   262 	virtual void SetWordJustification(TInt aExcessWidth, TInt aNumGaps) = 0;
       
   263 	virtual void SetUnderlineStyle(TFontUnderline aUnderlineStyle) = 0;
       
   264 	virtual void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle) = 0;
       
   265 	virtual void SetBrushPattern(const CFbsBitmap& aBitmap) = 0;
       
   266 	virtual void SetBrushPattern(TInt aFbsBitmapHandle) = 0;
       
   267 	virtual void SetFont(const CFont* aFont) = 0;
       
   268 	
       
   269 	// CFbsBitGc functionality used by Wserv for its internal operations
       
   270 	virtual void CopyRect(const TPoint& aOffset, const TRect& aRect) = 0;
       
   271 	virtual void UpdateJustification(const TDesC& aText,const TTextParameters* aParam) = 0;
       
   272 	virtual void UpdateJustificationVertical(const TDesC& aText,const TTextParameters* aParam,TBool aUp) = 0;
       
   273 	virtual void SetFontNoDuplicate(const CFont* aFont) = 0;
       
   274 	virtual TBool HasBrushPattern() const = 0;
       
   275 	virtual TBool HasFont() const = 0;
       
   276 	virtual TRgb BrushColor() const = 0;
       
   277 	virtual TRgb PenColor() const = 0;
       
   278 	virtual TRgb TextShadowColor() const = 0;
       
   279 	
       
   280 	// Return current error status of MWsGraphicsContext
       
   281 	virtual TInt GetError() = 0;
       
   282 	
       
   283 	/** The origin of the GC relative to the screen's origin
       
   284 		@return the origin */
       
   285 	virtual TPoint Origin() const = 0;
       
   286 	/** The clipping region currently being used
       
   287 		@return the clipping region */
       
   288 	virtual const TRegion& ClippingRegion() = 0;
       
   289 	/** Saves the state of the GC to an internal buffer.  Several GC states can be saved in a FILO.
       
   290 		Do not restore a GC (using Pop()) that wasn't properly saved!
       
   291 		@return KErrNone if successful, else one of the system-wide error codes. */
       
   292 	virtual TInt Push() = 0;
       
   293 	/** Restores the last GC state that was saved. */
       
   294 	virtual void Pop() = 0;
       
   295 	};
       
   296 
       
   297 #endif	//__WSGRAPHICSCONTEXT_H__