epoc32/include/mw/AknsUtils.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2002-2004 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:  Defines a public static utility class AknsUtils.
    15 *
    16 */
    17 
    18 
    19 #ifndef AKNSUTILS_H
    20 #define AKNSUTILS_H
    21 
    22 //  INCLUDES
    23 #include <AknsSkinInstance.h>
    24 #include <apgicnfl.h>
    25 #include <AknIconUtils.h>
    26 
    27 // FORWARD DECLARATIONS
    28 class CFbsBitmap;
    29 class CAknsItemDef;
    30 class CCoeControl;
    31 class CGulIcon;
    32 
    33 // TYPE DEFINITIONS
    34 
    35 /**
    36 * Type of the application icon.
    37 *
    38 * @since 2.8
    39 */
    40 enum TAknsAppIconType
    41     {
    42     EAknsAppIconTypeList    = 0,
    43     EAknsAppIconTypeContext = 1,
    44     EAknsAppIconType3D      = 2
    45     };
    46 
    47 // CLASS DECLARATION
    48 
    49 /**
    50 * Static utility class to support AVKON SKINS common operations.
    51 * AknsUtils provides utility method to initialize application skin support,
    52 * retrieve current skin instance or data context, retrieve skin data
    53 * items and to perform other skin-related tasks.
    54 *
    55 * This is a public static class with exported functions.
    56 * The class is not intended for derivation outside the library.
    57 *
    58 * @lib AknSkins.lib
    59 *
    60 * @since 2.0
    61 */
    62 class AknsUtils
    63     {    
    64 
    65     public: // New functions - Creators
    66         
    67         /**
    68         * Initializes application skin support.
    69         * Creates application skin instance. Method should be called once
    70         * in the construction phase of application, before any other 
    71         * skin-related operations take place.
    72         *
    73         * @since 2.0
    74         *
    75         * @par Notes:
    76         *   The framework calls this method automatically for each
    77         *   application. Thus, a normal application does not need to
    78         *   call this method explicitly.        
    79         *
    80         * @par Exceptions:
    81         *   - If allocation fails, function leaves with an error code.
    82         */
    83         IMPORT_C static void InitSkinSupportL();
    84 
    85         /**
    86         * Creates data context suitable for a container.
    87         * Constructs a new data context suitable for a container. Container
    88         * should store the pointer and perform proper destruction when 
    89         * the lifetime of the container itself ends.
    90         *
    91         * @since 2.0
    92         *
    93         * @return Newly created data context. Ownership of the context object
    94         *   is transferred to the caller.
    95         */
    96         IMPORT_C static MAknsDataContext* CreateDataContextForContainerL();
    97 
    98         /**
    99         * Constructs a new bitmap item definition object.
   100         *
   101         * @since 2.0
   102         *
   103         * @param aID Item ID of the item definition object to be created:
   104         *
   105         * @param aFile Filename of the MBM file.
   106         *
   107         * @param aIndex Index of the bitmap in the file.
   108         *
   109         * @return Newly constructed item definition object.
   110         *
   111         * @par Exceptions:
   112         *   If construction fails, the method leaves with an error code.
   113         */
   114         IMPORT_C static CAknsItemDef* CreateBitmapItemDefL( 
   115             const TAknsItemID& aID, const TDesC& aFilename, 
   116             const TInt aIndex );
   117 
   118         /**
   119         * Constructs a new masked bitmap item definition object.
   120         *
   121         * @since 2.0
   122         *
   123         * @param aID Item ID of the item definition object to be created:
   124         *
   125         * @param aFile Filename of the MBM file.
   126         *
   127         * @param aIndex Index of the bitmap in the file.
   128         *
   129         * @param aIndex Index of the bitmap mask in the file.
   130         *
   131         * @return Newly constructed item definition object. Ownership of the
   132         *   object is transferred to the caller.
   133         *
   134         * @par Exceptions:
   135         *   If construction fails, the method leaves with an error code.
   136         */
   137         IMPORT_C static CAknsItemDef* CreateMaskedBitmapItemDefL( 
   138             const TAknsItemID& aID, const TDesC& aFilename, 
   139             const TInt aIndex, const TInt aMaskIndex );
   140 
   141     public: // New functions - Skin access
   142 
   143 		/**
   144         * Returns pointer to current skin instance.
   145         * Retrieves pointer to the current application skin instance singleton.
   146         * If there is none, @c NULL value is returned.
   147         *
   148         * @since 2.0
   149         *
   150         * @return Pointer to current skin instance, or @c NULL if no skin 
   151         *   support is available.
   152         */
   153         IMPORT_C static MAknsSkinInstance* SkinInstance();
   154 
   155         /**
   156         * Returns pointer to current data context.
   157         * If aMop parameter is specified, retrieves the nearest data context
   158         * in control hierarchy. If none is found (or @c NULL parameter was
   159         * given) returns root data context from skin instance. If there is
   160         * no skin instance, @c NULL value is returned.
   161         *
   162         * @since 2.0
   163         *
   164         * @param aMop Object provider to be used to find the nearest data
   165         *   context. In most cases this should be a pointer to the calling
   166         *   @c CCoeControl. @c NULL value is also valid.
   167         *
   168         * @return Pointer to the nearest data context, or @c NULL if no
   169         *   skin support is available.
   170         */
   171         IMPORT_C static MAknsDataContext* DataContext( MObjectProvider* aMop );
   172 
   173     public: // New functions - Item access w/ fallback support
   174 
   175         /**
   176         * Constructs an independent masked bitmap with fallback support.
   177         * Creates an independent (in terms of instance ownership) copy of a 
   178         * masked bitmap by the given item ID.
   179         *
   180         * If no matching item is found in the currently activate skin,
   181         * attempts to construct the item using the given file.
   182         *
   183         * @since 2.6
   184         *
   185         * @lib AknSkins.lib
   186         *
   187         * @param aInstance Pointer to the current skin instance.
   188         *   Usually retrieved using @c AknsUtils::SkinInstance.
   189         *
   190         * @param aID Item ID of the masked bitmap to be created.
   191         *
   192         * @param aBitmap If method succeeds, set to point to the
   193         *   newly constructed bitmap. Ownership of the bitmap is transferred 
   194         *   to the caller.
   195         *
   196         * @param aMask If method succeeds, set to point to the newly
   197         *   constructed mask bitmap. Ownership of the bitmap is transferred
   198         *   to the caller.
   199         *
   200         * @param aFilename Filename to be used to construct the item, 
   201         *   if no matching item was found in the currently active skin.
   202         *
   203         * @param aFileBitmapId ID of the bitmap in the file. 
   204         *   Used only if no matching item was found in the currently 
   205         *   active skin.
   206         *
   207         * @param aFileMaskId ID of the mask in the file.
   208         *   Used only if no matching item was found in the currently
   209         *   active skin.
   210         *
   211         * @par Exceptions:
   212         *   If data construction fails or bitmap is not found, the function
   213         *   leaves with an error code.
   214         */
   215         IMPORT_C static void CreateIconL(
   216             MAknsSkinInstance* aInstance, const TAknsItemID& aID,
   217             CFbsBitmap*& aBitmap, CFbsBitmap*& aMask,
   218             const TDesC& aFilename,
   219             const TInt aFileBitmapId, const TInt aFileMaskId );
   220 
   221         /**
   222         * Otherwise identical to CreateIconL, but leaves both the bitmaps
   223         * in the cleanup stack.
   224         * The order in which they are pushed into the stack and types of 
   225         * the items in the stack are both undefined.
   226         *
   227         * @copydoc AknsUtils::CreateIconL(MAknsSkinInstance*,TAknsItemID&,CFbsBitmap*&,CFbsBitmap*&,const TDesC&,const TInt,const TInt)
   228         *
   229         * @par Note:
   230         *   Since both the bitmaps are left in the cleanup stack,
   231         *   call to this method can not be enclosed in an immediate TRAP.
   232         */
   233         IMPORT_C static void CreateIconLC(
   234             MAknsSkinInstance* aInstance, const TAknsItemID& aID,
   235             CFbsBitmap*& aBitmap, CFbsBitmap*& aMask,
   236             const TDesC& aFilename,
   237             const TInt aFileBitmapId, const TInt aFileMaskId );
   238 
   239         /**
   240         * Constructs an independent non-masked bitmap with fallback support.
   241         * Creates an independent (in terms of instance ownership) copy of a 
   242         * non-masked bitmap by the given item ID.
   243         *
   244         * If no matching item is found in the currently activate skin,
   245         * attempts to construct the item using the given file.
   246         *
   247         * @since 2.6
   248         *
   249         * @lib AknSkins.lib
   250         *
   251         * @param aInstance Pointer to the current skin instance.
   252         *   Usually retrieved using @c AknsUtils::SkinInstance.
   253         *
   254         * @param aID Item ID of the non-masked bitmap to be created.
   255         *
   256         * @param aBitmap If method succeeds, set to point to the
   257         *   newly constructed bitmap. Ownership of the bitmap is transferred 
   258         *   to the caller.
   259         *
   260         * @param aFilename Filename to be used to construct the item, 
   261         *   if no matching item was found in the currently active skin.
   262         *
   263         * @param aFileBitmapId ID of the bitmap in the file. 
   264         *   Used only if no matching item was found in the currently 
   265         *   active skin.
   266         *
   267         * @par Exceptions:
   268         *   If data construction fails or bitmap is not found, the function
   269         *   leaves with an error code.
   270         */
   271         IMPORT_C static void CreateIconL(
   272             MAknsSkinInstance* aInstance, const TAknsItemID& aID,
   273             CFbsBitmap*& aBitmap,
   274             const TDesC& aFilename,
   275             const TInt aFileBitmapId );
   276 
   277         /**
   278         * Otherwise identical to CreateIconL, but leaves the bitmap
   279         * in the cleanup stack.
   280         * The type of the item pushed into the stack is undefined.
   281         *
   282         * @copydoc AknsUtils::CreateIconL(MAknsSkinInstance*,TAknsItemID&,CFbsBitmap*&,const TDesC&,const TInt)
   283         *
   284         * @par Note:
   285         *   Since the bitmap is left in the cleanup stack,
   286         *   call to this method can not be enclosed in an immediate TRAP.
   287         */
   288         IMPORT_C static void CreateIconLC(
   289             MAknsSkinInstance* aInstance, const TAknsItemID& aID,
   290             CFbsBitmap*& aBitmap,
   291             const TDesC& aFilename,
   292             const TInt aFileBitmapId );
   293 
   294         /**
   295         * Constructs an independent masked bitmap with fallback support.
   296         * Creates an independent (in terms of instance ownership) copy of a 
   297         * masked bitmap by the given item ID.
   298         *
   299         * If no matching item is found in the currently activate skin,
   300         * attempts to construct the item using the given file.
   301         *
   302         * @since 2.6
   303         *
   304         * @lib AknSkins.lib
   305         *
   306         * @param aInstance Pointer to the current skin instance.
   307         *
   308         * @param aID Item ID of the masked bitmap to be created.
   309         *
   310         * @param aFilename Filename to be used to construct the item, 
   311         *   if no matching item was found in the currently active skin.
   312         *
   313         * @param aFileIndex Index (for bitmap) in the file. 
   314         *   Used only if no matching item was found in the currently 
   315         *   active skin.
   316         *
   317         * @param aFileMaskIndex Index (for mask) in the file.
   318         *   Used only if no matching item was found in the currently 
   319         *   active skin.
   320         *
   321         * @return Pointer to the newly created CApaMaskedBitmap object.
   322         *   Ownership of the object is transferred to the caller.
   323         *
   324         * @par Exceptions:
   325         *   If data construction fails or bitmap is not found, the function
   326         *   leaves with an error code.
   327         *
   328         * @par Note:
   329         *   Since @c CApaMaskedBitmap can not be used to store scalable
   330         *   graphics, consider using @c CreateIconLC instead.
   331         */
   332         IMPORT_C static CApaMaskedBitmap* CreateMaskedBitmapL(
   333             MAknsSkinInstance* aInstance, const TAknsItemID& aID,
   334             const TDesC& aFilename,
   335             const TInt aFileIndex, const TInt aFileMaskIndex );
   336 
   337         /**
   338         * Constructs an independent CGulIcon object with fallback support.
   339         * Creates an independent (in terms of instance ownership) copy of a
   340         * masked bitmap by the given item ID, and returns it as a
   341         * newly constructed CGulIcon object.
   342         *
   343         * If no matching item is found in the currently active skin,
   344         * attempts to construct the item using the given file.
   345         *
   346         * @since 2.6
   347         *
   348         * @lib AknSkins.lib
   349         *
   350         * @param aInstance Pointer to the current skin instance.
   351         *
   352         * @param aID Item ID of the masked bitmap to be created.
   353         *
   354         * @param aFilename Filename to be used to construct the item, 
   355         *   if no matching item was found in the currently active skin.
   356         *
   357         * @param aFileIndex Index (for bitmap) in the file. 
   358         *   Used only if no matching item was found in the currently 
   359         *   active skin.
   360         *
   361         * @param aFileMaskIndex Index (for mask) in the file.
   362         *   Used only if no matching item was found in the currently 
   363         *   active skin.
   364         *
   365         * @return Pointer to the newly created CGulIcon object.
   366         *   Ownership of the object is transferred to the caller.
   367         *
   368         * @par Exceptions:
   369         *   If data construction fails or bitmap is not found, the function
   370         *   leaves with an error code.
   371         */
   372         IMPORT_C static CGulIcon* CreateGulIconL(
   373             MAknsSkinInstance* aInstance, const TAknsItemID& aID,
   374             const TDesC& aFilename,
   375             const TInt aFileIndex, const TInt aFileMaskIndex );
   376 
   377         /**
   378         * Constructs an application icon supporting scalable graphics.
   379         *
   380         * This method is fallback-enabled. If no icon is found in the 
   381         * currently active skin, the application icon is retrieved using
   382         * application resource file or AIF.
   383         *
   384         * After successful completion, the method leaves both the bitmaps
   385         * in the cleanup stack.
   386         * The order in which they are pushed into the stack and types of 
   387         * the items in the stack are both undefined.
   388         *
   389         * The caller must set the size of the returned bitmaps. 
   390         * See @c AknIconUtils for details.
   391         *
   392         * @par Note:
   393         *   Since both the bitmaps are left in the cleanup stack,
   394         *   call to this method can not be enclosed in an immediate TRAP. 
   395         *
   396         * @since 2.8
   397         *
   398         * @lib AknSkins.lib
   399         *
   400         * @param aInstance Pointer to current skin instance.
   401         *
   402         * @param aAppUid Application UID. Icon is searched with major IID
   403         *   ::EAknsIIDMajorAppIcon and minor IID aAppUid.
   404         * 
   405         * @param aType Type of the application icon (list or context).
   406         *   This parameter is tentative. If no icon of the given type
   407         *   is found, the other icon is returned. Only the following values
   408         *   are allowed: EAknsAppIconTypeList and EAknsAppIconTypeContext.
   409         *
   410         * @param aBitmap If method succeeds, set to point to the
   411         *   newly constructed bitmap. Ownership of the bitmap is transferred 
   412         *   to the caller.
   413         *
   414         * @param aMask If method succeeds, set to point to the newly
   415         *   constructed mask bitmap. Ownership of the bitmap is transferred
   416         *   to the caller.
   417         *
   418         * @par Exceptions:
   419         *   If the method fails, it leaves with a standard error code.
   420         */
   421         IMPORT_C static void CreateAppIconLC(
   422             MAknsSkinInstance* aInstance, TUid aAppUid,
   423             TAknsAppIconType aType,
   424             CFbsBitmap*& aBitmap, CFbsBitmap*& aMask );
   425 
   426         /**
   427         * Opens the file containing application icon data.
   428         *
   429         * This method first checks whether there is a data file of the given
   430         * type associated with the application icon of the given UID. If no 
   431         * file is found, an error code is returned and the caller should use 
   432         * @c CreateAppIconLC to construct the icon. Otherwise, one of the 
   433         * associated files is opened using the given @c RFile object.
   434         *
   435         * @since 3.0
   436         *
   437         * @lib AknSkins.lib
   438         *
   439         * @param aInstance Pointer to current skin instance.
   440         *
   441         * @param aAppUid Application UID. Icon is searched with major IID
   442         *   ::EAknsIIDMajorAppIcon and minor IID aAppUid.
   443         *
   444         * @param aType Only EAknsAppIconType3D is allowed.
   445         *
   446         * @param aFile Reference to a @c RFile. If @c KErrNone is returned,
   447         *   this handle refers to an open file containing the data.
   448         *   If an error code is returned, the file is not opened.
   449         *
   450         * @return @c KErrNone if a file was opened, an error code otherwise.
   451         */
   452         IMPORT_C TInt OpenAppIconFile(
   453             MAknsSkinInstance* aInstance, TUid aAppUid,
   454             TAknsAppIconType aType, RFile& aFile );
   455 
   456         /**
   457         * Constructs an independent masked color-customized icon with 
   458         * fallback support without setting its size.
   459         *
   460         * Creates an independent (in terms of instance ownership) copy of a 
   461         * masked bitmap by the given item ID and applies color-based
   462         * skinning to it.
   463         *
   464         * This method:
   465         *  - Creates a masked bitmap item from skin, or from the given
   466         *    MBM or MIF file if no matching item is found in the active skin.
   467         *  - If the icon can be color-skinned, applies the color retrieved
   468         *    from the given color table and index. If no color information
   469         *    is found in the active skin, uses the given fallback color value.
   470         *  - Returns the resulting bitmaps. If no color skinning was applied,
   471         *    returns the original bitmaps.
   472         *
   473         * The method fails only, if the masked bitmap can not be constructed
   474         * at all. If the icon can not be color-skinned, it is returned as-is.
   475         *
   476         * @since 2.6
   477         *
   478         * @lib AknSkins.lib
   479         *
   480         * @param aInstance Pointer to the current skin instance.
   481         *   Usually retrieved using @c AknsUtils::SkinInstance.
   482         *
   483         * @param aID Item ID of the masked bitmap to be created.
   484         *
   485         * @param aColorID Item ID of the color table.
   486         *
   487         * @param aColorIndex Index in the color table.
   488         *
   489         * @param aBitmap If method succeeds, set to point to the
   490         *   newly constructed bitmap. Ownership of the bitmap is transferred 
   491         *   to the caller.
   492         *
   493         * @param aMask If method succeeds, set to point to the newly
   494         *   constructed mask bitmap. Ownership of the bitmap is transferred
   495         *   to the caller.
   496         *
   497         * @param aFilename Filename to be used to construct the item, 
   498         *   if no matching item was found in the currently active skin.
   499         *
   500         * @param aFileBitmapId ID of the bitmap in the file. 
   501         *   Used only if no matching item was found in the currently 
   502         *   active skin.
   503         *
   504         * @param aFileMaskId ID of the mask in the file.
   505         *   Used only if no matching item was found in the currently
   506         *   active skin.
   507         *
   508         * @param aDefaultColor Color RGB value to be used, if no color
   509         *   is found in the currently active skin.
   510         *
   511         * @par Exceptions:
   512         *   If data construction fails or bitmap is not found, the function
   513         *   leaves with an error code.
   514         */
   515         IMPORT_C static void CreateColorIconL(
   516             MAknsSkinInstance* aInstance, const TAknsItemID& aID,
   517             const TAknsItemID& aColorID, const TInt aColorIndex,
   518             CFbsBitmap*& aBitmap, CFbsBitmap*& aMask,
   519             const TDesC& aFilename,
   520             const TInt aFileBitmapId, const TInt aFileMaskId,
   521             const TRgb aDefaultColor );
   522 
   523         /**
   524         * Otherwise identical to @c CreateColorIconL, but leaves both the 
   525         * bitmap and the mask in the cleanup stack. 
   526         * The order in which they are pushed into the stack and types of 
   527         * the items in the stack are both undefined.
   528         *
   529         * @since 2.6
   530         *
   531         * @lib AknSkins.lib
   532         *
   533         * @par Note:
   534         *   Since two bitmaps are left in the cleanup stack,
   535         *   call to this method can not be enclosed in an immediate TRAP.
   536         */
   537         IMPORT_C static void CreateColorIconLC(
   538             MAknsSkinInstance* aInstance, const TAknsItemID& aID,
   539             const TAknsItemID& aColorID, const TInt aColorIndex,
   540             CFbsBitmap*& aBitmap, CFbsBitmap*& aMask,
   541             const TDesC& aFilename,
   542             const TInt aFileBitmapId, const TInt aFileMaskId,
   543             const TRgb aDefaultColor );
   544 
   545         /**
   546         * Otherwise identical to @c CreateColorIconL without size parameters,
   547         * but calls @c SetSize to set the size of the resulting icon.
   548         *
   549         * @since 2.8
   550         *
   551         * @lib AknSkins.lib
   552         */
   553         IMPORT_C static void CreateColorIconL(
   554             MAknsSkinInstance* aInstance, const TAknsItemID& aID,
   555             const TAknsItemID& aColorID, const TInt aColorIndex,
   556             CFbsBitmap*& aBitmap, CFbsBitmap*& aMask,
   557             const TDesC& aFilename,
   558             const TInt aFileBitmapId, const TInt aFileMaskId,
   559             const TRgb aDefaultColor,
   560             const TSize& aSize, const TScaleMode aScaleMode );
   561 
   562         /**
   563         * Otherwise identical to @c CreateColorIconL, but leaves both the 
   564         * bitmap and the mask in the cleanup stack. 
   565         * The order in which they are pushed into the stack and types of 
   566         * the items in the stack are both undefined.
   567         *
   568         * @since 2.8
   569         *
   570         * @lib AknSkins.lib
   571         *
   572         * @par Note:
   573         *   Since two bitmaps are left in the cleanup stack,
   574         *   call to this method can not be enclosed in an immediate TRAP.
   575         */
   576         IMPORT_C static void CreateColorIconLC(
   577             MAknsSkinInstance* aInstance, const TAknsItemID& aID,
   578             const TAknsItemID& aColorID, const TInt aColorIndex,
   579             CFbsBitmap*& aBitmap, CFbsBitmap*& aMask,
   580             const TDesC& aFilename,
   581             const TInt aFileBitmapId, const TInt aFileMaskId,
   582             const TRgb aDefaultColor,
   583             const TSize& aSize, const TScaleMode aScaleMode );
   584 
   585     public: // New functions - Item access w/o support for scalable graphics
   586 
   587         /**
   588         * Constructs an application icon. Icon bitmaps are duplicated to the 
   589         * given CApaMaskedBitmap object.
   590         *
   591         * Since Series 60 Release 2.6, this method is fallback-enabled.
   592         * If no icon is found in the currently active skin, it uses
   593         * AppArch to construct the icon.
   594         *
   595         * @since 2.0
   596         *
   597         * @param aInstance Pointer to current skin instance.
   598         *
   599         * @param aAppUid Application UID. Icon is searched with major IID
   600         *   ::EAknsIIDMajorAppIcon and minor IID aAppUid. AppArch search
   601         *   is always performed with UID only.
   602         *
   603         * @param aSize Maximum size of the icon.
   604         *
   605         * @param aAppBitmap On return contains the icon.
   606         *
   607         * @return KErrNone if succeeded, KErrNotFound if no icon was found
   608         *   or size requirements were not met, other error code if
   609         *   another error occured.
   610         *
   611         * @par Note:
   612         *   This method does not support scalable graphics.
   613         *   Consider using @c CreateAppIconLC instead.
   614         */
   615         IMPORT_C static TInt GetAppIcon(
   616             MAknsSkinInstance* aInstance, TUid aAppUid, TSize aSize, 
   617             CApaMaskedBitmap& aAppBitmap );
   618 
   619     public: // New functions - Item access w/ ownership
   620 
   621         /**
   622         * Constructs an independent bitmap.
   623         * Creates an independent copy of bitmap (in terms of instance ownership)
   624         * by given item ID.
   625         *
   626         * @since 2.0
   627         *
   628         * @param aInstance Pointer to current skin instance.
   629         *
   630         * @param aID Item ID of the bitmap to be created.
   631         *
   632         * @return Pointer to the newly created bitmap. Ownership of the object
   633         *   is transferred to the caller.
   634         *
   635         * @par Exceptions:
   636         *   - If data construction fails or bitmap is not found, function
   637         *     leaves with an error code.
   638         */
   639         IMPORT_C static CFbsBitmap* CreateBitmapL( 
   640             MAknsSkinInstance* aInstance, const TAknsItemID& aID );
   641 
   642         /**
   643         * Constructs an independent masked bitmap.
   644         * Creates an independent (in terms of instance ownership) copy of a 
   645         * masked bitmap by the given item ID.
   646         *
   647         * Alternatively, masked bitmaps can be retrieved by using
   648         * @c MAknsSkinInstance::GetCachedItemData(TAknsItemID,TAknsItemType)
   649         * or
   650         * @c MAknsSkinInstance::CreateUncachedItemDataL(TAknsItemID,TAknsItemType)
   651         * methods. For these, @c ::EAknsITMaskedBitmap should be given as the
   652         * second parameter. Returned @c CAknsItemData pointer can be casted
   653         * to a @c CAknsMaskedBitmapItemData pointer in order to get access
   654         * to the bitmap objects themselves.
   655         *
   656         * @par Note:
   657         *   This method does not have fallback support (to load the bitmap from
   658         *   the specified file in case it is not available in the current 
   659         *   skin). Consider using one of the fallback-enabled overloads 
   660         *   instead.
   661         *
   662         * @since 2.0
   663         *
   664         * @param aInstance Pointer to the current skin instance.
   665         *
   666         * @param aID Item ID of the masked bitmap to be created.
   667         *
   668         * @return Pointer to the newly created CApaMaskedBitmap object.
   669         *   Ownership of the object is transferred to the caller.
   670         *
   671         * @par Exceptions:
   672         *   If data construction fails or bitmap is not found, the function
   673         *   leaves with an error code.
   674         *
   675         * @par Note:
   676         *   Since @c CApaMaskedBitmap can not be used to store scalable
   677         *   graphics, consider using @c CreateIconLC instead.
   678         */
   679         IMPORT_C static CApaMaskedBitmap* CreateMaskedBitmapL(
   680             MAknsSkinInstance* aInstance, const TAknsItemID& aID );
   681 
   682         /**
   683         * Constructs an independent CGulIcon object.
   684         * Creates an independent (in terms of instance ownership) copy of a
   685         * bitmap or a masked bitmap by the given item ID, and returns it as a
   686         * newly constructed CGulIcon object.
   687         *
   688         * @par Note:
   689         *   This method does not have fallback support (to load the bitmap from
   690         *   the specified file in case it is not available in the current 
   691         *   skin). Consider using one of the fallback-enabled overloads 
   692         *   instead.
   693         *
   694         * @since 2.1
   695         *
   696         * @lib AknSkins.lib
   697         *
   698         * @param aInstance Pointer to the current skin instance.
   699         *
   700         * @param aID Item ID of the bitmap or masked bitmap to be created.
   701         *
   702         * @param aRequireMask ETrue if masked bitmap is explicitly required.
   703         *   EFalse if mask is optional.
   704         *
   705         * @return Pointer to the newly created CGulIcon object.
   706         *   Ownership of the object is transferred to the caller.
   707         *
   708         * @par Exceptions:
   709         *   If data construction fails or bitmap is not found, the function
   710         *   leaves with an error code.
   711         */
   712         IMPORT_C static CGulIcon* CreateGulIconL(
   713             MAknsSkinInstance* aInstance, const TAknsItemID& aID,
   714             const TBool aRequireMask );
   715 
   716     public: // New functions - Item access w/o ownership
   717 
   718         /**
   719         * Returns pointer to a cached bitmap.
   720         * Retrieves (and constructs if necessary) a bitmap in skin instance
   721         * cache. Caller can use the bitmap temporarily (e.g. in drawing code),
   722         * but should not store pointer to it, since its lifetime is determined
   723         * by cache.
   724         *
   725         * @since 2.0
   726         *
   727         * @param aInstance Pointer to current skin instance. If @c NULL value
   728         *   is specified, method immediately returns with @c NULL return value.
   729         *
   730         * @param aID Item ID of the bitmap to be retrieved.
   731         *
   732         * @return Pointer to the bitmap, or @c NULL if no bitmap with given ID
   733         *   was found or an error occured.
   734         *
   735         * @par Exceptions:
   736         *   - Because the method can not leave, error handling procedure
   737         *     described in 
   738         *     MAknsSkinInstance::GetCachedItemData(const TAknsItemID& aID) is 
   739         *     used if data construction fails.
   740         */
   741         IMPORT_C static CFbsBitmap* GetCachedBitmap( 
   742             MAknsSkinInstance* aInstance, const TAknsItemID& aID );
   743 
   744         /**
   745         * Retrieves temporary pointers to a cached bitmap and its mask.
   746         * Retrieves (and constructs, if necessary) a masked bitmap in the skin
   747         * instance cache. Pointers to the bitmap (and its mask) are stored
   748         * to the pointers given as parameters. Caller can use the bitmaps
   749         * temporarily (e.g. in drawing code), but should not store them, since
   750         * their lifetimes are determined by the cache.
   751         *
   752         * @since 2.1
   753         *
   754         * @param aInstance Pointer to the current skin instance. If @c NULL
   755         *   value is specified, the method assigns @c NULL to both the given
   756         *   pointers and then returns.
   757         *
   758         * @param aID Item ID of the bitmap (or masked bitmap) to be retrieved.
   759         *
   760         * @param aBitmap Reference to the pointer that will receive the bitmap.
   761         *   @c NULL value is assigned if no bitmap with the given ID was found
   762         *   or an error occured.
   763         *
   764         * @param aMask Reference to the pointer that will receive the mask.
   765         *   @c NULL value is assigned if no bitmap with the given ID was found,
   766         *   or the bitmap did not have a mask, or an error occured.
   767         *
   768         * @par Exceptions:
   769         *   - Because the method can not leave, error handling procedure
   770         *     described in 
   771         *     MAknsSkinInstance::GetCachedItemData(const TAknsItemID& aID) is 
   772         *     used if data construction fails.
   773         */
   774         IMPORT_C static void GetCachedMaskedBitmap(
   775             MAknsSkinInstance* aInstance, const TAknsItemID& aID,
   776             CFbsBitmap*& aBitmap, CFbsBitmap*& aMask );
   777 
   778         /**
   779         * Returns a color value from a cached color table.
   780         * Retrieves (and constructs if necessary) a color table in
   781         * skin instance cache and returns a color value from it.
   782         *
   783         * Since release 2.8, this method also handles any backward 
   784         * compatibility operations possibly required.
   785         *
   786         * @since 2.0
   787         *
   788         * @param aInstance Pointer to current skin instance. If @c NULL value
   789         *   is specified, returns KErrNotSupported.
   790         *
   791         * @param aRgb Reference to a TRgb that will receive the color.
   792         *
   793         * @param aID Item ID of the color table.
   794         *
   795         * @param aIndex Index of the color in the color table.
   796         *
   797         * @return KErrNone if successful, otherwise an error code is returned.
   798         */
   799         IMPORT_C static TInt GetCachedColor(
   800             MAknsSkinInstance* aInstance, TRgb& aRgb, const TAknsItemID& aID,
   801             const TInt aIndex );
   802 
   803         /**
   804         * Retrieves the value of the given boolean property skin item.
   805         *
   806         * @since 2.8
   807         *
   808         * @param aInstance Pointer to current skin instance. If @c NULL value
   809         *   is specified, the method leaves.
   810         *
   811         * @param aID Item ID of the boolean property.
   812         *
   813         * @return Value of the boolean property as @c TBool.
   814         *
   815         * @par Exceptions:
   816         *   - If the item is not found, leaves with @c KErrNotFound.
   817         *   - If the item is not a boolean property or another error occures,
   818         *       leaves with a system-wide error code.
   819         */
   820         IMPORT_C static TBool BooleanPropertyL( MAknsSkinInstance* aInstance, 
   821             const TAknsItemID& aID );
   822 
   823         /**
   824         * Test whether the given type is derived from the given base type.
   825         *
   826         * @since 2.0
   827         *
   828         * @param aBaseType Base type.
   829         *
   830         * @param aDerivedType Derived type.
   831         *
   832         * @return ETrue if the type is derived from the base type, EFalse
   833         *   otherwise.
   834         *
   835         * @internal
   836         */
   837         static TBool IsDerivedType( const TAknsItemType aBaseType, 
   838             const TAknsItemType aDerivedType );
   839 
   840     public: // New functions - Avkon parameters
   841 
   842         /**
   843         * Sets the flag indicating whether default skin parameters should
   844         * be used for newly created Avkon controls in the scope of the
   845         * current AppUi. 
   846         *
   847         * @since 2.0
   848         *
   849         * @param Value of the flag as TBool.
   850         *
   851         * @par Exceptions:
   852         *   If construction of the storage object for the flag fails,
   853         *   leaves with an error code.
   854         */
   855         IMPORT_C static void SetAvkonSkinEnabledL( const TBool aEnabled );
   856 
   857         /**
   858         * Queries whether default skin parameters should be used for newly
   859         * created Avkon controls. Components supporting 
   860         * <code>SetSkinEnabledL</code> method should also check for this
   861         * value upon construction and set their internal state accordingly.
   862         *
   863         * Note that this flag is intended to be used to determine whether or
   864         * not controls should create skin backgrounds for main pane
   865         * layouts. Skins are always enabled for e.g. all the popup windows,
   866         * even through the flag may be @c EFalse, and therefore the flag 
   867         * must not be used as a generic "are skins enabled" switch.
   868         *
   869         * Most controls do not (and should not) query the flag value. If
   870         * control just fetches the skin control context with
   871         * @c AknsDrawUtils::ControlContext, it will get the proper @c NULL
   872         * value if no background has been defined.
   873         *
   874         * @since 2.0
   875         *
   876         * @return ETrue if default skin parameters should be used,
   877         *   EFalse otherwise. The default value is EFalse.
   878         */
   879         IMPORT_C static TBool AvkonSkinEnabled();
   880 
   881         /**
   882         * Sets the flag indicating whether highlight animations should be used
   883         * for Avkon list controls in the scope of the current AppUi.
   884         *
   885         * @since 3.0
   886         *
   887         * @param Value of the flag as TBool.
   888         *
   889         * @par Exceptions:
   890         *   If construction of the storage object for the flag fails,
   891         *   leaves with an error code.
   892         */
   893         IMPORT_C static void SetAvkonHighlightAnimationEnabledL( const TBool aEnabled );
   894 
   895         /**
   896         * Queries whether highlight animation should be used for newly created
   897         * Avkon list controls.
   898         *
   899         * @since 3.0
   900         *
   901         * @return ETrue if list highlight animation should be used, EFalse
   902         *         otherwise. The default value is ETrue.
   903         */
   904         IMPORT_C static TBool AvkonHighlightAnimationEnabled();
   905 
   906     public: // New functions - Control position list
   907 
   908         /**
   909         * Registers the position of the given control.
   910         * The position is stored in the thread-local control position list.
   911         * If the control has already been registered, its position is updated.
   912         *
   913         * Registering the position of the control enables background drawing
   914         * methods in AknsDrawUtils to calculate positions in
   915         * parent-absolute layouts without causing window server flushes.
   916         *
   917         * When a registered control goes out of scope, it must call
   918         * AknsUtils::DeregisterControlPosition to ensure that it is properly
   919         * removed from the list.
   920         *
   921         * @since 2.0
   922         *
   923         * @param aControl Pointer to the control that needs its position
   924         *   to be updated in the control position list.
   925         */
   926         IMPORT_C static void RegisterControlPosition( 
   927             const CCoeControl* aControl );
   928 
   929         /**
   930         * Registers the position of the given control with given position.
   931         * The position is stored in the thread-local control position list.
   932         * If the control has already been registered, its position is updated.
   933         *
   934         * Registering the position of the control enables background drawing
   935         * methods in AknsDrawUtils to calculate positions in
   936         * parent-absolute layouts without causing window server flushes.
   937         *
   938         * When a registered control goes out of scope, it must call
   939         * AknsUtils::DeregisterControlPosition to ensure that it is properly
   940         * removed from the list.
   941         *
   942         * @since 2.0
   943         *
   944         * @param aControl Pointer to the control that needs its position
   945         *   to be updated in the control position list.
   946         *
   947         * @param aPoint The new position to be registered with the given
   948         *   control (in screen coordinates).
   949         */
   950         IMPORT_C static void RegisterControlPosition( 
   951             const CCoeControl* aControl, const TPoint& aPoint );
   952 
   953         /**
   954         * Removes the position of the given control from the list.
   955         * The position of the given control is removed from the thread-local
   956         * control position list. If the control has not been registered,
   957         * this method does nothing.
   958         *
   959         * @since 2.0
   960         *
   961         * @param aControl Pointer to the control that needs to be removed
   962         *   from the control position list.
   963         */
   964         IMPORT_C static void DeregisterControlPosition( 
   965             const CCoeControl* aControl );
   966 
   967         /**
   968         * Gets the position of the control registered in the control position
   969         * list.
   970         *
   971         * @param aControl Pointer to the control whose position is to be 
   972         *   queried.
   973         *
   974         * @param aScreenPos Reference to the TPoint that will receive the
   975         *   position.
   976         *
   977         * @return KErrNone if successful, KErrNotFound if the control has
   978         *   not been registered.
   979         */
   980         IMPORT_C static TInt GetControlPosition( const CCoeControl* aControl,
   981             TPoint& aScreenPos );
   982 
   983     private: // Internal methods
   984 
   985         /**
   986         * Gets an application icon from skin.
   987         *
   988         * @since 2.8
   989         *
   990         * @internal
   991         */
   992         static TInt GetAppIconFromSkin(
   993             MAknsSkinInstance* aInstance, TUid aAppUid, TSize aSize, 
   994             CFbsBitmap*& aBitmap, CFbsBitmap*& aMask );
   995 
   996         /** 
   997         * Returns the best application icon bitmap IID among the listed icons.
   998         *
   999         * @since 2.1
  1000         *
  1001         * @param aSize Maximum size.
  1002         *
  1003         * @param aSkin Skin instance.
  1004         *
  1005         * @param aAppIconIID Item ID of the application icon.
  1006         *
  1007         * @return Icon bitmap IID.
  1008         *
  1009         * @internal
  1010         */
  1011         static TAknsItemID SelectBestAppIconBitmapL(
  1012             const TSize& aSize, MAknsSkinInstance* aSkin,
  1013             const TAknsItemID& aAppIconIID );
  1014 
  1015     private: // Reserved exports
  1016 
  1017         /**
  1018         * Reserved for future use.
  1019         *
  1020         * @since 2.0
  1021         *
  1022         * @return Always returns zero.
  1023         */
  1024         IMPORT_C static TInt Reserved();
  1025 
  1026     private: // Prohibited constructors and destructor
  1027         
  1028         // Construction prohibited (static class)
  1029         AknsUtils();
  1030         // Destruction prohibited (static class)
  1031         ~AknsUtils();
  1032     };
  1033 
  1034 #endif      // AKNSUTILS_H   
  1035             
  1036 // End of File