00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef AKN_ICON_UTILS_H
00024 #define AKN_ICON_UTILS_H
00025
00026
00027 #include <e32std.h>
00028 #include <gdi.h>
00029
00030
00031 class CFbsBitmap;
00032 class MAknIconObserver;
00033
00034
00035 enum TScaleMode
00036 {
00037
00038
00039
00040
00041
00042
00043
00044 EAspectRatioPreserved = 0,
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 EAspectRatioPreservedAndUnusedSpaceRemoved = 1,
00058
00059
00060
00061
00062
00063 EAspectRatioNotPreserved = 2,
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 EAspectRatioPreservedSlice = 3
00075 };
00076
00077
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;
00185 CFbsBitmap* iMask;
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
00755 #endif
00756
00757