uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/HuiImageBrush.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:   A brush that is able to draw images.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __HUIImageBrush_H__
       
    21 #define __HUIImageBrush_H__
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <uiacceltk/HuiBrush.h>
       
    26 #include <uiacceltk/HuiSkin.h>
       
    27 #include <uiacceltk/HuiGc.h>
       
    28 #include <uiacceltk/HuiImage.h>
       
    29 #include <uiacceltk/HuiTimedPoint.h>
       
    30 #include <uiacceltk/HuiImageVisual.h>
       
    31 
       
    32 
       
    33 /**
       
    34  * HuiImageBrush is a brush that can be used to attach (draw) images to
       
    35  * visuals. For example: backgrounds, pop-up icons or other image-based
       
    36  * decorations.
       
    37  *
       
    38  * Has also ability to stretch-fit the image to the area and draw borders.
       
    39  * 
       
    40  */
       
    41 NONSHARABLE_CLASS(CHuiImageBrush) : public CHuiBrush
       
    42     {
       
    43 public:
       
    44 
       
    45     /* Constructors and destructor. */
       
    46     
       
    47     /** @beginAPI */
       
    48 
       
    49     /**
       
    50      * Constructs a new image brush.
       
    51      *
       
    52      * @param aImage            Texture image for this brush.
       
    53      */
       
    54     IMPORT_C static CHuiImageBrush* NewL(const THuiImage & aImage);
       
    55 
       
    56     /**
       
    57      * Constructs a new image brush.
       
    58      *
       
    59      * @param aImage            Texture image for this brush.
       
    60      * @note 					The new brush is left on the cleanup stack.
       
    61      */
       
    62     IMPORT_C static CHuiImageBrush* NewLC(const THuiImage & aImage);
       
    63 
       
    64     /**
       
    65      * Destructor.
       
    66      */
       
    67     IMPORT_C ~CHuiImageBrush();
       
    68 
       
    69 
       
    70     /* Methods. */
       
    71     
       
    72     /**
       
    73      * Sets the scaling mode for the bitmap.
       
    74      * An unscaled image will be drawn at a 1:1 mapping between its
       
    75      * texture and the screen. A scaled image will be resized to fit the
       
    76      * visual's size exactly.
       
    77      * If unset, the default is EScaleFit.
       
    78      * 
       
    79      * @param aScaleMode The scaling mode of this image visual.
       
    80      *
       
    81      * @see CHuiImageVisual::SetScaleMode()
       
    82      */
       
    83     IMPORT_C void SetScaleMode( CHuiImageVisual::TScaleMode aScaleMode );
       
    84 
       
    85     /**
       
    86      * Sets an image for this brush.
       
    87      *
       
    88      * @param aImage            Texture image for this brush.
       
    89      * 
       
    90      * @see SetBorders() 	    Call this if the image also includes 
       
    91      * 							borders.
       
    92      */
       
    93     IMPORT_C void SetImage(const THuiImage& aImage);
       
    94 
       
    95     /**
       
    96      * Returns the image of the brush.
       
    97      */
       
    98     IMPORT_C const THuiImage& Image() const;
       
    99 
       
   100 	/**
       
   101 	 * Define widths and heights for the borders of this image brush.
       
   102 	 * 
       
   103      * @param aLeftBorderWidth  Specifies if this image brush should also
       
   104      * 							draw a left border. Positive values specify
       
   105      * 							border the visuals left edge 
       
   106      * 							(extending the effective area of the visual),
       
   107      * 							negative values specify border inside the
       
   108      * 							area defined by the visual (visuals effective 
       
   109      * 							area is not extended).
       
   110      * 
       
   111      * 							Also the absolute value defines the width 
       
   112      * 							of the left border section of the image, 
       
   113      * 							in pixel columns. 
       
   114      * 							
       
   115      * 							Set to zero to draw without border.
       
   116      *
       
   117      * @param aRightBorderWidth Specifies if this image brush should also
       
   118      * 							draw a right border. Positive values specify
       
   119      * 							border outside the visuals right 
       
   120      * 							edge (extending the effective area of the 
       
   121      * 							visual), negative values specify border inside 
       
   122      * 							the	area defined by the visual (visuals 
       
   123      * 							effective area is not extended).
       
   124      * 
       
   125      * 							Also the absolute value defines the width 
       
   126      * 							of the right border section of the image, 
       
   127      * 							in pixel columns. 
       
   128      * 							
       
   129      * 							Set to zero to draw without border.
       
   130      * 
       
   131      * @param aTopBorderHeight  Specifies if this image brush should also
       
   132      * 							draw a top border. Positive values specify
       
   133      * 							border on top of the visuals top edge 
       
   134      * 							(extending the effective area of the visual),
       
   135      * 							negative values specify border inside the
       
   136      * 							area defined by the visual (visuals effective 
       
   137      * 							area is not extended).
       
   138      * 
       
   139      * 							Also the absolute value defines the height 
       
   140      * 							of the top border section of the image, 
       
   141      * 							in pixel rows. 
       
   142      * 							
       
   143      * 							Set to zero to draw without border.
       
   144      *
       
   145      * @param aBottomBorderHeight  Specifies if this image brush should also
       
   146      * 							draw a bottom border. Positive values specify
       
   147      * 							border below the visuals bottom edge 
       
   148      * 							(extending the effective area of the visual),
       
   149      * 							negative values specify border inside the
       
   150      * 							area defined by the visual (visuals effective 
       
   151      * 							area is not extended).
       
   152      * 
       
   153      * 							Also the absolute value defines the height 
       
   154      * 							of the top border section of the image, 
       
   155      * 							in pixel rows. 
       
   156      * 							
       
   157      * 							Set to zero to draw without border.
       
   158      * 
       
   159      * 
       
   160 	 */                           
       
   161 	IMPORT_C void SetBorders(TInt aLeftBorderWidth = 0,
       
   162                              TInt aRightBorderWidth = 0,
       
   163                              TInt aTopBorderHeight = 0,
       
   164                              TInt aBottomBorderHeight = 0);
       
   165 
       
   166 	/**
       
   167 	 * Returns true if borders should be drawn.
       
   168 	 */
       
   169 	IMPORT_C TBool BorderDrawingEnabled() const;
       
   170 
       
   171 	/**
       
   172 	 * Returns true if center should be also be drawn (not just borders).
       
   173 	 */
       
   174 	IMPORT_C TBool CenterDrawingEnabled() const;
       
   175 
       
   176     /** @endAPI */
       
   177 
       
   178     // From CHuiBrush ..
       
   179 
       
   180     IMPORT_C virtual void ExpandVisualRect(TRect& aRect) const;
       
   181     
       
   182     /**
       
   183      * From CHuiBrush.
       
   184      * @see CHuiBrush::Changed()
       
   185     */
       
   186     TBool Changed() const;
       
   187     
       
   188     /**
       
   189      * From CHuiBrush.
       
   190      * @see CHuiBrush::ClearChanged()
       
   191     */
       
   192     void ClearChanged();
       
   193 
       
   194     IMPORT_C virtual void Draw(CHuiGc& aGc, const MHuiBrushGuide& aGuide) const;
       
   195 
       
   196     virtual TInt Type2() const { return EImageBrush; }
       
   197 
       
   198 protected:
       
   199 
       
   200     /* Constructors. */
       
   201 
       
   202     /**
       
   203      * Protected constructor.
       
   204      * @see NewL
       
   205      * @see NewLC
       
   206      */
       
   207     CHuiImageBrush(const THuiImage& aImage);
       
   208 
       
   209 private:
       
   210 
       
   211     /* Private variables. */
       
   212 
       
   213     /** Image for this brush. */
       
   214     THuiImage iImage;
       
   215     
       
   216     /** Scalingmode of the visual. */
       
   217     CHuiImageVisual::TScaleMode iScaleMode;
       
   218 
       
   219     /** Border width for the left border, in pixels. 0 means no border. */
       
   220     TInt iLeftBorderWidth;
       
   221     /** Border width for the right border, in pixels. 0 means no border. */
       
   222     TInt iRightBorderWidth;
       
   223     /** Border width for the top border, in pixels. 0 means no border. */
       
   224     TInt iTopBorderWidth;
       
   225     /** Border width for the bottom border, in pixels. 0 means no border. */
       
   226     TInt iBottomBorderWidth;
       
   227 
       
   228 public:
       
   229     /* Public properties. */
       
   230     
       
   231     /** Uniform scale factor for the image. */
       
   232     THuiTimedValue iScale;
       
   233 
       
   234     /** Texture offset. */
       
   235     THuiTimedPoint iImageOffset;
       
   236 
       
   237     };
       
   238 
       
   239 #endif  // __HUIImageBrush_H__