|
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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "HgIndicatorManager.h" |
|
20 |
|
21 #include "HgConstants.h" |
|
22 #include <ganes/HgItem.h> |
|
23 |
|
24 #include <AknIconUtils.h> |
|
25 #include <avkon.mbg> |
|
26 #include <AknsDrawUtils.h> |
|
27 #include <gulicon.h> |
|
28 #include <AknUtils.h> |
|
29 #include <ganes.mbg> |
|
30 #include <AknLayout2ScalableDef.h> |
|
31 |
|
32 |
|
33 CHgIndicatorManager* CHgIndicatorManager::NewL() |
|
34 { |
|
35 CHgIndicatorManager* self = new (ELeave) CHgIndicatorManager; |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } |
|
41 |
|
42 CHgIndicatorManager::~CHgIndicatorManager() |
|
43 { |
|
44 delete iDrmIcon; |
|
45 delete iDrmExpIcon; |
|
46 delete iVideoIcon; |
|
47 delete iPlaybackIndicatorIcon; |
|
48 delete iMmcIcon; |
|
49 delete iMarkIcon; |
|
50 delete iPauseIndicatorIcon; |
|
51 delete iBrokenPlaylistIcon; |
|
52 delete iBrokenTrackIcon; |
|
53 delete iCorruptedTrackIcon; |
|
54 delete iMassStorageIcon; |
|
55 delete iNewVideoIcon; |
|
56 delete iPhoneStorageIcon; |
|
57 delete iNewPodcastIcon; |
|
58 delete iPlayedPodcastIcon; |
|
59 delete iCompletelyPlayedPodcastIcon; |
|
60 delete iMoveUpIcon; |
|
61 delete iMoveDownIcon; |
|
62 delete iMoveUpDownIcon; |
|
63 } |
|
64 |
|
65 void CHgIndicatorManager::InitIndicatorsL( const TSize& aIndicatorSize ) |
|
66 { |
|
67 // Non-Skinned icons |
|
68 // Broken Playlist icon |
|
69 InitIconL( iBrokenPlaylistIcon, |
|
70 EMbmGanesQgn_graf_mup_lst_brokenplayl, |
|
71 EMbmGanesQgn_graf_mup_lst_brokenplayl_mask, |
|
72 aIndicatorSize ); |
|
73 |
|
74 // Broken track icon |
|
75 InitIconL( iBrokenTrackIcon, |
|
76 EMbmGanesQgn_graf_mup_lst_brokentrack, |
|
77 EMbmGanesQgn_graf_mup_lst_brokentrack_mask, |
|
78 aIndicatorSize ); |
|
79 |
|
80 // Corrupted track icon |
|
81 InitIconL( iCorruptedTrackIcon, |
|
82 EMbmGanesQgn_graf_mup_lst_corrupttrack, |
|
83 EMbmGanesQgn_graf_mup_lst_corrupttrack_mask, |
|
84 aIndicatorSize ); |
|
85 |
|
86 // New podcast icon |
|
87 InitIconL( iNewPodcastIcon, |
|
88 EMbmGanesQgn_graf_mup_lst_pdc_new, |
|
89 EMbmGanesQgn_graf_mup_lst_pdc_new_mask, |
|
90 aIndicatorSize ); |
|
91 |
|
92 // Played podcast icon |
|
93 InitIconL( iPlayedPodcastIcon, |
|
94 EMbmGanesQgn_graf_mup_lst_pdc_partplay, |
|
95 EMbmGanesQgn_graf_mup_lst_pdc_partplay_mask, |
|
96 aIndicatorSize ); |
|
97 |
|
98 // Completely played podcast icon |
|
99 InitIconL( iCompletelyPlayedPodcastIcon, |
|
100 EMbmGanesQgn_graf_mup_lst_pdc_compplay, |
|
101 EMbmGanesQgn_graf_mup_lst_pdc_compplay_mask, |
|
102 aIndicatorSize ); |
|
103 |
|
104 // Video icon |
|
105 InitIconL( iVideoIcon, |
|
106 EMbmGanesQgn_indi_media_thumbnail, |
|
107 EMbmGanesQgn_indi_media_thumbnail_mask, |
|
108 aIndicatorSize ); |
|
109 |
|
110 // Skinned icons |
|
111 // Mark icon |
|
112 InitIconL( iMarkIcon, KAknsIIDQgnPropSubMarked, |
|
113 EMbmGanesQgn_prop_sub_marked, |
|
114 EMbmGanesQgn_prop_sub_marked_mask, |
|
115 aIndicatorSize ); |
|
116 |
|
117 // DRM valid icon |
|
118 InitIconL( iDrmIcon, KAknsIIDQgnPropDrmRightsValidSuper, |
|
119 EMbmGanesQgn_prop_drm_rights_valid_super, |
|
120 EMbmGanesQgn_prop_drm_rights_valid_super_mask, |
|
121 aIndicatorSize ); |
|
122 |
|
123 // DRM expired icon |
|
124 InitIconL( iDrmExpIcon, KAknsIIDQgnPropDrmRightsExpSuper, |
|
125 EMbmGanesQgn_prop_drm_rights_exp_super, |
|
126 EMbmGanesQgn_prop_drm_rights_exp_super_mask, |
|
127 aIndicatorSize ); |
|
128 |
|
129 // Playback icon |
|
130 InitIconL( iPlaybackIndicatorIcon, KAknsIIDQgnIndiMupPlay, |
|
131 EMbmGanesQgn_indi_mup_play, |
|
132 EMbmGanesQgn_indi_mup_play_mask, |
|
133 aIndicatorSize ); |
|
134 |
|
135 // Pause icon |
|
136 InitIconL( iPauseIndicatorIcon, KAknsIIDQgnIndiMupPause, |
|
137 EMbmGanesQgn_indi_mup_pause, |
|
138 EMbmGanesQgn_indi_mup_pause_mask, |
|
139 aIndicatorSize ); |
|
140 |
|
141 // New Video icon |
|
142 InitIconL( iNewVideoIcon, KAknsIIDQgnPropFmgrFileVideo, |
|
143 EMbmGanesQgn_prop_fmgr_file_video, |
|
144 EMbmGanesQgn_prop_fmgr_file_video_mask, |
|
145 aIndicatorSize ); |
|
146 |
|
147 // Phone memory icon |
|
148 InitIconL( iPhoneStorageIcon, KAknsIIDQgnPropPhoneMemc, |
|
149 EMbmGanesQgn_prop_phone_memc, |
|
150 EMbmGanesQgn_prop_phone_memc_mask, |
|
151 aIndicatorSize ); |
|
152 |
|
153 // MMC memory icon |
|
154 InitIconL( iMmcIcon, KAknsIIDQgnPropMmcMemc, |
|
155 EMbmGanesQgn_prop_mmc_memc, |
|
156 EMbmGanesQgn_prop_mmc_memc_mask, |
|
157 aIndicatorSize ); |
|
158 |
|
159 // Mass memory icon |
|
160 InitIconL( iMassStorageIcon, KAknsIIDQgnPropFmgrMsSmall, |
|
161 EMbmGanesQgn_prop_fmgr_ms_small, |
|
162 EMbmGanesQgn_prop_fmgr_ms_small_mask, |
|
163 aIndicatorSize ); |
|
164 |
|
165 // Move up icon |
|
166 InitIconL( iMoveUpIcon, KAknsIIDQgnGrafMupAdtlReorderUp, |
|
167 EMbmGanesQgn_graf_mup_adtl_reorder_up, |
|
168 EMbmGanesQgn_graf_mup_adtl_reorder_up_mask, |
|
169 aIndicatorSize ); |
|
170 |
|
171 // Move down icon |
|
172 InitIconL( iMoveDownIcon, KAknsIIDQgnGrafMupAdtlReorderDown, |
|
173 EMbmGanesQgn_graf_mup_adtl_reorder_down, |
|
174 EMbmGanesQgn_graf_mup_adtl_reorder_down_mask, |
|
175 aIndicatorSize ); |
|
176 |
|
177 // Move updown icon |
|
178 InitIconL( iMoveUpDownIcon, KAknsIIDQgnGrafMupAdtlReorderUpdown, |
|
179 EMbmGanesQgn_graf_mup_adtl_reorder_updown, |
|
180 EMbmGanesQgn_graf_mup_adtl_reorder_updown_mask, |
|
181 aIndicatorSize ); |
|
182 } |
|
183 |
|
184 void CHgIndicatorManager::DrawIndicators( |
|
185 CWindowGc& aGc, |
|
186 const TRect& aRect, |
|
187 TInt aFlags, |
|
188 TAknWindowComponentLayout aFirstIndicatorLayout, |
|
189 TAknWindowComponentLayout aSecondIndicatorLayout |
|
190 ) const |
|
191 { |
|
192 TAknLayoutRect secondIndicator; |
|
193 secondIndicator.LayoutRect(aRect, aSecondIndicatorLayout); |
|
194 |
|
195 TAknLayoutRect firstIndicator; |
|
196 firstIndicator.LayoutRect(aRect, aFirstIndicatorLayout); |
|
197 |
|
198 TAknLayoutRect rect = secondIndicator; |
|
199 TBool memIndicator = EFalse; |
|
200 TInt indicatorsDrawn = 0; |
|
201 |
|
202 if( aFlags & CHgItem::EHgItemFlagMarked ) |
|
203 { |
|
204 rect.DrawImage(aGc, iMarkIcon->Bitmap(), iMarkIcon->Mask()); |
|
205 ++indicatorsDrawn; |
|
206 rect = firstIndicator; |
|
207 } |
|
208 |
|
209 if( DrawIndicator(aGc, rect, aFlags, memIndicator) ) |
|
210 { |
|
211 ++indicatorsDrawn; |
|
212 rect = firstIndicator; |
|
213 } |
|
214 |
|
215 if( indicatorsDrawn == 1 && !memIndicator ) |
|
216 { |
|
217 if( aFlags & CHgItem::EHgItemFlagsMmc ) |
|
218 { |
|
219 rect.DrawImage(aGc, iMmcIcon->Bitmap(), iMmcIcon->Mask() ); |
|
220 } |
|
221 else if( aFlags & CHgItem::EHgItemFlagsMassStorageIndicator ) |
|
222 { |
|
223 rect.DrawImage(aGc, iMassStorageIcon->Bitmap(), iMassStorageIcon->Mask() ); |
|
224 } |
|
225 else if( aFlags & CHgItem::EHgItemFlagsPhoneStorageIndicator ) |
|
226 { |
|
227 rect.DrawImage(aGc, iPhoneStorageIcon->Bitmap(), iPhoneStorageIcon->Mask() ); |
|
228 } |
|
229 } |
|
230 |
|
231 } |
|
232 |
|
233 TBool CHgIndicatorManager::DrawIndicator( |
|
234 CWindowGc& aGc, |
|
235 TAknLayoutRect& aRect, |
|
236 TInt aFlags, |
|
237 TBool& aMemIndicator |
|
238 ) const |
|
239 { |
|
240 TBool ret = EFalse; |
|
241 |
|
242 if( aFlags & CHgItem::EHgItemFlagsPlaybackIndicator ) |
|
243 { |
|
244 aRect.DrawImage(aGc, iPlaybackIndicatorIcon->Bitmap(), iPlaybackIndicatorIcon->Mask() ); |
|
245 ret = ETrue; |
|
246 } |
|
247 else if( aFlags & CHgItem::EHgItemFlagsPauseIndicator ) |
|
248 { |
|
249 aRect.DrawImage(aGc, iPauseIndicatorIcon->Bitmap(), iPauseIndicatorIcon->Mask() ); |
|
250 ret = ETrue; |
|
251 } |
|
252 else if( aFlags & CHgItem::EHgItemFlagsDrmRightsValid ) |
|
253 { |
|
254 aRect.DrawImage(aGc, iDrmIcon->Bitmap(), iDrmIcon->Mask() ); |
|
255 ret = ETrue; |
|
256 } |
|
257 else if( aFlags & CHgItem::EHgItemFlagsDrmRightsExpired ) |
|
258 { |
|
259 aRect.DrawImage(aGc, iDrmExpIcon->Bitmap(), iDrmExpIcon->Mask() ); |
|
260 ret = ETrue; |
|
261 } |
|
262 else if( aFlags & CHgItem::EHgItemFlagsVideo ) |
|
263 { |
|
264 aRect.DrawImage(aGc, iVideoIcon->Bitmap(), iVideoIcon->Mask() ); |
|
265 ret = ETrue; |
|
266 } |
|
267 else if( aFlags & CHgItem::EHgItemFlagsBrokenPlaylistIndicator ) |
|
268 { |
|
269 aRect.DrawImage(aGc, iBrokenPlaylistIcon->Bitmap(), iBrokenPlaylistIcon->Mask() ); |
|
270 ret = ETrue; |
|
271 } |
|
272 else if( aFlags & CHgItem::EHgItemFlagsBrokenTrackIndicator ) |
|
273 { |
|
274 aRect.DrawImage(aGc, iBrokenTrackIcon->Bitmap(), iBrokenTrackIcon->Mask() ); |
|
275 ret = ETrue; |
|
276 } |
|
277 else if( aFlags & CHgItem::EHgItemFlagsCorruptedTrackIndicator ) |
|
278 { |
|
279 aRect.DrawImage(aGc, iCorruptedTrackIcon->Bitmap(), iCorruptedTrackIcon->Mask() ); |
|
280 ret = ETrue; |
|
281 } |
|
282 else if( aFlags & CHgItem::EHgItemFlagsNewVideoIndicator ) |
|
283 { |
|
284 aRect.DrawImage(aGc, iNewVideoIcon->Bitmap(), iNewVideoIcon->Mask() ); |
|
285 ret = ETrue; |
|
286 } |
|
287 else if( aFlags & CHgItem::EHgItemFlagsNewPodcastIndicator ) |
|
288 { |
|
289 aRect.DrawImage(aGc, iNewPodcastIcon->Bitmap(), iNewPodcastIcon->Mask() ); |
|
290 ret = ETrue; |
|
291 } |
|
292 else if( aFlags & CHgItem::EHgItemFlagsPlayedPodcastIndicator ) |
|
293 { |
|
294 aRect.DrawImage(aGc, iPlayedPodcastIcon->Bitmap(), iPlayedPodcastIcon->Mask() ); |
|
295 ret = ETrue; |
|
296 } |
|
297 else if( aFlags & CHgItem::EHgItemFlagsCompletelyPlayedPodcastIndicator ) |
|
298 { |
|
299 aRect.DrawImage(aGc, iCompletelyPlayedPodcastIcon->Bitmap(), iCompletelyPlayedPodcastIcon->Mask() ); |
|
300 ret = ETrue; |
|
301 } |
|
302 else if( aFlags & CHgItem::EHgItemFlagsMoveUpIndicator ) |
|
303 { |
|
304 aRect.DrawImage(aGc, iMoveUpIcon->Bitmap(), iMoveUpIcon->Mask() ); |
|
305 ret = ETrue; |
|
306 } |
|
307 else if( aFlags & CHgItem::EHgItemFlagsMoveDownIndicator ) |
|
308 { |
|
309 aRect.DrawImage(aGc, iMoveDownIcon->Bitmap(), iMoveDownIcon->Mask() ); |
|
310 ret = ETrue; |
|
311 } |
|
312 else if( aFlags & CHgItem::EHgItemFlagsMoveUpDownIndicator ) |
|
313 { |
|
314 aRect.DrawImage(aGc, iMoveUpDownIcon->Bitmap(), iMoveUpDownIcon->Mask() ); |
|
315 ret = ETrue; |
|
316 } |
|
317 else if( aFlags & CHgItem::EHgItemFlagsMmc ) |
|
318 { |
|
319 aRect.DrawImage(aGc, iMmcIcon->Bitmap(), iMmcIcon->Mask() ); |
|
320 ret = ETrue; |
|
321 aMemIndicator = ETrue; |
|
322 } |
|
323 else if( aFlags & CHgItem::EHgItemFlagsMassStorageIndicator ) |
|
324 { |
|
325 aRect.DrawImage(aGc, iMassStorageIcon->Bitmap(), iMassStorageIcon->Mask() ); |
|
326 ret = ETrue; |
|
327 aMemIndicator = ETrue; |
|
328 } |
|
329 else if( aFlags & CHgItem::EHgItemFlagsPhoneStorageIndicator ) |
|
330 { |
|
331 aRect.DrawImage(aGc, iPhoneStorageIcon->Bitmap(), iPhoneStorageIcon->Mask() ); |
|
332 ret = ETrue; |
|
333 aMemIndicator = ETrue; |
|
334 } |
|
335 return ret; |
|
336 } |
|
337 |
|
338 // ----------------------------------------------------------------------------- |
|
339 // CHgIndicatorManager::InitIconL() |
|
340 // ----------------------------------------------------------------------------- |
|
341 // |
|
342 void CHgIndicatorManager::InitIconL( CGulIcon*& aIcon, |
|
343 TInt aIconIndex, |
|
344 TInt aMaskIndex, |
|
345 TSize aSize ) |
|
346 { |
|
347 if( !aIcon ) |
|
348 { |
|
349 CFbsBitmap* bitmap, *mask; |
|
350 AknIconUtils::CreateIconL( |
|
351 bitmap, |
|
352 mask, |
|
353 KGanesMif, |
|
354 aIconIndex, |
|
355 aMaskIndex ); |
|
356 aIcon = CGulIcon::NewL(bitmap, mask); |
|
357 } |
|
358 |
|
359 AknIconUtils::SetSize(aIcon->Bitmap(), aSize); |
|
360 } |
|
361 |
|
362 // ----------------------------------------------------------------------------- |
|
363 // CHgIndicatorManager::InitIconL() |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 void CHgIndicatorManager::InitIconL( CGulIcon*& aIcon, |
|
367 const TAknsItemID& aItemId, |
|
368 TInt aIconIndex, |
|
369 TInt aMaskIndex, |
|
370 TSize aSize ) |
|
371 { |
|
372 if( !aIcon ) |
|
373 { |
|
374 aIcon = AknsUtils::CreateGulIconL( |
|
375 AknsUtils::SkinInstance(), |
|
376 aItemId, |
|
377 KGanesMif, |
|
378 aIconIndex, |
|
379 aMaskIndex ); |
|
380 } |
|
381 |
|
382 AknIconUtils::SetSize(aIcon->Bitmap(), aSize); |
|
383 } |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // CHgIndicatorManager::InitIconL() |
|
387 // ----------------------------------------------------------------------------- |
|
388 // |
|
389 void CHgIndicatorManager::InitColorIconL( CGulIcon*& aIcon, |
|
390 const TAknsItemID& aItemId, |
|
391 TInt aIconIndex, |
|
392 TInt aMaskIndex, |
|
393 TSize aSize ) |
|
394 { |
|
395 if( !aIcon ) |
|
396 { |
|
397 TRgb defaultColour( KRgbWhite ); |
|
398 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
399 |
|
400 AknsUtils::GetCachedColor( skin, |
|
401 defaultColour, |
|
402 KAknsIIDQsnIconColors, |
|
403 EAknsCIQsnIconColorsCG13 ); |
|
404 |
|
405 CFbsBitmap *bitmap,*mask; |
|
406 AknsUtils::CreateColorIconL( |
|
407 skin, |
|
408 aItemId, |
|
409 KAknsIIDQsnIconColors, |
|
410 EAknsCIQsnIconColorsCG13, |
|
411 bitmap, |
|
412 mask, |
|
413 KGanesMif, |
|
414 aIconIndex, |
|
415 aMaskIndex, |
|
416 defaultColour ); |
|
417 |
|
418 aIcon = CGulIcon::NewL(bitmap, mask); |
|
419 } |
|
420 |
|
421 AknIconUtils::SetSize(aIcon->Bitmap(), aSize); |
|
422 } |
|
423 |
|
424 TInt CHgIndicatorManager::CountIndicators( TInt aFlags ) |
|
425 { |
|
426 TInt count = 0; |
|
427 aFlags &= (~CHgItem::EHgItemFlagsIconOverlayIndicator); // overlayindicator not counted |
|
428 while(aFlags) |
|
429 { |
|
430 count += aFlags & 0x1; |
|
431 aFlags = aFlags >> 1; |
|
432 } |
|
433 return count > KMaxNumberOfTitleIndicators ? KMaxNumberOfTitleIndicators : count; |
|
434 } |
|
435 |
|
436 CHgIndicatorManager::CHgIndicatorManager() |
|
437 { |
|
438 |
|
439 } |
|
440 |
|
441 void CHgIndicatorManager::ConstructL() |
|
442 { |
|
443 |
|
444 } |