uiaccelerator_plat/alf_visual_api/inc/alf/alfgradientbrush.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:   Gradient brush class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_ALFGRADIENTBRUSH_H
       
    21 #define C_ALFGRADIENTBRUSH_H
       
    22 
       
    23 #include <alf/alfbrush.h>
       
    24 #include <gdi.h>
       
    25 
       
    26 class CAlfEnv;
       
    27 class TAlfImage;
       
    28 
       
    29 /**
       
    30  * Linear gradient brush. Draws a sequence of colors in a linear gradient.
       
    31  * A gradient brush can draw gradients in horizontal and vertical 
       
    32  * directions using any number of colors.
       
    33  * 
       
    34  * Usage:
       
    35  * @code
       
    36  * 
       
    37  * CAlfVisual* visual = CAlfVisual::AddNewL( control );
       
    38  * visual->EnableBrushesL();
       
    39  * CAlfGradientBrush* brush = CAlfGradientBrush::NewL( *iEnv );
       
    40  * 
       
    41  * // Configure the gradient: direction and colors.
       
    42  * brush->SetDirection( CAlfGradientBrush::EDirectionDown );
       
    43  * brush->SetColor( KRgbBlack, .5f );
       
    44  * brush->AppendColorL( 1, KRgbRed, 1.f );
       
    45  * brush->AppendColorL( 2, KRgbYellow, .1f );
       
    46  * 
       
    47  * //Append brush in brusharray with ownership to array 
       
    48  * visual->Brushes()->AppendL( brush, EAlfHasOwnership );
       
    49  * @endcode
       
    50  * @lib alfclient.lib
       
    51  * @since S60 v3.2
       
    52  */
       
    53 NONSHARABLE_CLASS( CAlfGradientBrush ): public CAlfBrush
       
    54     {
       
    55     
       
    56 public:
       
    57 
       
    58     /** Linear gradient directions. */
       
    59     enum TDirection
       
    60         {
       
    61         EDirectionUp,
       
    62         EDirectionRight,
       
    63         EDirectionDown,
       
    64         EDirectionLeft
       
    65         };
       
    66 
       
    67     /**
       
    68      * Constructor.
       
    69      */
       
    70     IMPORT_C static CAlfGradientBrush* NewL( CAlfEnv& aEnv );
       
    71 
       
    72     /**
       
    73      * Constructor. The new brush is left on the cleanup stack.
       
    74      */
       
    75     IMPORT_C static CAlfGradientBrush* NewLC( CAlfEnv& aEnv );
       
    76     
       
    77     /**
       
    78      * Destructor.
       
    79      */
       
    80     virtual ~CAlfGradientBrush();
       
    81     
       
    82     /**
       
    83      * Sets the gradient direction.
       
    84      */
       
    85     IMPORT_C void SetDirection(TDirection aDirection);
       
    86 
       
    87     /**
       
    88      * Replaces all colors with a single color.
       
    89      *
       
    90      * @param aColor    Solid color for the gradient.
       
    91      * @param aOpacity  Opacity.
       
    92      */
       
    93     IMPORT_C void SetColor(const TRgb& aColor, TReal32 aOpacity = 1.0) __SOFTFP;
       
    94 
       
    95     /**
       
    96      * Sets the image for the gradient. By default, no image is used. The image
       
    97      * can be cleared with <code>SetImage(TAlfImage())</code>.
       
    98      *
       
    99      * @param aImage  Image to use in the gradient.
       
   100      */
       
   101     IMPORT_C void SetImage(const TAlfImage& aImage);
       
   102 
       
   103     /**
       
   104      * Returns a color from the gradient.
       
   105      */
       
   106     IMPORT_C TRgb Color(TInt aIndex) const;
       
   107 
       
   108     /**
       
   109      * Returns an opacity value from the gradient.
       
   110      */
       
   111     IMPORT_C TReal32 Opacity(TInt aIndex) const;
       
   112 
       
   113     /**
       
   114      * Returns the image of the gradient brush.
       
   115      */
       
   116     IMPORT_C const TAlfImage& Image() const;
       
   117 
       
   118     /**
       
   119      * Appends a new color for the entire gradient. The caller must
       
   120      * append colors in the correct order, by ascending position.
       
   121      *
       
   122      * @param aPosition  Position of the color.
       
   123      * @param aColor     Color at the position.
       
   124      * @param aOpacity   Opacity at the position.
       
   125      */
       
   126     IMPORT_C void AppendColorL(
       
   127         TReal32 aPosition, 
       
   128         const TRgb& aColor,
       
   129         TReal32 aOpacity = 1.0) __SOFTFP;
       
   130     
       
   131 
       
   132 private:
       
   133 
       
   134     CAlfGradientBrush();
       
   135 
       
   136     void ConstructL( CAlfEnv& aEnv );
       
   137 
       
   138 private: // data
       
   139 
       
   140     struct TGradientBrushPrivateData;
       
   141     TGradientBrushPrivateData* iGradientBrushData;
       
   142     
       
   143     };
       
   144 
       
   145 
       
   146 
       
   147 #endif // C_ALFGRADIENTBRUSH_H