uiaccelerator_plat/alf_core_toolkit_api/inc/uiacceltk/huidropshadow.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2008 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:   Drop shadow handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_HUIDROPSHADOW_H
       
    21 #define C_HUIDROPSHADOW_H
       
    22 
       
    23 #include <gdi.h>
       
    24 #include <uiacceltk/HuiRealPoint.h>
       
    25 #include <uiacceltk/HuiRealRect.h>
       
    26 #include <uiacceltk/HuiTimedPoint.h>
       
    27 #include <uiacceltk/HuiTextureHandle.h>
       
    28 #include <uiacceltk/huimetric.h>
       
    29 
       
    30 class TAknsItemID;
       
    31 class MHuiSegmentedTexture;
       
    32 class CHuiTexture;
       
    33 class CHuiVisual;
       
    34 
       
    35 /**
       
    36  *  Drop shadow parameter handler
       
    37  *
       
    38  *  This interface can be fetched from the visual
       
    39  *  @see CHuiVisual::EnableDropShadowL
       
    40  *  @see CHuiVisual::DropShadowHandler
       
    41  *  
       
    42  *  @code
       
    43  *   // get the pointer
       
    44  *   visual->EnableDropShadowL();
       
    45  *   CHuiDropShadow* dropShadow = visual->DropShadowHandler();
       
    46  *
       
    47  *   // use it
       
    48  *   dropShadow->SetColor( KRgbRed );
       
    49  *   dropShadow->iOffset.Set( THuiRealPoint( 10, 10 ) );
       
    50  *  @endcode
       
    51  *
       
    52  *  Disabling the drop shadow from the visual, deletes the instance and therefore loses
       
    53  *  all set paramteres. If you want to just hide the drops shadow temporally, you can 
       
    54  *   a) set the opacity into 0 or
       
    55  *   b) set the scale into 0
       
    56  *
       
    57  *  @lib hitchcock.lib
       
    58  *  @since S60 v5.0.1
       
    59  */
       
    60 NONSHARABLE_CLASS( CHuiDropShadow ) : public CBase
       
    61     {
       
    62 public: // Exported functions
       
    63      
       
    64     /**
       
    65      * Sets the shadow in polar coordinates. This will be converted into xy
       
    66      * coordinates
       
    67      *
       
    68      * @param aAngle Angle of the shadow. 0 degrees is on the right hand side and 90 in directly above.
       
    69      * @param aDistance Distance of the shadow in unit defined by the user component. 
       
    70      * @param aTransitionTime Time reach the target.
       
    71      */ 
       
    72     IMPORT_C void SetOffset( TReal32 aAngle, THuiMetric aDistance, TInt aTransitionTime = 0 ) __SOFTFP;
       
    73         
       
    74     /**
       
    75      * Sets the color of the shadow.
       
    76      *
       
    77      * @param aColor Text color.
       
    78      * @param aTransitionTime Time reach the target. (not supported )
       
    79      */
       
    80     IMPORT_C void SetColor(const TRgb& aColor, TInt aTransitionTime = 0 );
       
    81 
       
    82      /**
       
    83       * Sets the color of the shadow via skin id.
       
    84       *
       
    85       * @param aID      Skin ID of the color group to use
       
    86       * @param aIndex   Index within the color group
       
    87       * @param aTransitionTime Time reach the target. (not supported )
       
    88       */
       
    89      IMPORT_C void SetColor(const TAknsItemID& aID,const TInt aIndex, TInt aTransitionTime = 0 );
       
    90      
       
    91 public: // internal methods
       
    92 
       
    93     CHuiDropShadow();
       
    94     void ConstructL();
       
    95     ~CHuiDropShadow();
       
    96     
       
    97     TBool Changed() const;
       
    98     void ClearChanged();
       
    99     
       
   100     TRgb Color() const;
       
   101     
       
   102     /**
       
   103      * Calculates the drawing size of the shadow texture
       
   104      *
       
   105      * @param aImageDrawingSize     Image drawing size
       
   106      * @param aShadowTextureSize    Shadow texture size
       
   107      *
       
   108      * @return Shadow drawing size
       
   109      */
       
   110     THuiRealSize ShadowDrawingSize( 
       
   111         const TSize& aImageDrawingSize, 
       
   112         const TSize& aShadowTextureSize ) const;
       
   113         
       
   114     /**
       
   115      * Checks if the shadow is visible (checks opacity and scale != 0)
       
   116      * 
       
   117      * @return ETrue if visible.
       
   118      */ 
       
   119     TBool IsShadowVisible() const;
       
   120     
       
   121     /**
       
   122      * Casts 'const MHuiTexture' into 'CHuiTexture' if applicaple.
       
   123      *
       
   124      * @param aTextureIf Original texture interface
       
   125      *
       
   126      * @return Casted to CHuiTexture instance if possible.
       
   127      */
       
   128     static CHuiTexture* ShadowedTextureInstance( const MHuiTexture& aTextureIf );
       
   129     
       
   130     /**
       
   131      * Calculates the shadow distance in pixels.
       
   132      *
       
   133      * @param aReferenceVisual Visual which determines the metrics.
       
   134      *
       
   135      * @return Shadow distance in pixels.
       
   136      */
       
   137     THuiRealPoint DistanceInPixels( const CHuiVisual& aReferenceVisual ) const;
       
   138     
       
   139     /**
       
   140      * Returns the rectangle in which the shadow is supposed to be drawn.
       
   141      * Area is given as real/floating values.
       
   142      *
       
   143      * @param aImageDrawingPosition Position where the image is drawn
       
   144      * @param aImageDrawingSize Size of the image to be drawn
       
   145      * @param aShadowTextureSize Size of the shadow texture
       
   146      * @prarm aReferenceVisual Reference visual for the relative metrics.
       
   147      *
       
   148      * @return Area used by the shadow.
       
   149      */
       
   150     THuiRealRect ShadowDrawingRealRect( 
       
   151         const TPoint& aImageDrawingPosition,
       
   152         const TSize& aImageDrawingSize, 
       
   153         const TSize& aShadowTextureSize,
       
   154         const CHuiVisual& aReferenceVisual  ) const;
       
   155     
       
   156     /**
       
   157      * Returns the rectangle in which the shadow is supposed to be drawn.
       
   158      * Area is given as integer/fixed values.
       
   159      *
       
   160      * @param aImageDrawingPosition Position where the image is drawn
       
   161      * @param aImageDrawingSize Size of the image to be drawn
       
   162      * @param aShadowTextureSize Size of the shadow texture
       
   163      * @prarm aReferenceVisual Reference visual for the relative metrics.
       
   164      *
       
   165      * @return Area used by the shadow.
       
   166      */    
       
   167     TRect ShadowDrawingTRect( 
       
   168         const TPoint& aImageDrawingPosition,
       
   169         const TSize& aImageDrawingSize, 
       
   170         const TSize& aShadowTextureSize,
       
   171         const CHuiVisual& aReferenceVisual  ) const;
       
   172     
       
   173 public: // public members
       
   174 
       
   175     /**
       
   176      * Opacity of the shadow
       
   177      */ 
       
   178     THuiTimedValue iOpacity;
       
   179     
       
   180     /**
       
   181      * Shadow offset in timed xy-coordinates
       
   182      */
       
   183     THuiTimedPoint iOffset;
       
   184     
       
   185     /**
       
   186      * Shadow offset unit
       
   187      */
       
   188     TInt iOffsetUnit;
       
   189     
       
   190     /**
       
   191      * Sets the blur filter radius. This is used to generate the shadow from the
       
   192      * texture. Normally between 2-5 pixels (in texture coordinates).
       
   193      */
       
   194     THuiTimedValue iRadius;
       
   195     
       
   196     /**
       
   197      * Scale of the shadow - default 1.0.
       
   198      */ 
       
   199     THuiTimedValue iScale;
       
   200    
       
   201 private:
       
   202 
       
   203     struct THuiDropShadowData;
       
   204     THuiDropShadowData* iData;
       
   205 
       
   206     };
       
   207 
       
   208 
       
   209 #endif // C_HUIDROPSHADOW_H