uiaccelerator_plat/alf_visual_api/inc/alf/alfimagebrush.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Image brush definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_ALFIMAGEBRUSH_H
       
    21 #define C_ALFIMAGEBRUSH_H
       
    22 
       
    23 #include <alf/alfbrush.h>
       
    24 #include <alf/alfimagevisual.h>
       
    25 
       
    26 class CAlfEnv;
       
    27 class TAlfImage;
       
    28 class TRgb;
       
    29 
       
    30 /**
       
    31  * Image brush can be used to fill the entire background of a visual. 
       
    32  * It can also be used for stretching out a single bitmap.
       
    33  * For example, in the case below, image is used as the borders and background of a visual.
       
    34  * 
       
    35  * Usage:
       
    36  * @code
       
    37  * 
       
    38  * // Create layout and visual, and set up some padding.
       
    39  * CAlfDeckLayout* deck = CAlfDeckLayout::AddNewL( control );
       
    40  * deck->SetPadding( TPoint( 10, 10 ) );
       
    41  * CAlfTextVisual* text = CAlfTextVisual::AddNewL( control, deck );
       
    42  * text->EnableBrushesL();
       
    43  * 
       
    44  * //For image in imagebrush
       
    45  * CAlfTexture* texture = iEnv->TextureManager().LoadTexture( _L("1.bmp"), 
       
    46  * 						EAlfTextureFlagDefault, AUTO_GENERATED_TEXTURE_ID );
       
    47  * 
       
    48  * // Image brush with borders within the brush area.
       
    49  * CAlfImageBrush* brush = CAlfImageBrush::NewL( &iEnv, TAlfImage( *texture ) );
       
    50  * brush->SetLayer( EAlfBrushLayerBackground );
       
    51  * text->Brushes()->AppendL( brush, EAlfHasOwnership );
       
    52  * 
       
    53  * @endcode
       
    54  * @lib alfclient.lib
       
    55  * @since S60 v3.2
       
    56  */
       
    57 NONSHARABLE_CLASS( CAlfImageBrush ): public CAlfBrush
       
    58     {
       
    59 
       
    60 public:
       
    61 
       
    62     /**
       
    63      * Constructor.
       
    64      */
       
    65     IMPORT_C static CAlfImageBrush* NewL(CAlfEnv& aEnv, const TAlfImage & aImage);
       
    66 
       
    67     /**
       
    68      * Constructor. The new brush is left on the cleanup stack.
       
    69      */
       
    70     IMPORT_C static CAlfImageBrush* NewLC(CAlfEnv& aEnv, const TAlfImage & aImage);
       
    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     IMPORT_C void SetScaleMode(CAlfImageVisual::TScaleMode aScaleMode);
       
    82 
       
    83     /**
       
    84      * Sets an image for this brush.
       
    85      *
       
    86      * @param aImage            Texture image for this brush.
       
    87      * 
       
    88      * @see SetBorders() 	    Call this if the image also includes 
       
    89      * 							borders.
       
    90      */
       
    91     IMPORT_C void SetImage(const TAlfImage& aImage);
       
    92     
       
    93     /**
       
    94      * Returns the brush image.
       
    95      */
       
    96     IMPORT_C const TAlfImage& Image() const;
       
    97 
       
    98 	/**
       
    99 	 * Define widths and heights for the borders of this image brush.
       
   100 	 * Note that image won't be scaled if this brush has borders.
       
   101      *
       
   102      * @param aLeftBorderWidth  Specifies if this image brush should also
       
   103      * 							draw a left border. Positive values specify
       
   104      * 							border the visuals left edge 
       
   105      * 							(extending the effective area of the visual),
       
   106      * 							negative values specify border inside the
       
   107      * 							area defined by the visual (visuals effective 
       
   108      * 							area is not extended).
       
   109      * 
       
   110      * 							Also the absolute value defines the width 
       
   111      * 							of the left border section of the image, 
       
   112      * 							in pixel columns. 
       
   113      * 							
       
   114      * 							Set to zero to draw without border.
       
   115      *
       
   116      * @param aRightBorderWidth Specifies if this image brush should also
       
   117      * 							draw a right border. Positive values specify
       
   118      * 							border outside the visuals right 
       
   119      * 							edge (extending the effective area of the 
       
   120      * 							visual), negative values specify border inside 
       
   121      * 							the	area defined by the visual (visuals 
       
   122      * 							effective area is not extended).
       
   123      * 
       
   124      * 							Also the absolute value defines the width 
       
   125      * 							of the right border section of the image, 
       
   126      * 							in pixel columns. 
       
   127      * 							
       
   128      * 							Set to zero to draw without border.
       
   129      * 
       
   130      * @param aTopBorderHeight  Specifies if this image brush should also
       
   131      * 							draw a top border. Positive values specify
       
   132      * 							border on top of the visuals top edge 
       
   133      * 							(extending the effective area of the visual),
       
   134      * 							negative values specify border inside the
       
   135      * 							area defined by the visual (visuals effective 
       
   136      * 							area is not extended).
       
   137      * 
       
   138      * 							Also the absolute value defines the height 
       
   139      * 							of the top border section of the image, 
       
   140      * 							in pixel rows. 
       
   141      * 							
       
   142      * 							Set to zero to draw without border.
       
   143      *
       
   144      * @param aBottomBorderHeight  Specifies if this image brush should also
       
   145      * 							draw a bottom border. Positive values specify
       
   146      * 							border below the visuals bottom edge 
       
   147      * 							(extending the effective area of the visual),
       
   148      * 							negative values specify border inside the
       
   149      * 							area defined by the visual (visuals effective 
       
   150      * 							area is not extended).
       
   151      * 
       
   152      * 							Also the absolute value defines the height 
       
   153      * 							of the top border section of the image, 
       
   154      * 							in pixel rows. 
       
   155      * 							
       
   156      * 							Set to zero to draw without border.
       
   157      * 
       
   158      * 
       
   159 	 */                           
       
   160 	IMPORT_C void SetBorders(TInt aLeftBorderWidth = 0,
       
   161                              TInt aRightBorderWidth = 0,
       
   162                              TInt aTopBorderHeight = 0,
       
   163                              TInt aBottomBorderHeight = 0);
       
   164 
       
   165 	/**
       
   166 	 * Returns true if borders should be drawn.
       
   167 	 */
       
   168 	IMPORT_C TBool BorderDrawingEnabled() const;
       
   169 
       
   170 	/**
       
   171 	 * Returns true if center should be also be drawn (not just borders).
       
   172 	 */
       
   173 	IMPORT_C TBool CenterDrawingEnabled() const;    
       
   174     
       
   175     /** 
       
   176      * Sets relative offset for scaled images.
       
   177      * 
       
   178      * @param aOffset relative offset Default value is (0,0).
       
   179      *                (0.5,1) moves the brush half the visual width right
       
   180      *                and the visual height downwards.
       
   181      */
       
   182     IMPORT_C void SetOffset(const TAlfTimedPoint& aOffset);
       
   183     
       
   184     /** 
       
   185      * Gets relative offset for scaled images.
       
   186      * @return relative offset
       
   187      */
       
   188     IMPORT_C const TAlfTimedPoint& Offset() const;
       
   189     
       
   190     /** 
       
   191      * Sets uniform scale factor for the image. 
       
   192      * Note that image won't be scaled if this brush has borders.
       
   193      *
       
   194      * @param aScale Scale factor. Value 1 is default.
       
   195      *               2 means double the size and 0.5 half the size.
       
   196      */
       
   197     IMPORT_C void SetScale(const TAlfTimedValue& aScale);
       
   198     
       
   199     /** 
       
   200      * Gets uniform scale factor for the image. 
       
   201      * @return aScale Scale factor
       
   202      */
       
   203     IMPORT_C const TAlfTimedValue& Scale() const;
       
   204         
       
   205     /**
       
   206      * Destructor.
       
   207      */
       
   208     virtual ~CAlfImageBrush();
       
   209 
       
   210 
       
   211 private:
       
   212 
       
   213     /**
       
   214      * 1st pahse constructor.
       
   215      */
       
   216     CAlfImageBrush();
       
   217 
       
   218     /**
       
   219      * 1nd pahse constructor.
       
   220      */
       
   221     void ConstructL(CAlfEnv& aEnv, const TAlfImage & aImage);
       
   222 
       
   223 private:
       
   224 
       
   225     // Private data. Owned.
       
   226     struct TImageBrushPrivateData;
       
   227     TImageBrushPrivateData* iImageBrushData;
       
   228 
       
   229     };
       
   230 
       
   231     
       
   232 #endif // C_ALFIMAGEBRUSH_H