akniconutils.h

Go to the documentation of this file.
00001 /*
00002 * ==============================================================================
00003 *  Name        : AknIconUtils.h
00004 *  Part of     : AknIcon
00005 *  Interface   : AknIcon
00006 *  Description : Utility functions related to scalable icons.
00007 *
00008 *  Version     : 1
00009 *
00010 *  Copyright (c) 2002 Nokia Corporation.
00011 *  This material, including documentation and any related 
00012 *  computer programs, is protected by copyright controlled by 
00013 *  Nokia Corporation. All rights are reserved. Copying, 
00014 *  including reproducing, storing, adapting or translating, any 
00015 *  or all of this material requires the prior written consent of 
00016 *  Nokia Corporation. This material also contains confidential 
00017 *  information which may not be disclosed to others without the 
00018 *  prior written consent of Nokia Corporation.
00019 * ==============================================================================
00020 */
00021 
00022 
00023 #ifndef AKN_ICON_UTILS_H
00024 #define AKN_ICON_UTILS_H
00025 
00026 // INCLUDES
00027 #include <e32std.h>
00028 #include <gdi.h>
00029 
00030 // FORWARD DECLARATIONS
00031 class CFbsBitmap;
00032 class MAknIconObserver;
00033 
00034 // ENUMERATIONS
00035 enum TScaleMode
00036     {
00037     /*
00038     * Scales the icon to the maximum size that fits in the given size,
00039     * whilst preserving the aspect ratio of the icon. The sizes of the resulting
00040     * bitmaps are exactly of the given size. If the aspect ratio of
00041     * the given size differs from the aspect ratio of the icon,
00042     * the resulting bitmaps will contain an unused area.
00043     */
00044     EAspectRatioPreserved = 0,
00045 
00046     /*
00047     * Scales the icon to the maximum size that fits in the given size,
00048     * whilst preserving the aspect ratio of the icon. The resulting bitmaps
00049     * are resized so that any unused portion of the given size is not
00050     * present in them.
00051     *
00052     * This mode should be used when only the height or the width of the icon
00053     * is known and the other should be based on the aspect ratio of the icon.
00054     * The unknown dimension should be defined high enough (e.g. KMaxTInt) so
00055     * that it does not limit the scaling based on the aspect ratio of the icon.
00056     */
00057     EAspectRatioPreservedAndUnusedSpaceRemoved = 1,
00058 
00059     /*
00060     * Scales the icon exactly to the given size. Does not preserve the aspect
00061     * ratio of the icon.
00062     */
00063     EAspectRatioNotPreserved = 2,
00064         
00065     /*
00066     * Scales the icon to the minimum size that covers the given size,
00067     * whilst preserving the aspect ratio of the icon. The sizes of the resulting
00068     * bitmaps are exactly of the given size. If the aspect ratio of
00069     * the given size differs from the aspect ratio of the icon, some parts of the 
00070     * icon will be sliced from the resulting bitmaps.
00071     *
00072     * 
00073     */
00074     EAspectRatioPreservedSlice = 3
00075     };
00076 
00077 // CLASS DECLARATIONS
00078 
00082 class TAknContentDimensions
00083         {
00084         public:
00085 
00089         inline TAknContentDimensions(); 
00090 
00097         inline TAknContentDimensions(TReal32 aWidth, TReal32 aHeight);
00098 
00105         inline void SetDimensions(TReal32 aWidth, TReal32 aHeight);     
00106  
00113         inline void SetDimensions(const TSize& aDimensions);    
00114 
00115         public:
00116     
00118         TReal32 iWidth;
00119 
00121                 TReal32 iHeight;
00122         };
00123 
00127 NONSHARABLE_CLASS(CAknIcon) : public CBase
00128     {
00129     public:
00130     
00138         IMPORT_C static CAknIcon* NewL();
00139     
00143         ~CAknIcon();
00144     
00145     public:
00146     
00152         IMPORT_C CFbsBitmap* Bitmap() const;
00153     
00159         IMPORT_C CFbsBitmap* Mask() const;
00160     
00166         IMPORT_C void SetBitmap( CFbsBitmap* aBitmap );
00167     
00173         IMPORT_C void SetMask( CFbsBitmap* aMask );
00174     
00175     private:
00176     
00180         inline CAknIcon() {}
00181 
00182     private:
00183     
00184         CFbsBitmap* iBitmap; // owned
00185         CFbsBitmap* iMask; // owned
00186     };
00187 
00198 class MAknIconFileProvider
00199     {
00200     public:
00201 
00202         enum TIconFileType
00203             {
00204             EMbmFile = 0,
00205             EMifFile = 1
00206             };
00207 
00208     public:
00209 
00213         virtual ~MAknIconFileProvider() {}
00214 
00230         virtual void RetrieveIconFileHandleL(
00231             RFile& aFile, const TIconFileType aType ) = 0;
00232 
00245         virtual void Finished() = 0;
00246     };
00247 
00259 class AknIconUtils
00260     {
00261     public:
00262 
00281         IMPORT_C static void CreateIconL(
00282             CFbsBitmap*& aBitmap,
00283             CFbsBitmap*& aMask,
00284             const TDesC& aFileName,
00285             TInt aBitmapId,
00286             TInt aMaskId );
00287 
00305         IMPORT_C static void CreateIconLC(
00306             CFbsBitmap*& aBitmap,
00307             CFbsBitmap*& aMask,
00308             const TDesC& aFileName,
00309             TInt aBitmapId,
00310             TInt aMaskId );
00311 
00325         IMPORT_C static CFbsBitmap* CreateIconL(
00326             const TDesC& aFileName,
00327             TInt aBitmapId );
00328 
00349         IMPORT_C static void CreateIconL(
00350             CFbsBitmap*& aBitmap,
00351             CFbsBitmap*& aMask,
00352             MAknIconFileProvider& aFileProvider,
00353             TInt aBitmapId,
00354             TInt aMaskId );
00355 
00375         IMPORT_C static void CreateIconLC(
00376             CFbsBitmap*& aBitmap,
00377             CFbsBitmap*& aMask,
00378             MAknIconFileProvider& aFileProvider,
00379             TInt aBitmapId,
00380             TInt aMaskId );
00381 
00397         IMPORT_C static CFbsBitmap* CreateIconL(
00398             MAknIconFileProvider& aFileProvider,
00399             TInt aBitmapId );
00400 
00423         IMPORT_C static void PreserveIconData( CFbsBitmap* aBitmap );
00424 
00433         IMPORT_C static void DestroyIconData( CFbsBitmap* aBitmap );
00434 
00450         IMPORT_C static TInt SetSize(
00451             CFbsBitmap* aBitmap,
00452             const TSize& aSize,
00453             TScaleMode aMode = EAspectRatioPreserved );
00454 
00471         IMPORT_C static TInt SetSizeAndRotation(
00472             CFbsBitmap* aBitmap,
00473             const TSize& aSize,
00474             TScaleMode aMode,
00475             TInt aAngle );
00476 
00488         IMPORT_C static void SetObserver( CFbsBitmap* aBitmap, MAknIconObserver* aObserver );
00489 
00496         IMPORT_C static const TDesC& AvkonIconFileName();
00497 
00511         IMPORT_C static void ValidateLogicalAppIconId( 
00512             const TDesC& aIconFileName,
00513             TInt& aBitmapId,
00514             TInt& aMaskId );
00515 
00525         IMPORT_C static TBool IsMifFile( const TDesC& aFileName );
00526 
00537         IMPORT_C static TBool IsMifIcon( const CFbsBitmap* aBitmap );
00538 
00555         IMPORT_C static TInt GetContentDimensions(
00556             CFbsBitmap* aBitmap,
00557             TSize& aContentDimensions );
00558             
00574         IMPORT_C static TInt GetContentDimensions(
00575             CFbsBitmap* aBitmap,
00576             TAknContentDimensions& aContentDimensions );
00577             
00578 
00610         IMPORT_C static CAknIcon* CreateIconL( CAknIcon* aSourceIcon );
00611 
00627         IMPORT_C static CFbsBitmap* CreateIconL( CFbsBitmap* aSourceBitmap );
00628 
00639         IMPORT_C static void SetIconColor( CFbsBitmap* aBitmap, const TRgb aColor );
00640         
00641         
00664         IMPORT_C static void ExcludeFromCache( CFbsBitmap* aBitmap );
00665         
00677         IMPORT_C static void DisableCompression( CFbsBitmap* aBitmap );
00678         
00679 
00684         static void ScaleBitmapL( 
00685             const TRect& aTrgRect,
00686             CFbsBitmap* aTrgBitmap,
00687             CFbsBitmap* aSrcBitmap );
00688 
00707         static void RotateAndScaleBitmapL(
00708             const TRect& aTrgRect,
00709             CFbsBitmap* aTrgBitmap, 
00710             CFbsBitmap* aSrcBitmap,
00711             TInt aAngle );
00712 
00713     private:
00714 
00723         static TBool IsAknBitmap( const CFbsBitmap* aBitmap );
00724         
00728         static void CreateIconLC(
00729             CFbsBitmap*& aBitmap,
00730             CFbsBitmap*& aMask,
00731             const TDesC& aFileName,
00732             TInt aBitmapId,
00733             TInt aMaskId,
00734             MAknIconFileProvider* aFileProvider );
00735 
00740         static void CreateIconLC(
00741             CFbsBitmap*& aBitmap,
00742             CFbsBitmap*& aMask,
00743             const TDesC& aFileName,
00744             TInt aBitmapId,
00745             TInt aMaskId,
00746             RFile& aFile );
00747         
00748     private:
00749 
00750         AknIconUtils();
00751     };
00752 
00753 #include "AknIconUtils.inl"
00754 // AKN_ICON_UTILS_H
00755 #endif
00756             
00757 // End of File

Copyright © Nokia Corporation 2001-2008
Back to top