meetingrequest/mrgui/mrfieldbuildercommon/inc/cmrrecordinggc.h
branchRCL_3
changeset 22 d620048b4810
equal deleted inserted replaced
20:efd4f1afd43e 22:d620048b4810
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Recording graphics context used to cache drawing commands.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <w32std.h>
       
    20 #include <gdi.h>
       
    21 
       
    22 class CFbsBitmap;
       
    23 class CFbsBitGc;
       
    24 class CFbsBitmapDevice;
       
    25 
       
    26 NONSHARABLE_CLASS( CMRRecordingGc ) : public CWindowGc
       
    27     {
       
    28 public:
       
    29 
       
    30     CMRRecordingGc( CWindowGc& aRealGc );
       
    31 	~CMRRecordingGc();
       
    32 		
       
    33 public:
       
    34     
       
    35 	/**
       
    36 	 * Flush recorded drawing commands from buffer to the real
       
    37 	 * graphics context.
       
    38 	 * 
       
    39 	 * @param aRect Target rectangle to draw
       
    40 	 */
       
    41 	void FlushBuffer( const TRect& aRect );
       
    42 	
       
    43 	/**
       
    44 	 * Delete recorded drawing commands
       
    45 	 */
       
    46     void PurgeBuffer();
       
    47     
       
    48 public: // From CGraphicsContext
       
    49     
       
    50     void SetOrigin(const TPoint &aPoint=TPoint(0,0));
       
    51     
       
    52 protected:
       
    53     
       
    54     // From CWindowGc
       
    55     	
       
    56 	void Activate( RDrawableWindow &aDevice );
       
    57 	void Deactivate();
       
    58 
       
    59 	// From CGraphicsContext
       
    60 	CGraphicsDevice* Device() const;
       
    61 	void SetDrawMode(TDrawMode aDrawingMode);
       
    62 	void SetClippingRect(const TRect& aRect);
       
    63 	void CancelClippingRect();
       
    64 	void Reset();
       
    65 
       
    66 	void UseFont(const CFont *aFont);
       
    67 	void DiscardFont();
       
    68 	void SetUnderlineStyle(TFontUnderline aUnderlineStyle);
       
    69 	void SetStrikethroughStyle( TFontStrikethrough aStrikethroughStyle );
       
    70 	
       
    71 	void SetWordJustification(TInt aExcessWidth,TInt aNumGaps);
       
    72 	void SetCharJustification(TInt aExcessWidth,TInt aNumChars);
       
    73 
       
    74 	void SetPenColor(const TRgb &aColor);
       
    75 	void SetPenStyle(TPenStyle aPenStyle);
       
    76 	void SetPenSize(const TSize& aSize);
       
    77 
       
    78 	void SetBrushColor(const TRgb &aColor);
       
    79 	void SetBrushStyle(TBrushStyle aBrushStyle);
       
    80 	void SetBrushOrigin(const TPoint &aOrigin);
       
    81 	void UseBrushPattern(const CFbsBitmap *aDevice);
       
    82 	void DiscardBrushPattern();
       
    83 
       
    84 	void MoveTo(const TPoint &aPoint);
       
    85 	void MoveBy(const TPoint &aPoint);
       
    86 	void Plot(const TPoint &aPoint);
       
    87 
       
    88 	void DrawArc(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd);
       
    89 	void DrawLine(const TPoint &aPoint1,const TPoint &aPoint2);
       
    90 	void DrawLineTo(const TPoint &aPoint);
       
    91 	void DrawLineBy( const TPoint& aPoint );
       
    92 	
       
    93 	void DrawPolyLine(const CArrayFix<TPoint> *aPointList);
       
    94 	void DrawPolyLine(const TPoint* aPointList,TInt aNumPoints);
       
    95 
       
    96 	void DrawPie(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd);
       
    97 	void DrawEllipse(const TRect &aRect);
       
    98 	void DrawRect(const TRect &aRect);
       
    99 	void DrawRoundRect(const TRect &aRect,const TSize &aEllipse);
       
   100 	TInt DrawPolygon(const CArrayFix<TPoint> *aPointList,TFillRule aFillRule=EAlternate);
       
   101 	TInt DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule=EAlternate);
       
   102 
       
   103 	void DrawBitmap(const TPoint &aTopLeft, const CFbsBitmap *aDevice);
       
   104 	void DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice);
       
   105 	void DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aDevice, const TRect &aSourceRect);
       
   106 	void DrawBitmapMasked(const TRect& aDestRect, const CFbsBitmap* aBitmap, const TRect& aSourceRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask);
       
   107 	void DrawBitmapMasked(const TRect& aDestRect, const CWsBitmap* aBitmap, const TRect& aSourceRect, const CWsBitmap* aMaskBitmap, TBool aInvertMask);
       
   108 
       
   109 	void DrawText(const TDesC &aBuf,const TPoint &aPos);
       
   110 	void DrawText(const TDesC &aBuf,const TRect &aBox,TInt aBaselineOffset,TTextAlign aHoriz=ELeft,TInt aLeftMrg=0);
       
   111 
       
   112 	// From CBitmapContext
       
   113 	void Clear();
       
   114 	void Clear(const TRect &aRect);
       
   115 	void CopyRect(const TPoint &anOffset,const TRect &aRect);
       
   116 	void BitBlt(const TPoint &aPos, const CFbsBitmap *aBitmap);
       
   117 	void BitBlt(const TPoint &aDestination, const CFbsBitmap *aBitmap, const TRect &aSource);
       
   118 	void BitBltMasked(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask);
       
   119 	void BitBlt(const TPoint &aPoint, const CWsBitmap *aBitmap);
       
   120 	void BitBlt(const TPoint &aDestination, const CWsBitmap *aBitmap, const TRect &aSource);
       
   121 	void BitBltMasked(const TPoint& aPoint,const CWsBitmap *aBitmap,const TRect& aSourceRect,const CWsBitmap *aMaskBitmap,TBool aInvertMask);
       
   122 	void MapColors(const TRect& aRect,const TRgb* aColors,TInt aNumPairs=2,TBool aMapForwards=ETrue);
       
   123 
       
   124 	void DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp);
       
   125 	void DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0);
       
   126 
       
   127 	//=================Extra functions specific to wserv GDI==============
       
   128 	void SetDitherOrigin(const TPoint& aPoint);
       
   129 	TInt SetClippingRegion(const TRegion &aRegion);
       
   130 	void CancelClippingRegion();
       
   131 	void SetOpaque(TBool aDrawOpaque=ETrue);
       
   132 
       
   133 	// From CFbsBitGc
       
   134 	void SetFaded(TBool aFaded);
       
   135 	void SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap);
       
   136 	TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt);
       
   137 	TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp, const TRect& aSrcRect, const CWsBitmap* aAlphaBmp, const TPoint& aAlphaPt);
       
   138 	
       
   139 	TAny* Interface( TUid aInterfaceId );
       
   140     const TAny* Interface( TUid aInterfaceId ) const;
       
   141     
       
   142 protected:  
       
   143     TInt APIExtension( TUid aUid, TAny*& aOutput, TAny* aInput );
       
   144     
       
   145 private:
       
   146     
       
   147     /**
       
   148      * Buffer item to store drawing command and parameters
       
   149      */
       
   150     NONSHARABLE_CLASS( CBufferItem ) : public CBase
       
   151         {
       
   152         public:
       
   153         enum TCommandType
       
   154             {
       
   155             EShortText,
       
   156             ELongText,
       
   157             ESetPenColor,
       
   158             EBitBlt1,
       
   159             EBitBlt2,
       
   160             EBitBltMasked1,
       
   161             EUseFont,
       
   162             EDiscardFont,
       
   163             ESetDrawMode,
       
   164             ESetClippingRect,
       
   165             ECancelClippingRect,
       
   166             ESetBrushColor,
       
   167             ESetBrushStyle,
       
   168             EDrawRect,
       
   169             EClear,
       
   170             EDrawLine,
       
   171             ESetUnderlineStyle,
       
   172             ESetStrikethroughStyle
       
   173             };
       
   174         
       
   175         public:
       
   176             ~CBufferItem();
       
   177             
       
   178             /**
       
   179              * Translated commaned with given point
       
   180              */
       
   181             void Translate( const TPoint& aPoint );
       
   182             
       
   183             TInt iType;
       
   184             HBufC* iText;
       
   185             TPoint iPosition;
       
   186             TRect iBox;
       
   187             TInt iBaseLineOffset;
       
   188             //TTextAlign iHorizontal;
       
   189             TInt iLeftMargin;
       
   190             TRgb iColor;
       
   191             const CFbsBitmap* iBitmap;
       
   192             const CFbsBitmap* iMask;
       
   193             TRect iSource;
       
   194             TBool iInvertMask;
       
   195             const CFont* iFont;
       
   196             //TDrawMode iDrawMode;
       
   197             //TBrushStyle iBrushStyle;
       
   198             TRect iRect;
       
   199             TInt iValue;
       
   200         };
       
   201         
       
   202     CBufferItem* BufferItem();
       
   203         
       
   204     /// Ref: Real window GC for actual drawing
       
   205     CWindowGc& iRealGc;
       
   206     /// Own: Array of recorded drawing commands
       
   207     RPointerArray<CBufferItem> iItems;
       
   208     /// Own: Recording origin relative to real context
       
   209     TPoint iOrigin;
       
   210     };
       
   211