uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiBrush.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:   Definition of CHuiBrush. Brushes augment visuals with graphical effects.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __HUIBRUSH_H__
       
    21 #define __HUIBRUSH_H__
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <uiacceltk/HuiTimedValue.h>
       
    26 #include <uiacceltk/HuiRealRect.h>
       
    27 #include <uiacceltk/HuiSessionObject.h>
       
    28 
       
    29 
       
    30 /* Forward declarations. */
       
    31 class CHuiGc;
       
    32 class CHuiSkin;
       
    33 class CHuiVisual;
       
    34 
       
    35 
       
    36 /** Brush layers. */
       
    37 enum THuiBrushLayer
       
    38     {
       
    39     EHuiBrushLayerBackground,
       
    40     EHuiBrushLayerForeground
       
    41     };
       
    42 
       
    43 /**
       
    44  * MHuiBrushGuide is an interface that brushes use to get information about
       
    45  * the shape on which they are being applied.
       
    46  */
       
    47 class MHuiBrushGuide 
       
    48     {
       
    49 public:
       
    50 
       
    51     /**
       
    52      * Determines the general opacity of the brush.
       
    53      *
       
    54      * @return  Opacity (0..1).
       
    55      */ 
       
    56     virtual TReal32 BrushOpacity() const __SOFTFP = 0;
       
    57 
       
    58     /**
       
    59      * Determines the rectangle into which the brush is being drawn.
       
    60      * Uses display coordinates, with (0, 0) being in the upper left
       
    61      * corner of the display.
       
    62      *
       
    63      * @return  Rectangle for the brush in display coordinates.
       
    64      */
       
    65     virtual THuiRealRect BrushRect() const  __SOFTFP = 0;
       
    66     
       
    67     /**
       
    68      * Returns the skin that the brush should use for getting resources.
       
    69      *
       
    70      * @return  Skin instance.
       
    71      */    
       
    72     virtual CHuiSkin& BrushSkin() const = 0;
       
    73     
       
    74     };
       
    75 
       
    76 /**
       
    77  * A brush implements a series of graphics drawing operations. Brushes are 
       
    78  * attached to visuals and drawn whenever the visual is drawn. Brushes can 
       
    79  * be used for augmenting the normal appearance of visuals with graphical 
       
    80  * features such as background pictures, gradients, overlay icons, and 
       
    81  * selection highlights. Technically, a brush is a simple class whose most 
       
    82  * important method is Draw() that draws the brush into the specified area 
       
    83  * of the display.
       
    84  *
       
    85  * @see CHuiVisual::EnableBrushesL()
       
    86  * @see CHuiBrushArray
       
    87  */
       
    88 class CHuiBrush : public CBase, public MHuiSessionObject
       
    89 	{
       
    90 public:
       
    91 
       
    92 	/**
       
    93 	 * Destructor.
       
    94 	 */
       
    95 	IMPORT_C ~CHuiBrush();
       
    96 
       
    97 
       
    98 public: // new methods
       
    99 
       
   100     /**
       
   101      * Expands the dirty region of a visual. Called when a visual's dirty 
       
   102      * region is being determined. The brush is allowed to expand the 
       
   103      * rectangle to cover any additional drawing the brush is doing.
       
   104      * This is not called when the brush is clipped to the visual
       
   105      * rectangle, because in that case no drawing can occur outside the 
       
   106      * visual's area.
       
   107      *
       
   108      * @param aRect  Rectangle to expand. Visual's dirty region.
       
   109      */
       
   110     IMPORT_C virtual void ExpandVisualRect(TRect& aRect) const;
       
   111 
       
   112 	/**
       
   113 	 * Mark the brush as changed or unchanged.
       
   114 	 */
       
   115 	IMPORT_C void SetChanged();
       
   116 
       
   117     /**
       
   118      * Determines whether the brush has been changed and needs to be 
       
   119      * redrawn.
       
   120      */    
       
   121     IMPORT_C virtual TBool Changed() const;
       
   122     
       
   123     /**
       
   124      * Clears the changed status of the brush. This is called automatically
       
   125      * by the refresh loop after a frame has been drawn.
       
   126      */
       
   127     IMPORT_C virtual void ClearChanged();
       
   128     
       
   129     /**
       
   130      * Defines whether the brush can draw outside brush guide (i.e. visual's) rect 
       
   131      */
       
   132     IMPORT_C void SetClipToVisual(TBool aClipToVisual);
       
   133     
       
   134     IMPORT_C TBool ClipToVisual() const;
       
   135     
       
   136     /**
       
   137      * Defines the layer where brush is drawn (on top of / below visual)
       
   138      * @see THuiBrushLayer
       
   139      */
       
   140     IMPORT_C void SetLayer(THuiBrushLayer aLayer);
       
   141     
       
   142     IMPORT_C THuiBrushLayer Layer() const;
       
   143        
       
   144     /**
       
   145      * The brush is about to get drawn, usually gc parameters are set here
       
   146      */
       
   147     IMPORT_C virtual void BeginDraw(CHuiGc& aGc, const MHuiBrushGuide& aGuide) const;
       
   148 
       
   149     /**
       
   150      * Draw the brush using the current drawing parameters.
       
   151      */
       
   152     IMPORT_C virtual void Draw(CHuiGc& aGc, const MHuiBrushGuide& aGuide) const;
       
   153                                
       
   154     /**
       
   155      * The brush has been drawn, usually parameters changed in BeginDraw are reset here
       
   156      */
       
   157     IMPORT_C virtual void EndDraw(CHuiGc& aGc, const MHuiBrushGuide& aGuide) const;
       
   158               
       
   159     /**
       
   160      * Notifies change in the brush guide
       
   161      */
       
   162     void ActivateBrushGuide(const CHuiVisual* aNewGuide) const;
       
   163 
       
   164     /**
       
   165      * Returns active brush guide as a visual if it exist.
       
   166      * @return Visual acting as a brush guide.
       
   167      */
       
   168     CHuiVisual* BrushGuide() const;
       
   169                                                          
       
   170 public: // From MHuiSessionObject
       
   171     
       
   172     /**
       
   173      * Gets the object type.
       
   174      */
       
   175     IMPORT_C TType Type() const;
       
   176 
       
   177     /**
       
   178      * Gets the session id for object.
       
   179      */
       
   180     IMPORT_C TInt SessionId() const;
       
   181 
       
   182     /**
       
   183      * Sets the session id for object.
       
   184      */
       
   185     IMPORT_C void SetSessionId(TInt aSessionId);
       
   186 public:
       
   187     enum TType2
       
   188         { // this type is used for browsing BrushArray -- to detect who should control the brush in question
       
   189         ENotKnown,
       
   190         EImageBrush,
       
   191         ECmdBufferBrush
       
   192         };
       
   193     // returns TType2
       
   194     virtual TInt Type2() const { return ENotKnown; }
       
   195     
       
   196 protected:
       
   197 
       
   198 	/**
       
   199 	 * Constructor.
       
   200 	 */
       
   201 	IMPORT_C CHuiBrush();
       
   202     
       
   203     IMPORT_C virtual void BrushExtension(const TUid& aExtensionUid, TAny** aExtensionParameters);
       
   204 
       
   205 public:
       
   206 
       
   207     /* Public properties. */
       
   208 
       
   209     /** Opacity of the shadow. */    
       
   210     THuiTimedValue iOpacity;
       
   211     
       
   212 private:
       
   213 
       
   214     /** <code>ETrue</code> if the brush will be drawn. */
       
   215     TBool iEnabled;
       
   216 
       
   217     /** <code>ETrue</code> if the brush needs to be redrawn. */
       
   218     mutable TBool iChanged;    
       
   219 
       
   220     /** Layer determines drawing order. */
       
   221     THuiBrushLayer iLayer;
       
   222 
       
   223     /** Clip brush to the visual. */
       
   224     TBool iClipToVisual;
       
   225 
       
   226     /** Session id */
       
   227     TInt iSessionId;
       
   228 
       
   229     mutable CHuiVisual* iGuideVisual;//TAny* iSpare;
       
   230 	};
       
   231 
       
   232 #endif  // __HUIBRUSH_H__