uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiLineVisual.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:   Defines CHuiLineVisual, Visual that is able to draw lines 
       
    15 *                onto a curve path. 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __HUILINEVISUAL_H__
       
    22 #define __HUILINEVISUAL_H__
       
    23 
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <uiacceltk/HuiVisual.h>
       
    27 #include <uiacceltk/HuiImage.h>
       
    28 #include <uiacceltk/HuiOwnedPointer.h>
       
    29 #include <uiacceltk/HuiCurvePath.h>
       
    30 #include <uiacceltk/HuiGc.h>
       
    31 #include <uiacceltk/HuiMappingFunctions.h>
       
    32 
       
    33 
       
    34 /* Forward declarations */
       
    35 class CHuiEnv;
       
    36 class CHuiControl;
       
    37 
       
    38 
       
    39 /**
       
    40  * Line visual draws a line along a curve path.
       
    41  *
       
    42  * A line visual will draw a bendy line that follows a specified
       
    43  * curve path. Width and alpha functions can be set to change the
       
    44  * opacity and thickness of the line along its length.
       
    45  *
       
    46  * Note that the Bitgdi renderer contains only a minimal implementation
       
    47  * of line drawing. There is no aliasing or shading on the line, and
       
    48  * thickness and alpha functions have no effect. The entire thickness of a Bitgdi
       
    49  * line is set by the initial thickness at point 0.
       
    50  *
       
    51  * @see CHuiCurvePath
       
    52  */
       
    53 NONSHARABLE_CLASS(CHuiLineVisual) : public CHuiVisual
       
    54     {
       
    55 public:
       
    56 
       
    57     /* Constructors and destructor. */
       
    58 
       
    59     /**
       
    60      * Constructs and appends a new text visual to the owner control.
       
    61      *
       
    62      * @param aOwnerControl  Control that will own the new visual.
       
    63      *
       
    64      * @return  The new visual.
       
    65      */
       
    66     IMPORT_C static CHuiLineVisual* AddNewL(CHuiControl& aOwnerControl,
       
    67                                             CHuiLayout* aParentLayout);
       
    68 
       
    69     /**
       
    70      * Constructor.
       
    71      */
       
    72     CHuiLineVisual(MHuiVisualOwner& aOwner);
       
    73 
       
    74     /**
       
    75      * Second-phase constructor.
       
    76      */
       
    77     void ConstructL();
       
    78 
       
    79     /**
       
    80      * Destructor.
       
    81      */
       
    82     virtual ~CHuiLineVisual();
       
    83 
       
    84 
       
    85     /* Methods. */
       
    86 
       
    87     /**
       
    88      * Sets the path instance of the visual.
       
    89      *
       
    90      * @param aPath
       
    91      * @param aOwnership
       
    92      */
       
    93     IMPORT_C void SetPath(CHuiCurvePath* aPath, THuiOwnership aOwnership);
       
    94 
       
    95     /**
       
    96      * Returns the path of the visual. The path can be modified via this
       
    97      * reference.
       
    98      */
       
    99     IMPORT_C CHuiCurvePath& Path();
       
   100 
       
   101     virtual TBool Changed() const;
       
   102 
       
   103     virtual void ClearChanged();
       
   104 
       
   105     /**
       
   106      * Sets the image used by the line.
       
   107      */
       
   108     IMPORT_C void SetImage(const THuiImage& aImage);
       
   109 
       
   110     /**
       
   111      * Sets the alpha mapping function that generates alpha values for the
       
   112      * path.
       
   113      */
       
   114     IMPORT_C void SetAlphaFunction(MHuiMappingFunction* aFunction);
       
   115 
       
   116     /**
       
   117      * Sets the width mapping function that generates width values for the
       
   118      * path.
       
   119      */
       
   120     IMPORT_C void SetWidthFunction(MHuiMappingFunction* aFunction);
       
   121 
       
   122      /**
       
   123      * Sets the color of the line.
       
   124      *
       
   125      * @param aColor           Line color.
       
   126      */
       
   127     IMPORT_C void SetColor(const TRgb& aColor);
       
   128 
       
   129     /**
       
   130      * Draw the curve path.
       
   131      */
       
   132     virtual void DrawSelf(CHuiGc& aGc, const TRect& aDisplayRect) const;
       
   133     
       
   134     /**
       
   135      * Expand dirty region
       
   136      */
       
   137     void ExpandRectWithContent(TRect& aRect) const;
       
   138 
       
   139 private:
       
   140 
       
   141     /* Private methods */
       
   142 
       
   143 
       
   144 private:
       
   145 
       
   146     /** The path of the visual. */
       
   147     RHuiOwnedPointer<CHuiCurvePath> iPath;
       
   148 
       
   149     /** Image used by the line. */
       
   150     THuiImage iImage;
       
   151 
       
   152     /** Value mapping function that generates alpha values for path
       
   153         positions. */
       
   154     MHuiMappingFunction* iAlphaFunction;
       
   155 
       
   156     /** Custom width mapping function. */
       
   157     MHuiMappingFunction* iWidthFunction;
       
   158 
       
   159     /** Determines the width of the line. Depends on the current value
       
   160         of iThickness. */
       
   161     mutable THuiConstantMappingFunction iDefaultWidthFunction;
       
   162 
       
   163 public:
       
   164 
       
   165     /* Public properties. */
       
   166 
       
   167     /** Thickness of the line. */
       
   168     THuiTimedValue iThickness;
       
   169 
       
   170     /** Thickness of the shadow around the line. */
       
   171     THuiTimedValue iShadowThickness;
       
   172 
       
   173     /** Current start position on the path. */
       
   174     THuiTimedValue iStartPos;
       
   175 
       
   176     /** Current end position on the path. */
       
   177     THuiTimedValue iEndPos;
       
   178 
       
   179 private:
       
   180 
       
   181     /** Line color */
       
   182     TRgb iColor;
       
   183     };
       
   184 
       
   185 #endif  // __HUILINEVISUAL_H__
       
   186