|
1 /* |
|
2 * Copyright (c) 2006, 2007 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_AKNTREELISTICON_H |
|
20 #define C_AKNTREELISTICON_H |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <AknsItemID.h> |
|
25 #include <AknIconUtils.h> |
|
26 #include <babitflags.h> |
|
27 |
|
28 |
|
29 /** |
|
30 * Internal class for tree list icon data. |
|
31 * |
|
32 * This class encapsulates the paramaters used in constructing a bitmap and |
|
33 * mask for an icon used in tree list, as well as, the bitmap and mask itself. |
|
34 * The stored parameters can then be used in reconstructing the bitmaps on |
|
35 * skin change events. |
|
36 * |
|
37 * @lib aknhlist.lib |
|
38 * @since S60 v3.2 |
|
39 */ |
|
40 NONSHARABLE_CLASS( CAknTreeListIcon ) : public CBase |
|
41 { |
|
42 |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Two-phased constructor. |
|
47 * |
|
48 * @param aIconId Assigned icon ID for the icon. |
|
49 * |
|
50 * @param aId Item ID of the masked bitmap to be created. |
|
51 * |
|
52 * @param aFilename Filename to be used to construct the item, if no |
|
53 * matching item was found in the currently active skin. |
|
54 * |
|
55 * @param aBitmapId ID of the bitmap in the file. Used only if no matching |
|
56 * item was found in the currently active skin. |
|
57 * |
|
58 * @param aMaskId ID of the mask in the file. Used only if no matching item |
|
59 * was found in the currently active skin. |
|
60 * |
|
61 * @param aScaleMode Scale mode used when icon's bitmap is resized. |
|
62 * |
|
63 * @return Pointer to the newly created object. |
|
64 */ |
|
65 static CAknTreeListIcon* NewLC( TInt aIconId, const TAknsItemID& aId, |
|
66 const TDesC& aFilename, TInt aBitmapId, TInt aMaskId, |
|
67 TScaleMode aScaleMode ); |
|
68 |
|
69 /** |
|
70 * Two-phased constructor. |
|
71 * |
|
72 * @param aIconId Assigned icon ID for the icon. |
|
73 * |
|
74 * @param aIcon Pointer to the bitmap. |
|
75 * |
|
76 * @param aMask Pointer to the mask bitmap. |
|
77 * |
|
78 * @param aTransferOwnership @c ETrue, if ownership of bitmaps is |
|
79 * transferred to the list. If the method leaves, it is always on the |
|
80 * responsibility of the client code to take care of deleting the bitmaps. |
|
81 * |
|
82 * @param aScaleMode Scale mode used when icon's bitmap is resized. |
|
83 * |
|
84 * @return Pointer to the newly created object. |
|
85 */ |
|
86 static CAknTreeListIcon* NewLC( TInt aIconId, CFbsBitmap* aIcon, |
|
87 CFbsBitmap* aMask, TBool aTransferOwnership, TScaleMode aScaleMode ); |
|
88 |
|
89 /** |
|
90 * Two-phased constructor. |
|
91 * |
|
92 * @param aIconId Assigned icon ID for the icon. |
|
93 * |
|
94 * @param aId Item ID of the masked bitmap to be created. |
|
95 * |
|
96 * @param aColorId Item ID of the color table. |
|
97 * |
|
98 * @param aColorIndex Index in the color table. |
|
99 * |
|
100 * @param aFilename Filename to be used to construct the item, if no |
|
101 * matching item was found in the currently active skin. |
|
102 * |
|
103 * @param aBitmapId ID of the bitmap in the file. Used only if no matching |
|
104 * item was found in the currently active skin. |
|
105 * |
|
106 * @param aMaskId ID of the mask in the file. Used only if no matching item |
|
107 * was found in the currently active skin. |
|
108 * |
|
109 * @param aDefaultColor Color RGB value to be used, if no color is found in |
|
110 * the currently active skin. |
|
111 * |
|
112 * @param aScaleMode Scale mode used when icon's bitmap is resized. |
|
113 * |
|
114 * @return Pointer to the newly created object. |
|
115 */ |
|
116 static CAknTreeListIcon* NewLC( TInt aIconId, const TAknsItemID& aId, |
|
117 const TAknsItemID& aColorId, TInt aColorIndex, |
|
118 const TDesC& aFilename, TInt aBitmapId, TInt aMaskId, |
|
119 TRgb aDefaultColor, TScaleMode aScaleMode ); |
|
120 |
|
121 /** |
|
122 * Destructor. |
|
123 */ |
|
124 ~CAknTreeListIcon(); |
|
125 |
|
126 /** |
|
127 * Determines the order of two CAknTreeListIcon objects based on their IDs. |
|
128 * |
|
129 * @param aFirst First compared icon. |
|
130 * |
|
131 * @param aSecond Second compared icon. |
|
132 * |
|
133 * @return Negative value, if the first has smaller ID; zero, if the icons |
|
134 * have the same ID; and positive value, if second has smaller ID. |
|
135 */ |
|
136 static TInt Compare( const CAknTreeListIcon& aFirst, |
|
137 const CAknTreeListIcon& aSecond ); |
|
138 |
|
139 /** |
|
140 * Compares the given ID with the given icon. This function can be used |
|
141 * when icons are stored in @c RPointerArray and searched from the array |
|
142 * with on their IDs. |
|
143 * |
|
144 * @param aIconId Compared icon ID. |
|
145 * |
|
146 * @param aIcon Compared icon. |
|
147 * |
|
148 * @return Negative value, if the ID is smaller than the one in the icon; |
|
149 * zero, if the IDs match, and positive value if ID is greater than |
|
150 * the one in the icon. |
|
151 */ |
|
152 static TInt CompareId( const TInt* aIconId, const CAknTreeListIcon& aIcon ); |
|
153 |
|
154 /** |
|
155 * Reconstructs the icon's bitmap and mask according to the stored |
|
156 * parameters. |
|
157 */ |
|
158 void ReconstructL(); |
|
159 |
|
160 /** |
|
161 * Returns the ID assigned for the icon. |
|
162 * |
|
163 * @return The tree list icon ID. |
|
164 */ |
|
165 TInt Id() const; |
|
166 |
|
167 /** |
|
168 * Returns the skin item ID of the contained icon. |
|
169 * |
|
170 * @return Skin item ID of icon. |
|
171 */ |
|
172 const TAknsItemID& SkinItemID() const; |
|
173 |
|
174 /** |
|
175 * Returns pointer to the icon's bitmap. Ownership is not transsferred. |
|
176 * |
|
177 * @return The icon's bitmap. |
|
178 */ |
|
179 CFbsBitmap* Bitmap(); |
|
180 |
|
181 /** |
|
182 * Returns pointer to the icon's mask. Ownership is not transsferred. |
|
183 * |
|
184 * @return The icon's mask. |
|
185 */ |
|
186 CFbsBitmap* Mask(); |
|
187 |
|
188 /** |
|
189 * Returns the icon's size. |
|
190 * |
|
191 * @return The icon's size. |
|
192 */ |
|
193 TSize Size() const; |
|
194 |
|
195 /** |
|
196 * Returns the icon's scale mode. |
|
197 * |
|
198 * @return The icon's scale mode. |
|
199 */ |
|
200 TScaleMode ScaleMode() const; |
|
201 |
|
202 /** |
|
203 * Sets new size for the icon. |
|
204 * |
|
205 * @param aSize Icon size. |
|
206 */ |
|
207 TInt SetSize( const TSize& aSize ); |
|
208 |
|
209 private: |
|
210 |
|
211 /** |
|
212 * C++ constructor. |
|
213 */ |
|
214 CAknTreeListIcon( TInt aIconId, const TAknsItemID& aId, TInt aBitmapId, |
|
215 TInt aMaskId, TScaleMode aScaleMode ); |
|
216 |
|
217 /** |
|
218 * C++ constructor. |
|
219 */ |
|
220 CAknTreeListIcon( TInt aIconId, CFbsBitmap* aIcon, CFbsBitmap* aMask, |
|
221 TBool aTransferOwnership, TScaleMode aScaleMode ); |
|
222 |
|
223 /** |
|
224 * C++ constructor. |
|
225 */ |
|
226 CAknTreeListIcon( TInt aIconId, const TAknsItemID& aId, |
|
227 const TAknsItemID& aColorId, TInt aColorIndex, TInt aBitmapId, |
|
228 TInt aMaskId, TRgb aDefaultColor, TScaleMode aScaleMode ); |
|
229 |
|
230 /** |
|
231 * Second phase constructor. |
|
232 * |
|
233 * @param aFilename Name of the icon file. |
|
234 */ |
|
235 void ConstructL( const TDesC& aFilename ); |
|
236 |
|
237 private: |
|
238 |
|
239 /** |
|
240 * Assigned id for tree list icon. |
|
241 */ |
|
242 const TInt iIconId; |
|
243 |
|
244 /** |
|
245 * Skin item ID of the icon. |
|
246 */ |
|
247 TAknsItemID iId; |
|
248 |
|
249 /** |
|
250 * Skin item ID for icons color group. |
|
251 */ |
|
252 TAknsItemID iColorId; |
|
253 |
|
254 /** |
|
255 * Color index for colored item. |
|
256 */ |
|
257 TInt iColorIndex; |
|
258 |
|
259 /** |
|
260 * Bitmap ID. |
|
261 */ |
|
262 TInt iBitmapId; |
|
263 |
|
264 /** |
|
265 * Mask ID. |
|
266 */ |
|
267 TInt iMaskId; |
|
268 |
|
269 /** |
|
270 * Default color for the icon. |
|
271 */ |
|
272 TRgb iDefaultColor; |
|
273 |
|
274 /** |
|
275 * Filename for icon file. |
|
276 * Own. |
|
277 */ |
|
278 HBufC* iFilename; |
|
279 |
|
280 /** |
|
281 * Bitmap. |
|
282 * Own. |
|
283 */ |
|
284 CFbsBitmap* iBitmap; |
|
285 |
|
286 /** |
|
287 * Mask. |
|
288 * Own. |
|
289 */ |
|
290 CFbsBitmap* iMask; |
|
291 |
|
292 /** |
|
293 * Flags. |
|
294 */ |
|
295 TBitFlags32 iFlags; |
|
296 |
|
297 /** |
|
298 * Size of the icon. |
|
299 */ |
|
300 TSize iSize; |
|
301 |
|
302 /** |
|
303 * Icon's scale mode. |
|
304 */ |
|
305 TScaleMode iScaleMode; |
|
306 |
|
307 }; |
|
308 |
|
309 |
|
310 #endif // C_AKNTREELISTICON_H |