28 #include <AknLayout.lag> |
28 #include <AknLayout.lag> |
29 #include <AknIconArray.h> |
29 #include <AknIconArray.h> |
30 #include <gulicon.h> |
30 #include <gulicon.h> |
31 #include <widgetmanagerview.rsg> |
31 #include <widgetmanagerview.rsg> |
32 #include <widgetmanager.mbg> |
32 #include <widgetmanager.mbg> |
|
33 |
33 #include "wmcommon.h" |
34 #include "wmcommon.h" |
34 #include "wmplugin.h" |
35 #include "wmplugin.h" |
35 #include "wmresourceloader.h" |
36 #include "wmresourceloader.h" |
36 #include "wmlistbox.h" |
37 #include "wmlistbox.h" |
37 #include "wmwidgetdata.h" |
38 #include "wmwidgetdata.h" |
|
39 #include "wmwidgetorderdata.h" |
38 |
40 |
39 // CONSTANTS |
41 // CONSTANTS |
40 |
42 |
41 // MEMBER FUNCTIONS |
43 // MEMBER FUNCTIONS |
42 |
44 |
96 iDefaultLogoImageMask, |
98 iDefaultLogoImageMask, |
97 iWmPlugin.ResourceLoader().IconFilePath(), |
99 iWmPlugin.ResourceLoader().IconFilePath(), |
98 EMbmWidgetmanagerQgn_menu_hswidget, |
100 EMbmWidgetmanagerQgn_menu_hswidget, |
99 EMbmWidgetmanagerQgn_menu_hswidget_mask |
101 EMbmWidgetmanagerQgn_menu_hswidget_mask |
100 ); |
102 ); |
101 |
|
102 AknsUtils::CreateColorIconL( |
|
103 skin, |
|
104 KAknsIIDQgnIndiWmAdd, |
|
105 KAknsIIDQsnTextColors, |
|
106 EAknsCIQsnTextColorsCG6, |
|
107 iAddWidgetBtnImage, |
|
108 iAddWidgetBtnMask, |
|
109 iWmPlugin.ResourceLoader().IconFilePath(), |
|
110 EMbmWidgetmanagerAdd_widget_button, |
|
111 EMbmWidgetmanagerAdd_widget_button_mask, |
|
112 KRgbBlack ); |
|
113 |
|
114 AknsUtils::CreateColorIconL( |
|
115 skin, |
|
116 KAknsIIDQgnIndiWmAdd, |
|
117 KAknsIIDQsnTextColors, |
|
118 EAknsCIQsnTextColorsCG10, |
|
119 iAddWidgetBtnHighlightImage, |
|
120 iAddWidgetBtnHighlightMask, |
|
121 iWmPlugin.ResourceLoader().IconFilePath(), |
|
122 EMbmWidgetmanagerAdd_widget_button, |
|
123 EMbmWidgetmanagerAdd_widget_button_mask, |
|
124 KRgbWhite ); |
|
125 |
103 |
126 // This is temporary fix for ou1cimx1#228810 |
104 // This is temporary fix for ou1cimx1#228810 |
127 // Can be removed when avkon provides real fix for this error. |
105 // Can be removed when avkon provides real fix for this error. |
128 // Currently forever loop in CFormattedCellListBoxData::DrawFormattedSimple |
106 // Currently forever loop in CFormattedCellListBoxData::DrawFormattedSimple |
129 // never exits if there is no iconarray and name contains tab+digit which |
107 // never exits if there is no iconarray and name contains tab+digit which |
163 iListBox = NULL; |
141 iListBox = NULL; |
164 |
142 |
165 // dispose icons |
143 // dispose icons |
166 delete iDefaultLogoImage; |
144 delete iDefaultLogoImage; |
167 delete iDefaultLogoImageMask; |
145 delete iDefaultLogoImageMask; |
168 delete iAddWidgetBtnImage; |
|
169 delete iAddWidgetBtnMask; |
|
170 delete iAddWidgetBtnHighlightImage; |
|
171 delete iAddWidgetBtnHighlightMask; |
|
172 } |
146 } |
173 |
147 |
174 // --------------------------------------------------------- |
148 // --------------------------------------------------------- |
175 // CWmListItemDrawer::ResizeDefaultBitmaps |
149 // CWmListItemDrawer::ResizeDefaultBitmaps |
176 // --------------------------------------------------------- |
150 // --------------------------------------------------------- |
177 // |
151 // |
178 void CWmListItemDrawer::ResizeDefaultBitmaps() |
152 void CWmListItemDrawer::ResizeDefaultBitmaps() |
179 { |
153 { |
180 TAknWindowLineLayout logoPane = |
154 TAknWindowLineLayout logoPane = |
181 AknLayoutScalable_Apps::listrow_wgtman_pane_g1().LayoutLine(); |
155 AknLayoutScalable_Apps::listrow_wgtman_pane_g1().LayoutLine(); |
182 TAknWindowLineLayout addPane = |
156 |
183 AknLayoutScalable_Apps::listrow_wgtman_pane_g2().LayoutLine(); |
|
184 TAknLayoutRect layoutRect; |
157 TAknLayoutRect layoutRect; |
185 TRect rect = TRect( ItemCellSize() ); |
158 TRect rect = TRect( ItemCellSize() ); |
186 layoutRect.LayoutRect( rect, logoPane ); |
159 layoutRect.LayoutRect( rect, logoPane ); |
187 |
160 |
188 // RESIZE DEFAULT LOGO BITMAPS ACCORDING TO LAYOUT |
161 // RESIZE DEFAULT LOGO BITMAPS ACCORDING TO LAYOUT |
189 TSize size = layoutRect.Rect().Size(); |
162 TSize size = layoutRect.Rect().Size(); |
190 AknIconUtils::SetSize( |
163 AknIconUtils::SetSize( |
191 iDefaultLogoImage, size, EAspectRatioPreserved ); |
164 iDefaultLogoImage, size, EAspectRatioPreserved ); |
192 AknIconUtils::SetSize( |
165 AknIconUtils::SetSize( |
193 iDefaultLogoImageMask, size, EAspectRatioPreserved ); |
166 iDefaultLogoImageMask, size, EAspectRatioPreserved ); |
194 |
|
195 // RESIZE ADD BTN BITMAPS ACCORDING TO LAYOUT |
|
196 layoutRect.LayoutRect( rect, addPane ); |
|
197 size = layoutRect.Rect().Size(); |
|
198 AknIconUtils::SetSize( |
|
199 iAddWidgetBtnImage, size, EAspectRatioPreserved ); |
|
200 AknIconUtils::SetSize( |
|
201 iAddWidgetBtnMask, size, EAspectRatioPreserved ); |
|
202 AknIconUtils::SetSize( |
|
203 iAddWidgetBtnHighlightImage, size, EAspectRatioPreserved ); |
|
204 AknIconUtils::SetSize( |
|
205 iAddWidgetBtnHighlightMask, size, EAspectRatioPreserved ); |
|
206 } |
167 } |
207 |
168 |
208 // --------------------------------------------------------- |
169 // --------------------------------------------------------- |
209 // CWmListItemDrawer::DrawItem |
170 // CWmListItemDrawer::DrawItem |
210 // --------------------------------------------------------- |
171 // --------------------------------------------------------- |
256 else if( bitmap && mask ) |
216 else if( bitmap && mask ) |
257 { |
217 { |
258 logoLayout.DrawImage( gc, bitmap, mask ); |
218 logoLayout.DrawImage( gc, bitmap, mask ); |
259 } |
219 } |
260 |
220 |
|
221 // DRAW NAME |
261 TRgb textColor; |
222 TRgb textColor; |
262 TAknsQsnTextColorsIndex index = |
223 TAknsQsnTextColorsIndex index = |
263 ( aItemIsCurrent && listFocused && highlightEnabled )? |
224 ( aItemIsCurrent && listFocused && highlightEnabled )? |
264 EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG6; |
225 EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG6; |
265 |
226 |
266 AknsUtils::GetCachedColor( |
227 AknsUtils::GetCachedColor( |
267 skin, textColor, KAknsIIDQsnTextColors, index ); |
228 skin, textColor, KAknsIIDQsnTextColors, index ); |
268 |
|
269 // DRAW TEXT |
|
270 |
|
271 TAknTextLineLayout titleTextLayout = |
229 TAknTextLineLayout titleTextLayout = |
272 AknLayoutScalable_Apps::listrow_wgtman_pane_t1().LayoutLine(); |
230 AknLayoutScalable_Apps::listrow_wgtman_pane_t1().LayoutLine(); |
273 |
231 |
274 TAknLayoutText textLayoutTitle; |
232 TAknLayoutText textLayoutTitle; |
275 textLayoutTitle.LayoutText( itemRect, titleTextLayout ); |
233 textLayoutTitle.LayoutText( itemRect, titleTextLayout ); |
276 textLayoutTitle.DrawText( gc, wData.Name(), ETrue, textColor ); |
234 textLayoutTitle.DrawText( gc, wData.Name(), ETrue, textColor ); |
277 |
235 |
278 if ( !wData.IsUninstalling() && |
236 if ( wData.IsUninstalling() ) |
279 wData.HsContentInfo().CanBeAdded() ) |
237 { |
280 { |
238 // DRAW UNINSTALL ANIMATION |
281 // DRAW ADD BUTTON |
|
282 TAknLayoutRect addButtonLayout; |
|
283 addButtonLayout.LayoutRect( itemRect, |
|
284 AknLayoutScalable_Apps::listrow_wgtman_pane_g2().LayoutLine() ); |
|
285 if ( aItemIsCurrent && listFocused && highlightEnabled ) |
|
286 { |
|
287 addButtonLayout.DrawImage( gc, |
|
288 iAddWidgetBtnHighlightImage, iAddWidgetBtnHighlightMask ); |
|
289 } |
|
290 else |
|
291 { |
|
292 addButtonLayout.DrawImage( gc, |
|
293 iAddWidgetBtnImage, iAddWidgetBtnMask ); |
|
294 } |
|
295 } |
|
296 |
|
297 if ( !wData.IsUninstalling() ) |
|
298 { |
|
299 TAknTextLineLayout descTextLayout = |
|
300 AknLayoutScalable_Apps::listrow_wgtman_pane_t2().LayoutLine(); |
|
301 gc.SetPenSize(TSize(1,1)); |
|
302 // DRAW DESCRIPTION TEXT |
|
303 TAknLayoutText textLayoutDes; |
|
304 textLayoutDes.LayoutText( itemRect, descTextLayout ); |
|
305 textLayoutDes.DrawText( gc, wData.Description(), ETrue, textColor ); |
|
306 } |
|
307 else |
|
308 { |
|
309 // draw animation |
|
310 TAknLayoutRect animationLayout; |
239 TAknLayoutRect animationLayout; |
311 animationLayout.LayoutRect( itemRect, |
240 animationLayout.LayoutRect( itemRect, |
312 AknLayoutScalable_Apps::wait_bar_pane_cp09().LayoutLine() ); |
241 AknLayoutScalable_Apps::wait_bar_pane_cp09().LayoutLine() ); |
313 TSize size = animationLayout.Rect().Size(); |
242 TSize size = animationLayout.Rect().Size(); |
314 CFbsBitmap* animBitmap = |
243 CFbsBitmap* animBitmap = |
344 // CWmListItemDrawer::HandleSkinChanged |
273 // CWmListItemDrawer::HandleSkinChanged |
345 // --------------------------------------------------------- |
274 // --------------------------------------------------------- |
346 // |
275 // |
347 void CWmListItemDrawer::HandleSkinChanged() |
276 void CWmListItemDrawer::HandleSkinChanged() |
348 { |
277 { |
349 CFbsBitmap* addWidgetBtnImage( NULL ); |
278 ResizeDefaultBitmaps(); |
350 CFbsBitmap* addWidgetBtnMask( NULL ); |
|
351 CFbsBitmap* addWidgetBtnHighlightImage( NULL ); |
|
352 CFbsBitmap* addWidgetBtnHighlightMask( NULL ); |
|
353 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
354 |
|
355 TRAPD( err, |
|
356 AknsUtils::CreateColorIconLC( |
|
357 skin, |
|
358 KAknsIIDQgnIndiWmAdd, |
|
359 KAknsIIDQsnTextColors, |
|
360 EAknsCIQsnTextColorsCG6, |
|
361 addWidgetBtnImage, |
|
362 addWidgetBtnMask, |
|
363 iWmPlugin.ResourceLoader().IconFilePath(), |
|
364 EMbmWidgetmanagerAdd_widget_button, |
|
365 EMbmWidgetmanagerAdd_widget_button_mask, |
|
366 KRgbBlack ); |
|
367 |
|
368 AknsUtils::CreateColorIconLC( |
|
369 skin, |
|
370 KAknsIIDQgnIndiWmAdd, |
|
371 KAknsIIDQsnTextColors, |
|
372 EAknsCIQsnTextColorsCG10, |
|
373 addWidgetBtnHighlightImage, |
|
374 addWidgetBtnHighlightMask, |
|
375 iWmPlugin.ResourceLoader().IconFilePath(), |
|
376 EMbmWidgetmanagerAdd_widget_button, |
|
377 EMbmWidgetmanagerAdd_widget_button_mask, |
|
378 KRgbWhite ); |
|
379 |
|
380 CleanupStack::Pop( 4 ); // pop icons |
|
381 ); |
|
382 |
|
383 if ( KErrNone == err ) |
|
384 { |
|
385 // delete old icons |
|
386 delete iAddWidgetBtnImage; |
|
387 iAddWidgetBtnImage = NULL; |
|
388 delete iAddWidgetBtnMask; |
|
389 iAddWidgetBtnMask = NULL; |
|
390 delete iAddWidgetBtnHighlightImage; |
|
391 iAddWidgetBtnHighlightImage = NULL; |
|
392 delete iAddWidgetBtnHighlightMask; |
|
393 iAddWidgetBtnHighlightMask = NULL; |
|
394 |
|
395 // transfer ownership |
|
396 iAddWidgetBtnImage = addWidgetBtnImage; |
|
397 addWidgetBtnImage = NULL; |
|
398 iAddWidgetBtnMask = addWidgetBtnMask; |
|
399 addWidgetBtnMask = NULL; |
|
400 iAddWidgetBtnHighlightImage = addWidgetBtnHighlightImage; |
|
401 addWidgetBtnHighlightImage = NULL; |
|
402 iAddWidgetBtnHighlightMask = addWidgetBtnHighlightMask; |
|
403 addWidgetBtnHighlightMask = NULL; |
|
404 |
|
405 // resize new created icons |
|
406 ResizeDefaultBitmaps(); |
|
407 } |
|
408 } |
279 } |
409 |
280 |
410 // --------------------------------------------------------- |
281 // --------------------------------------------------------- |
411 // CWmListBox::NewL |
282 // CWmListBox::NewL |
412 // --------------------------------------------------------- |
283 // --------------------------------------------------------- |
440 // CWmListBox::~CWmListBox |
311 // CWmListBox::~CWmListBox |
441 // --------------------------------------------------------- |
312 // --------------------------------------------------------- |
442 // |
313 // |
443 CWmListBox::~CWmListBox() |
314 CWmListBox::~CWmListBox() |
444 { |
315 { |
445 iWidgetDatas.ResetAndDestroy(); |
316 iVisibleWidgetArray.ResetAndDestroy(); |
|
317 iOrderDataArray.ResetAndDestroy(); |
446 } |
318 } |
447 |
319 |
448 // --------------------------------------------------------- |
320 // --------------------------------------------------------- |
449 // CWmListBox::ConstructL |
321 // CWmListBox::ConstructL |
450 // --------------------------------------------------------- |
322 // --------------------------------------------------------- |
456 { |
328 { |
457 CEikFormattedCellListBox::ConstructL( aParent, aFlags ); |
329 CEikFormattedCellListBox::ConstructL( aParent, aFlags ); |
458 SetContainerWindowL( *aParent ); |
330 SetContainerWindowL( *aParent ); |
459 |
331 |
460 // set model point to the widgets array |
332 // set model point to the widgets array |
461 Model()->SetItemTextArray( &iWidgetDatas ); |
333 Model()->SetItemTextArray( &iVisibleWidgetArray ); |
462 Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
334 Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
463 |
335 |
464 // set empty-text to null |
336 // set empty-text to null |
465 View()->SetListEmptyTextL( KNullDesC ); |
337 View()->SetListEmptyTextL( KNullDesC ); |
466 |
338 |
472 // --------------------------------------------------------- |
344 // --------------------------------------------------------- |
473 // |
345 // |
474 CWmWidgetData* CWmListBox::WidgetData() |
346 CWmWidgetData* CWmListBox::WidgetData() |
475 { |
347 { |
476 TInt index = CurrentListBoxItemIndex(); |
348 TInt index = CurrentListBoxItemIndex(); |
477 return (index>=0 ? iWidgetDatas[index] : NULL); |
349 return (index>=0 ? iVisibleWidgetArray[index] : NULL); |
478 } |
350 } |
479 |
351 |
480 // --------------------------------------------------------- |
352 // --------------------------------------------------------- |
481 // CWmListBox::WidgetData |
353 // CWmListBox::WidgetData |
482 // --------------------------------------------------------- |
354 // --------------------------------------------------------- |
483 // |
355 // |
484 CWmWidgetData& CWmListBox::WidgetData( TInt aItemIndex ) |
356 CWmWidgetData& CWmListBox::WidgetData( TInt aItemIndex ) |
485 { |
357 { |
486 return *iWidgetDatas[ RealIndex( aItemIndex ) ]; |
358 return *iVisibleWidgetArray[ RealIndex( aItemIndex ) ]; |
487 } |
359 } |
488 |
360 |
489 // --------------------------------------------------------- |
361 // --------------------------------------------------------- |
490 // CWmListBox::AddWidgetDataL |
362 // CWmListBox::AddWidgetDataL |
491 // --------------------------------------------------------- |
363 // --------------------------------------------------------- |
509 void CWmListBox::RemoveWidgetData( TInt aItemIndex ) |
381 void CWmListBox::RemoveWidgetData( TInt aItemIndex ) |
510 { |
382 { |
511 TInt realIndex = RealIndex( aItemIndex ); |
383 TInt realIndex = RealIndex( aItemIndex ); |
512 TBool current = ( aItemIndex == CurrentItemIndex() ); |
384 TBool current = ( aItemIndex == CurrentItemIndex() ); |
513 // remove widget data |
385 // remove widget data |
514 CWmWidgetData* data = iWidgetDatas[realIndex]; |
386 CWmWidgetData* data = iVisibleWidgetArray[realIndex]; |
515 iWidgetDatas.Remove( realIndex ); |
387 iVisibleWidgetArray.Remove( realIndex ); |
516 // reorganise |
388 // reorganise |
517 TRAP_IGNORE( |
389 TRAP_IGNORE( |
518 AknListBoxUtils::HandleItemRemovalAndPositionHighlightL( |
390 AknListBoxUtils::HandleItemRemovalAndPositionHighlightL( |
519 this, realIndex, current ) ); |
391 this, realIndex, current ) ); |
|
392 |
|
393 // Remove item from order array |
|
394 for ( TInt i = 0; i < iOrderDataArray.Count(); i++ ) |
|
395 { |
|
396 CWmWidgetOrderData* order = iOrderDataArray[i]; |
|
397 if ( order->EqualsTo( data->Uid(), data->PublisherId() ) ) |
|
398 { |
|
399 iOrderDataArray.Remove( i ); |
|
400 delete order; |
|
401 order = NULL; |
|
402 break; |
|
403 } |
|
404 } |
520 |
405 |
521 // delete now |
406 // delete now |
522 delete data; |
407 delete data; |
523 data = NULL; |
408 data = NULL; |
524 } |
409 } |
538 |
423 |
539 // --------------------------------------------------------- |
424 // --------------------------------------------------------- |
540 // CWmListBox::SetSortOrderL |
425 // CWmListBox::SetSortOrderL |
541 // --------------------------------------------------------- |
426 // --------------------------------------------------------- |
542 // |
427 // |
543 void CWmListBox::SetSortOrderL( TSortOrder aOrder ) |
428 void CWmListBox::DoSortToVisibleArray( TSortOrder aOrder ) |
544 { |
429 { |
545 // now sort the existing data |
430 // now sort the existing data |
546 iWidgetDatas.Sort( SortOrder( aOrder ) ); |
431 iVisibleWidgetArray.Sort( SortOrder( aOrder ) ); |
547 DrawNow(); |
432 DrawNow(); |
548 } |
433 } |
549 |
434 |
550 // --------------------------------------------------------- |
435 // --------------------------------------------------------- |
551 // CWmListBox::CreateItemDrawerL |
436 // CWmListBox::CreateItemDrawerL |
570 // |
455 // |
571 void CWmListBox::HandleLayoutChanged() |
456 void CWmListBox::HandleLayoutChanged() |
572 { |
457 { |
573 iLogoSize = TSize( 0, 0); |
458 iLogoSize = TSize( 0, 0); |
574 iLogoSize = LogoSize(); |
459 iLogoSize = LogoSize(); |
575 for ( TInt i=0; i<iWidgetDatas.Count(); i++) |
460 for ( TInt i=0; i<iVisibleWidgetArray.Count(); i++) |
576 { |
461 { |
577 iWidgetDatas[i]->ReCreateLogo( iLogoSize ); |
462 iVisibleWidgetArray[i]->ReCreateLogo( iLogoSize ); |
578 } |
463 } |
579 } |
464 } |
580 |
465 |
581 // --------------------------------------------------------- |
466 // --------------------------------------------------------- |
582 // CWmListBox::HandleSkinChanged |
467 // CWmListBox::HandleSkinChanged |
761 return itemDrawer->DefaultLogoMask(); |
646 return itemDrawer->DefaultLogoMask(); |
762 } |
647 } |
763 return NULL; |
648 return NULL; |
764 } |
649 } |
765 |
650 |
|
651 // --------------------------------------------------------- |
|
652 // CWmListBox::SortOrderToOrderData |
|
653 // --------------------------------------------------------- |
|
654 // |
|
655 TLinearOrder<CWmWidgetOrderData> CWmListBox::SortOrderToOrderData( TSortOrder aOrder ) |
|
656 { |
|
657 if ( aOrder == EStoredOrder ) |
|
658 { |
|
659 return TLinearOrder<CWmWidgetOrderData>( |
|
660 CWmWidgetOrderData::CompareByPersistentWidgetOrder ); |
|
661 } |
|
662 else |
|
663 { |
|
664 return TLinearOrder<CWmWidgetOrderData>( |
|
665 CWmWidgetOrderData::CompareByName ); |
|
666 } |
|
667 } |
|
668 |
|
669 // --------------------------------------------------------- |
|
670 // CWmListBox::SetSortOrderToOrderDataL |
|
671 // --------------------------------------------------------- |
|
672 // |
|
673 void CWmListBox::DoSortToOrderData( TSortOrder aOrder ) |
|
674 { |
|
675 iOrderDataArray.Sort( SortOrderToOrderData( aOrder ) ); |
|
676 } |
|
677 |
|
678 // --------------------------------------------------------- |
|
679 // CWmListBox::AddWidgetDataL |
|
680 // --------------------------------------------------------- |
|
681 // |
|
682 void CWmListBox::AddOrderDataL( CWmWidgetOrderData* aOrderData ) |
|
683 { |
|
684 if ( aOrderData ) |
|
685 { |
|
686 iOrderDataArray.InsertInOrderAllowRepeatsL( aOrderData, |
|
687 SortOrderToOrderData( EStoredOrder ) ); |
|
688 } |
|
689 } |
|
690 |
|
691 // --------------------------------------------------------- |
|
692 // CWmListBox::OrderData |
|
693 // --------------------------------------------------------- |
|
694 // |
|
695 CWmWidgetOrderData* CWmListBox::OrderData( TInt aItemIndex ) |
|
696 { |
|
697 return iOrderDataArray[ aItemIndex ]; |
|
698 } |
766 // End of File |
699 // End of File |
767 |
700 |