idlehomescreen/inc/c_xnutils.h
branchRCL_3
changeset 83 5456b4e8b3a8
equal deleted inserted replaced
82:5f0182e07bfb 83:5456b4e8b3a8
       
     1 /*
       
     2 * Copyright (c) 2005-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:
       
    15 * Utility functions of Xuikon.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef C_XNUTILS_H
       
    20 #define C_XNUTILS_H
       
    21 
       
    22 // System includes
       
    23 #include <e32base.h>
       
    24 #include <gdi.h>
       
    25 #include <gulalign.h>
       
    26 
       
    27 // Forward declarations
       
    28 class CXnNodePluginIf;
       
    29 class CFont;
       
    30 class CXnNode;
       
    31 class CXnResource;
       
    32 class TAknsItemID;
       
    33 
       
    34 // Class declaration
       
    35 /**
       
    36  * Utility functions for Xuikon.
       
    37  *
       
    38  * @ingroup group_xnlayoutengine
       
    39  * @lib xn3layoutengine.lib
       
    40  * @since S60 v3.1
       
    41  */
       
    42 class CXnUtils : public CBase
       
    43     {
       
    44 public:
       
    45     /**
       
    46     * Creates the font according the parameters found from the given node.
       
    47     * Avkon font ids or font-family names can be used. If font family is
       
    48     * missing or defined as normal, system normal font is created.
       
    49     *
       
    50     * @since S60 v3.1
       
    51     * @param aNode Text element node.
       
    52     * @param aFont Font to be created.
       
    53     * @param aReleaseFont Whether the font needs to be released or not.
       
    54     */
       
    55     IMPORT_C static void CreateFontL(
       
    56         CXnNodePluginIf& aNode,
       
    57         CFont*& aFont,
       
    58         TInt& aReleaseFont );
       
    59 
       
    60     /**
       
    61     * Creates the font according the given parameters.
       
    62     * Avkon font ids or font-family names can be used. If font family is
       
    63     * missing or defined as normal, system normal font is created.
       
    64     *
       
    65     * @since S60 v3.2
       
    66     * @param aFontName Font name.
       
    67     * @param aFontSizeInPixels Defines a font size.
       
    68     * @param aFontStyle Defines the style, i.e. italic, bold, etc.
       
    69     * @param aFont Font to be created.
       
    70     * @param aReleaseFont Whether the font needs to be released or not.
       
    71     */
       
    72     IMPORT_C static void CreateFontL(
       
    73         const TDesC& aFontName,
       
    74         TInt aFontSizeInPixels,
       
    75         TFontStyle aFontStyle,
       
    76         CFont*& aFont,
       
    77         TInt& aReleaseFont );
       
    78 
       
    79     /**
       
    80     * Collapses the white spaces and special charachters from the given string
       
    81     * according to properties found from the given node.
       
    82     *
       
    83     * @since S60 v3.1
       
    84     * @param aNode Text element node.
       
    85     * @param aDes Descriptor to be modified.
       
    86     */
       
    87     IMPORT_C static void CollapseWhiteSpace(
       
    88         CXnNodePluginIf& aNode, TDes &aDes );
       
    89 
       
    90     /**
       
    91     * Returns the text alignment according to properties found from the given
       
    92     * node.
       
    93     *
       
    94     * @since S60 v3.1
       
    95     * @param aNode Text element node.
       
    96     * @return The text alignment.
       
    97     */
       
    98     IMPORT_C static TGulAlignmentValue TextAlignment( CXnNodePluginIf& aNode );
       
    99 
       
   100     /**
       
   101     * Avoid using this method. Produces low quality bitmaps. Rather use
       
   102     * CWindowGc::DrawBitmap and DrawBitmapMasked. These methods will scale 
       
   103     * images on fly and they support HW acceleration.
       
   104     * Scales the source bitmap into a given rectangle of the target bitmap.
       
   105     * Source and target bitmaps must have the same display mode.
       
   106     *
       
   107     * @since S60 v3.1
       
   108     * @param aTrgRect A rectangle area where the source bitmap is scaled.
       
   109     * @param aTrgBitmap A newly created bitmap.
       
   110     * @param aSrcBitmap An original bitmap.
       
   111     */
       
   112     IMPORT_C static void ScaleBitmapL(
       
   113         const TRect& aTrgRect,
       
   114         CFbsBitmap* aTrgBitmap,
       
   115         CFbsBitmap* aSrcBitmap );
       
   116 
       
   117     /**
       
   118      * Strips quotes from a descriptor string.
       
   119      *
       
   120      * @param aString A string.
       
   121      */
       
   122     IMPORT_C static void StripQuotes( HBufC*& aString );
       
   123 
       
   124     /**
       
   125      * Resolves a skin item ID from a descriptor string. The skin item ID is
       
   126      * stored in aItemID
       
   127      *
       
   128      * @param aSkinId A skin ID as a string descriptor.
       
   129      * @param aItemID An item ID to which the values are set from the
       
   130      *        descriptor.
       
   131      */
       
   132     IMPORT_C static TBool ResolveSkinItemIDL(
       
   133         const TDesC& aSkinId,
       
   134         TAknsItemID& aItemID );
       
   135 
       
   136     /**
       
   137      * Resolves a skin item ID and an integer index from a descriptor string.
       
   138      * The skin item ID is stored in aItemID and the index is stored in aIndex.
       
   139      *
       
   140      * @param aSkinId A skin ID as a descriptor string.
       
   141      * @param aItemID An item ID to which the values are set from the
       
   142      *        descriptor.
       
   143      * @param aIndex An integer index.
       
   144      */
       
   145     IMPORT_C static TBool ResolveSkinItemIDL(
       
   146         const TDesC& aSkinId,
       
   147         TAknsItemID& aItemID,
       
   148         TInt& aIndex );
       
   149 
       
   150     /**
       
   151      * Resolves RGB colour value from a string.
       
   152      *
       
   153      * @param aValue Resolved RGB value.
       
   154      * @param aData String from which RGB value is resolved.
       
   155      */
       
   156     IMPORT_C static TBool GetRgbValue( TRgb& aValue, const TDesC8& aData );
       
   157 
       
   158     /**
       
   159      * Converts HSL value to RGB and returns the RGB value.
       
   160      *
       
   161      * @param aHue Hue.
       
   162      * @param aSaturation Saturation.
       
   163      * @param aLightness Lightness.
       
   164      */
       
   165     IMPORT_C static TRgb ConvertHslToRgb(
       
   166         TInt aHue,
       
   167         TInt aSaturation,
       
   168         TInt aLightness );
       
   169 
       
   170     /**
       
   171      * Handles power save mode
       
   172      *
       
   173      * @param aNode A node where to start iterate.
       
   174      * @param aEvent Mode event.
       
   175      * @param aEnter enter or exit the mode.
       
   176      * @return ETrue if entered to the mode, EFalse if exited
       
   177      */
       
   178     IMPORT_C static TBool HandlePowerSaveModeL(
       
   179         CXnNode* aNode,
       
   180         TBool aEnter,
       
   181         TInt aEvent );
       
   182 
       
   183     /**
       
   184      * Finds a CXnResource object by the resource file name.
       
   185      *
       
   186      * @param aArray UIEngine's resource array
       
   187      * @param aResourceFileName resource file name
       
   188      * @param aBitmapIndex bitmap index
       
   189      */
       
   190     IMPORT_C static CXnResource* FindResource(
       
   191         CArrayPtrSeg< CXnResource >& aArray,
       
   192         const TDesC& aResourceFileName,
       
   193         TInt& aBitmapIndex );
       
   194 
       
   195     /**
       
   196      * @internal
       
   197      */
       
   198     static TBool DoesScaleBitmapUseFallBack( CFbsBitmap* aSrcBitmap );
       
   199 
       
   200     /**
       
   201      * @internal
       
   202      */
       
   203     static void ScaleBitmapExtL(
       
   204         const TRect& aTrgRect,
       
   205         CFbsBitmap* aTrgBitmap,
       
   206         CFbsBitmap* aSrcBitmap,
       
   207         TBool aForceFallBack );
       
   208     };
       
   209 
       
   210 #endif