|
1 /* |
|
2 * Copyright (c) 2002 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: CAknIconManager class. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef AKN_ICON_MANAGER_H |
|
22 #define AKN_ICON_MANAGER_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32std.h> |
|
26 #include <fbs.h> |
|
27 #include "AknIconObserver.h" |
|
28 #include "AknIconUtils.h" |
|
29 #include "AknIconSrvDef.h" |
|
30 // CONSTANTS |
|
31 |
|
32 const TInt KExtensionLength = 4; |
|
33 _LIT( KMbmExtension, ".mbm" ); |
|
34 _LIT( KMifExtension, ".mif" ); |
|
35 |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class MAknIconFormatHandler; |
|
39 class CAknBitmap; |
|
40 class CAknIconLoader; |
|
41 struct TAknIconParams; |
|
42 // CLASS DECLARATION |
|
43 |
|
44 /** |
|
45 * class CAknIconManager. |
|
46 * @internal |
|
47 */ |
|
48 NONSHARABLE_CLASS(CAknIconManager) : public CBase, public MAknIconChangeObserver |
|
49 { |
|
50 public: // Constructors and destructor |
|
51 |
|
52 static CAknIconManager* NewL( |
|
53 const TDesC& aFileName, |
|
54 const TInt16 aBitmapId, |
|
55 const TInt16 aMaskId ); |
|
56 |
|
57 /** |
|
58 * Destructor. |
|
59 */ |
|
60 ~CAknIconManager(); |
|
61 |
|
62 public: // New functions |
|
63 |
|
64 /** |
|
65 * Loads MBM icons. |
|
66 * Sets MIF icon handles to valid empty CFbsBitmap handles. |
|
67 */ |
|
68 void PreinitializeIconL(); |
|
69 |
|
70 TInt InitializeIcon( const TSize& aSize, TScaleMode aMode ); |
|
71 |
|
72 TInt InitializeIcon( |
|
73 const TSize& aSize, |
|
74 TScaleMode aMode, |
|
75 TInt aAngle ); |
|
76 |
|
77 TInt GetContentDimensions( TAknContentDimensions& aContentDimensions ); |
|
78 |
|
79 void PreserveIconData(); |
|
80 void DestroyIconData(); |
|
81 |
|
82 void SetIconColor( const TRgb aColor ); |
|
83 TRgb GetIconColor() const; |
|
84 void GetFileName( TDes& aFileName ) const; |
|
85 void GetFullFileName( TDes& aFileName ) const; |
|
86 void GetFullMifFileName( TDes& aFileName ) const; |
|
87 inline TInt BitmapId() const; |
|
88 inline TInt MaskId() const; |
|
89 |
|
90 inline void GetInitializedParams( TAknIconParams& aInfo ) const; |
|
91 inline void SetInitializedParams( const TAknIconParams& aInfo ); |
|
92 |
|
93 void Ref(); |
|
94 void Unref(const CAknBitmap& aBitmap); |
|
95 |
|
96 void SetBitmap( CAknBitmap* aBitmap ); |
|
97 void SetMask( CAknBitmap* aMask ); |
|
98 |
|
99 void SetObserver( MAknIconObserver* aObserver ); |
|
100 TBool IsMbmIcon() const; |
|
101 TInt IconIdToIndex( TInt aId ) const; |
|
102 inline TBool IsDefaultIconDirUsed() const; |
|
103 inline void SetDefaultIconDirUsed(); |
|
104 inline TBool IsExcludedFromCache() const; |
|
105 inline void ExcludeFromCache(); |
|
106 inline TBool IsCompressionDisabled() const; |
|
107 inline void DisableCompression(); |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 TInt ScaleMode() const; |
|
113 TInt Check(const TSize& aSize,TScaleMode aMode,TInt aAngle=0); |
|
114 |
|
115 protected: |
|
116 |
|
117 /** |
|
118 * This is called, when the file handle is no longer required, |
|
119 * and should be closed. |
|
120 */ |
|
121 virtual void ReleaseFileHandle(); |
|
122 |
|
123 /* |
|
124 * Initalizes iFileName member. |
|
125 * Note: This function must be called in ConstructL! |
|
126 */ |
|
127 void InitIconFileNameL( const TDesC& aFileName ); |
|
128 |
|
129 inline TBool IsIconDataPreserved() const; |
|
130 inline void SetIconDataPreserved(); |
|
131 inline void ClearIconDataPreserved(); |
|
132 inline TBool IsAnimated() const; |
|
133 inline void SetAnimated(); |
|
134 inline TBool IsFileExtRemoved() const; |
|
135 inline void SetFileExtRemoved(); |
|
136 inline TBool IsCompressionDisabledCleanUp() const; |
|
137 inline void SetDisableCompressionCleanUp(); |
|
138 inline void ClearDisableCompressionCleanUp(); |
|
139 inline TBool IsAppIcon() const; |
|
140 inline void SetAppIcon(TBool aAppIcon); |
|
141 inline TBool GetAppIcon() const; |
|
142 private: // from MAknIconChangeObserver |
|
143 void BitmapChanged(); |
|
144 |
|
145 private: // New functions |
|
146 |
|
147 /** |
|
148 * Loads icon from MBM file if it is a bitmap icon. |
|
149 */ |
|
150 void LoadIfBitmapIconL(); |
|
151 |
|
152 /** |
|
153 * Checks if the icon is already initialized with the given parameters, |
|
154 * and if not, initializes it. |
|
155 */ |
|
156 void InitializeIconL( |
|
157 const TSize& aSize, |
|
158 TScaleMode aMode, |
|
159 TInt aAngle ); |
|
160 |
|
161 /** |
|
162 * Initializes the icon with the given parameters. |
|
163 */ |
|
164 virtual void DoInitializeIconL( |
|
165 const TSize& aSize, |
|
166 TScaleMode aMode, |
|
167 TInt aAngle ); |
|
168 |
|
169 /** |
|
170 * Returns opened file handle to the icon file, |
|
171 * if such is supplied by the client. |
|
172 */ |
|
173 virtual RFile* FileHandleL( MAknIconFileProvider::TIconFileType aType ); |
|
174 |
|
175 /** |
|
176 * Loads a bitmap icon. |
|
177 */ |
|
178 virtual void LoadBitmapIconL(); |
|
179 |
|
180 |
|
181 inline TBool HasValidFileExtension( const TDesC& aFileName ) const; |
|
182 void ChangeFileExtension( TDes& aFileName ) const; |
|
183 void AppendFileExtension( TDes& aFileName ) const; |
|
184 void InitializeAnimatedIconL( const TAknIconParams& aInfo ); |
|
185 |
|
186 /** |
|
187 * Cleanup function that calls ReleaseFileHandle. |
|
188 */ |
|
189 static void CleanupReleaseFileHandle( TAny* aParam ); |
|
190 |
|
191 CAknIconLoader* PrepareAnimatedIconLC(); |
|
192 |
|
193 void PrepareAnimatedIconL(TBool bAnimationReady = EFalse); |
|
194 |
|
195 void GetContentDimensionsL( TAknContentDimensions& aContentDimensions ); |
|
196 |
|
197 void HandleError( TInt aError ); |
|
198 |
|
199 void RetrieveIconLocationInfoL(); |
|
200 |
|
201 void LoadIconLocationInfoL( const TDesC& aFileName ); |
|
202 |
|
203 RFile* FileHandleL(); |
|
204 |
|
205 inline void DeleteIconFormatHandler(); |
|
206 |
|
207 protected: // Protected constructors |
|
208 /** |
|
209 * C++ default constructor. |
|
210 */ |
|
211 CAknIconManager(); |
|
212 |
|
213 private: |
|
214 /** |
|
215 * 2nd phase constructor. |
|
216 */ |
|
217 void ConstructL( |
|
218 const TDesC& aFileName, |
|
219 const TInt16 aBitmapId, |
|
220 const TInt16 aMaskId ); |
|
221 |
|
222 protected: // Data |
|
223 |
|
224 enum TFlags |
|
225 { |
|
226 // bit flags |
|
227 EFlagUsesDefaultIconDir = 0x0001, |
|
228 EFlagIconDataPreserved = 0x0002, |
|
229 EFlagAnimated = 0x0004, |
|
230 EFlagFileExtRemoved = 0x0008, |
|
231 EFlagExcludeFromCache = 0x0010, |
|
232 EFlagDisableCompression = 0x0020, |
|
233 EFlagDisableCompressionCleanUp = 0x0040 |
|
234 }; |
|
235 |
|
236 HBufC* iFileName; // not owned |
|
237 TInt16 iBitmapId; |
|
238 TInt16 iMaskId; |
|
239 TInt16 iOriginalMaskId; |
|
240 TInt iFlags; |
|
241 CAknBitmap* iBitmap; // not owned |
|
242 CAknBitmap* iMask; // not owned |
|
243 MAknIconFormatHandler* iHandler; |
|
244 TInt iRefCount; |
|
245 MAknIconObserver* iObserver; |
|
246 TSize iLoadedSize; |
|
247 |
|
248 TSize iInitializedSize; |
|
249 TInt iInitializedMode; |
|
250 TInt iInitializedAngle; |
|
251 TRgb iInitializedColor; |
|
252 |
|
253 // Icon color. Effective only with 1-bit icons. |
|
254 TRgb iColor; |
|
255 |
|
256 // Content dimensions are stored here. |
|
257 TAknContentDimensions iContentDimensions; |
|
258 TBool iAppIcon; |
|
259 friend class RAknIconSrvClient; |
|
260 }; |
|
261 |
|
262 #include "AknIconManager.inl" |
|
263 |
|
264 #endif // AKN_ICON_MANAGER_H |
|
265 |
|
266 // End of File |