idlehomescreen/widgetmanager/inc/wmimageconverter.h
branchRCL_3
changeset 83 5456b4e8b3a8
child 93 b01126ce0bec
equal deleted inserted replaced
82:5f0182e07bfb 83:5456b4e8b3a8
       
     1 /*
       
     2 * Copyright (c) 2009 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 * CWmImageConverter declaration
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef WMIMAGECONVERTER_H
       
    20 #define WMIMAGECONVERTER_H
       
    21 
       
    22 //includes
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 #include <f32file.h>
       
    26 #include <AknIconUtils.h> // MAknIconFileProvider
       
    27 
       
    28 // Forward declarations
       
    29 class CFbsBitmap;
       
    30 class TAknsItemID;
       
    31 class CWmUnitTest;
       
    32 class MSvgError;
       
    33 
       
    34 // Class declaration
       
    35 /**
       
    36  * CWmImageConverter
       
    37  * Image converter
       
    38  */
       
    39 NONSHARABLE_CLASS ( CWmImageConverter ) : public MAknIconFileProvider
       
    40     {
       
    41 public: //contructors/destructors
       
    42     /**
       
    43      * Two-phased constructor.
       
    44      * @param aObserver observer
       
    45      */
       
    46     static CWmImageConverter* NewL();    
       
    47     
       
    48     /** Destructor */
       
    49     ~CWmImageConverter();
       
    50         
       
    51 public: // interface methods
       
    52     
       
    53     /**
       
    54      * Parses icon string and prepares logo image.
       
    55      * 
       
    56      * @param aIconSize wanted size
       
    57      * @param aIconStr str containing logo icon
       
    58 	 * @param aBitmap bitmap to create. Empty if fails
       
    59 	 * @param aMask mask to create. Empty if fails
       
    60      * Supported values:
       
    61      * - skin(<major id> <minor id>):mif(<path> <bitmapid> <maskid>)
       
    62      * - mif(<path> <bitmapid> <maskid>)
       
    63      * - uid(<application uid>)
       
    64      * - <file name>.<png/svg>
       
    65      * 
       
    66      * @return Error code 
       
    67      */
       
    68     TInt HandleIconString( 
       
    69             const TSize& aIconSize,
       
    70             const TDesC& aIconStr,
       
    71             CFbsBitmap*& aBitmap,
       
    72             CFbsBitmap*& aMask  );
       
    73     
       
    74 	/**
       
    75      * Parses icon string and resizes given bitmaps if needed.
       
    76 	 * Errors are ignored and previos size image will be used.
       
    77      * 
       
    78      * @param aIconSize wanted size
       
    79      * @param aIconStr icon string to find out what to resize
       
    80 	 * @param aBitmap bitmap to resize
       
    81 	 * @param aMask mask to resize
       
    82 	 */
       
    83     void UpdateImageSize( 
       
    84             const TSize& aSize,
       
    85             const TDesC& aIconStr, 
       
    86             CFbsBitmap& aBitmap, 
       
    87             CFbsBitmap& aMask );
       
    88     
       
    89 private:
       
    90     CWmImageConverter(); 
       
    91     void ConstructL();
       
    92 
       
    93 private:
       
    94     void CheckSvgErrorL( MSvgError* aError );
       
    95     void HandleIconStringL( const TSize& aIconSize, const TDesC& aIconStr );
       
    96     
       
    97     void CreateIconFromUidL( const TUid& aUid );
       
    98     void CreateIconFromSvgL( const TDesC& aFileName );
       
    99     void CreateIconFromOtherL( const TDesC& aFileName );
       
   100     void CreateSkinOrMifIconL( 
       
   101                     const TAknsItemID& aItemId, TInt aBitmapId, 
       
   102                     TInt aMaskId, const TDesC& aFileName );
       
   103     // resolvers
       
   104     TBool ResolveUid( const TDesC& aPath, TUid& aUid );
       
   105     TBool ResolveSkinId( const TDesC& aPath, TAknsItemID& aItemId );
       
   106     TBool ResolveMifId( const TDesC& aPath, TInt& aBitmapId, 
       
   107                         TInt& aMaskId, TDes& aFileName );
       
   108     TBool ResolveSkinIdAndMifId( const TDesC& aPath, TAknsItemID& aItemId,
       
   109                         TInt& aBitmapId, TInt& aMaskId, TDes& aFileName );
       
   110     TBool EndsWith( const TDesC& aString, const TDesC& aPattern );
       
   111 
       
   112     // helpers
       
   113     TInt ParseNextUint( TLex& aLex, TUint& aValue );
       
   114     void CopyBitmapL( CFbsBitmap& aTrgBitmap, CFbsBitmap& aSrcBitmap );
       
   115     
       
   116 private: // from MAknIconFileProvider
       
   117 
       
   118     /** Returns an open file handle to the icon file. */
       
   119 	void RetrieveIconFileHandleL( RFile& aFile, const TIconFileType aType );
       
   120     
       
   121     /** Stops using this MAknIconFileProvider instance */
       
   122     void Finished();
       
   123     
       
   124 private:
       
   125     /**
       
   126      * decoded image
       
   127      */
       
   128     CFbsBitmap*             iBitmap;
       
   129     
       
   130     /**
       
   131      * decoded image mask
       
   132      */
       
   133     CFbsBitmap*             iMask;
       
   134 
       
   135     /**
       
   136      * File name to convert
       
   137      */
       
   138     TFileName               iFilename;
       
   139     
       
   140     /**
       
   141      * size to convert
       
   142      */
       
   143     TSize                   iSize;
       
   144 
       
   145     /**
       
   146      * File handle
       
   147      */
       
   148     RFs                     iFs;
       
   149     };
       
   150 
       
   151 #endif // #ifndef WMIMAGECONVERTER_H
       
   152 
       
   153 // end of file