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