|
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 * Implementation of the widget listbox for WidgetManager |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <coemain.h> |
|
21 #include <AknsDrawUtils.h> |
|
22 #include <AknsFrameBackgroundControlContext.h> |
|
23 #include <AknsListBoxBackgroundControlContext.h> |
|
24 #include <aknlayout.cdl.h> |
|
25 #include <layoutmetadata.cdl.h> |
|
26 #include <aknlayoutscalable_avkon.cdl.h> |
|
27 #include <aknlayoutscalable_apps.cdl.h> |
|
28 #include <AknLayout.lag> |
|
29 #include <AknIconArray.h> |
|
30 #include <gulicon.h> |
|
31 #include <widgetmanagerview.rsg> |
|
32 #include <widgetmanager.mbg> |
|
33 |
|
34 #include "wmcommon.h" |
|
35 #include "wmplugin.h" |
|
36 #include "wmresourceloader.h" |
|
37 #include "wmlistbox.h" |
|
38 #include "wmwidgetdata.h" |
|
39 #include "wmwidgetorderdata.h" |
|
40 |
|
41 // CONSTANTS |
|
42 |
|
43 // MEMBER FUNCTIONS |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // CWmListItemDrawer::NewL |
|
47 // --------------------------------------------------------- |
|
48 // |
|
49 CWmListItemDrawer* CWmListItemDrawer::NewL( |
|
50 CWmPlugin& aWmPlugin, |
|
51 MTextListBoxModel* aTextListBoxModel, |
|
52 const CFont* aFont, |
|
53 CFormattedCellListBoxData* aFormattedCellData, |
|
54 CWmListBox* aListBox ) |
|
55 { |
|
56 CWmListItemDrawer* self = new ( ELeave ) CWmListItemDrawer( |
|
57 aWmPlugin, |
|
58 aTextListBoxModel, |
|
59 aFont, |
|
60 aFormattedCellData, |
|
61 aListBox ); |
|
62 CleanupStack::PushL(self); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop(self); |
|
65 return self; |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------- |
|
69 // CWmListItemDrawer::CWmListItemDrawer |
|
70 // --------------------------------------------------------- |
|
71 // |
|
72 CWmListItemDrawer::CWmListItemDrawer( |
|
73 CWmPlugin& aWmPlugin, |
|
74 MTextListBoxModel* aTextListBoxModel, |
|
75 const CFont* aFont, |
|
76 CFormattedCellListBoxData* aFormattedCellData, |
|
77 CWmListBox* aListBox ) |
|
78 : CFormattedCellListBoxItemDrawer( aTextListBoxModel,aFont,aFormattedCellData ), |
|
79 iWmPlugin( aWmPlugin ) |
|
80 { |
|
81 iCellData = aFormattedCellData; |
|
82 iListBox = aListBox; |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // CWmListItemDrawer::ConstructL |
|
87 // --------------------------------------------------------- |
|
88 // |
|
89 void CWmListItemDrawer::ConstructL() |
|
90 { |
|
91 SetSkinEnabledL( ETrue ); |
|
92 |
|
93 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
94 AknsUtils::CreateIconL( |
|
95 skin, |
|
96 KAknsIIDQgnMenuHswidget, |
|
97 iDefaultLogoImage, |
|
98 iDefaultLogoImageMask, |
|
99 iWmPlugin.ResourceLoader().IconFilePath(), |
|
100 EMbmWidgetmanagerQgn_menu_hswidget, |
|
101 EMbmWidgetmanagerQgn_menu_hswidget_mask |
|
102 ); |
|
103 |
|
104 // This is temporary fix for ou1cimx1#228810 |
|
105 // Can be removed when avkon provides real fix for this error. |
|
106 // Currently forever loop in CFormattedCellListBoxData::DrawFormattedSimple |
|
107 // never exits if there is no iconarray and name contains tab+digit which |
|
108 // confuses listbox e.g. considering name as icon index |
|
109 CArrayPtr<CGulIcon>* dummyArray = new( ELeave ) CAknIconArray(2); |
|
110 CleanupStack::PushL(dummyArray); |
|
111 |
|
112 CFbsBitmap* dummyBmp = new(ELeave) CFbsBitmap; |
|
113 CleanupStack::PushL( dummyBmp ); |
|
114 User::LeaveIfError( dummyBmp->Create( TSize(0,0), EColor256 ) ); |
|
115 CGulIcon* dummyIcon = CGulIcon::NewL( dummyBmp ); |
|
116 CleanupStack::Pop( dummyBmp ); //ownership transfered |
|
117 CleanupStack::PushL( dummyIcon ); |
|
118 |
|
119 CFbsBitmap* dummyBmp2 = new(ELeave) CFbsBitmap; |
|
120 CleanupStack::PushL( dummyBmp2 ); |
|
121 User::LeaveIfError( dummyBmp2->Create( TSize(0,0), EColor256 ) ); |
|
122 CGulIcon* dummyIcon2 = CGulIcon::NewL( dummyBmp2 ); |
|
123 CleanupStack::Pop( dummyBmp2 ); //ownership transfered |
|
124 CleanupStack::PushL( dummyIcon2 ); |
|
125 |
|
126 dummyArray->AppendL(dummyIcon); |
|
127 dummyArray->AppendL(dummyIcon2); |
|
128 ColumnData()->SetIconArray(dummyArray); |
|
129 CleanupStack::Pop( dummyIcon2 ); |
|
130 CleanupStack::Pop( dummyIcon ); |
|
131 CleanupStack::Pop( dummyArray ); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------- |
|
135 // CWmListItemDrawer::~CWmListItemDrawer |
|
136 // --------------------------------------------------------- |
|
137 // |
|
138 CWmListItemDrawer::~CWmListItemDrawer() |
|
139 { |
|
140 iCellData = NULL; |
|
141 iListBox = NULL; |
|
142 |
|
143 // dispose icons |
|
144 delete iDefaultLogoImage; |
|
145 delete iDefaultLogoImageMask; |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------- |
|
149 // CWmListItemDrawer::UpdateItemHeight |
|
150 // --------------------------------------------------------- |
|
151 // |
|
152 void CWmListItemDrawer::UpdateItemHeight() |
|
153 { |
|
154 // sets item height according to layout |
|
155 TAknWindowLineLayout listPane = AknLayoutScalable_Apps |
|
156 ::list_wgtman_pane().LayoutLine(); |
|
157 TAknLayoutRect listPaneRect; |
|
158 listPaneRect.LayoutRect( iListBox->Rect(), listPane ); |
|
159 |
|
160 TAknWindowLineLayout listRowPane = AknLayoutScalable_Apps |
|
161 ::listrow_wgtman_pane().LayoutLine(); |
|
162 TAknLayoutRect listRowPaneRect; |
|
163 listRowPaneRect.LayoutRect( listPaneRect.Rect(), listRowPane ); |
|
164 TRect itemRect = listRowPaneRect.Rect(); |
|
165 TRAP_IGNORE( iListBox->SetItemHeightL( itemRect.Height() ); ); |
|
166 iListBox->View()->ItemDrawer()->SetItemCellSize( itemRect.Size() ); |
|
167 |
|
168 // update view rect according to layout ( ou1cimx1#402776 ) |
|
169 iListBox->View()->SetViewRect( listPaneRect.Rect() ); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // CWmListItemDrawer::DrawItem |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 void CWmListItemDrawer::DrawItem( TInt aItemIndex, TPoint aItemRectPos, |
|
177 TBool /*aItemIsSelected*/, TBool aItemIsCurrent, |
|
178 TBool /*aViewIsEmphasized*/, TBool aViewIsDimmed ) const |
|
179 { |
|
180 TSize cellSize = ItemCellSize(); |
|
181 |
|
182 CWmWidgetData& wData = iListBox->WidgetData( aItemIndex ); |
|
183 // Get graphics context which is used for drawing. |
|
184 CWindowGc& gc = *Gc(); |
|
185 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
186 TBool highlightEnabled = !( iListBox->ItemDrawer()->Flags() & |
|
187 CListItemDrawer::ESingleClickDisabledHighlight ); |
|
188 TBool listFocused = ((iListBox->IsFocused() && !aViewIsDimmed) ? ETrue : EFalse); |
|
189 TRect itemRect = TRect( aItemRectPos, cellSize ); |
|
190 |
|
191 CFormattedCellListBoxItemDrawer::DrawEmptyItem( |
|
192 aItemIndex, aItemRectPos, aViewIsDimmed ); |
|
193 |
|
194 if ( aItemIsCurrent && listFocused && highlightEnabled ) |
|
195 { |
|
196 TRect innerRect( itemRect ); |
|
197 const TInt highlightOffset = 5; |
|
198 innerRect.Shrink( highlightOffset, highlightOffset ); |
|
199 |
|
200 AknsDrawUtils::DrawFrame( skin, |
|
201 gc, |
|
202 itemRect, |
|
203 innerRect, |
|
204 KAknsIIDQsnFrList, |
|
205 KAknsIIDQsnFrListCenter ); |
|
206 } |
|
207 // DRAW LOGO |
|
208 CFbsBitmap* bitmap = const_cast<CFbsBitmap*>(wData.LogoImage()); |
|
209 CFbsBitmap* mask = const_cast<CFbsBitmap*>(wData.LogoImageMask()); |
|
210 TAknLayoutRect logoLayout; |
|
211 logoLayout.LayoutRect( itemRect, |
|
212 AknLayoutScalable_Apps::listrow_wgtman_pane_g1().LayoutLine() ); |
|
213 if ( ( !bitmap || !mask ) && iDefaultLogoImage && iDefaultLogoImageMask ) |
|
214 { |
|
215 // real logo missing use default |
|
216 TSize size = logoLayout.Rect().Size(); |
|
217 if ( iDefaultLogoImage->SizeInPixels() != size ) |
|
218 { |
|
219 // Resize default icons only when they are really needed |
|
220 AknIconUtils::SetSize( |
|
221 iDefaultLogoImage, size, EAspectRatioPreserved ); |
|
222 AknIconUtils::SetSize( |
|
223 iDefaultLogoImageMask, size, EAspectRatioPreserved ); |
|
224 } |
|
225 |
|
226 gc.DrawBitmapMasked( logoLayout.Rect(), |
|
227 iDefaultLogoImage, |
|
228 TRect(TPoint(0, 0), iDefaultLogoImage->SizeInPixels()), |
|
229 iDefaultLogoImageMask, |
|
230 EFalse ); |
|
231 } |
|
232 else if( bitmap && mask ) |
|
233 { |
|
234 gc.DrawBitmapMasked( logoLayout.Rect(), |
|
235 bitmap, |
|
236 TRect(TPoint(0, 0), bitmap->SizeInPixels()), |
|
237 mask, |
|
238 ETrue ); |
|
239 } |
|
240 |
|
241 // DRAW NAME |
|
242 TRgb textColor; |
|
243 TAknsQsnTextColorsIndex index = |
|
244 ( aItemIsCurrent && listFocused && highlightEnabled )? |
|
245 EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG6; |
|
246 |
|
247 AknsUtils::GetCachedColor( |
|
248 skin, textColor, KAknsIIDQsnTextColors, index ); |
|
249 |
|
250 TAknTextLineLayout titleTextLayout; |
|
251 if ( !wData.IsUninstalling() ) |
|
252 { |
|
253 // centered 1 row layout |
|
254 titleTextLayout = |
|
255 AknLayoutScalable_Apps::listrow_wgtman_pane_t1(1).LayoutLine(); |
|
256 } |
|
257 else |
|
258 { |
|
259 // 2 row layout for uninstalling |
|
260 titleTextLayout = |
|
261 AknLayoutScalable_Apps::listrow_wgtman_pane_t1(0).LayoutLine(); |
|
262 } |
|
263 |
|
264 TAknLayoutText textLayoutTitle; |
|
265 textLayoutTitle.LayoutText( itemRect, titleTextLayout ); |
|
266 textLayoutTitle.DrawText( gc, wData.Name(), ETrue, textColor ); |
|
267 |
|
268 if ( wData.IsUninstalling() ) |
|
269 { |
|
270 // DRAW UNINSTALL ANIMATION |
|
271 TAknLayoutRect animationLayout; |
|
272 animationLayout.LayoutRect( itemRect, |
|
273 AknLayoutScalable_Apps::wait_bar_pane_cp09().LayoutLine() ); |
|
274 TSize size = animationLayout.Rect().Size(); |
|
275 CFbsBitmap* animBitmap = |
|
276 const_cast<CFbsBitmap*>(wData.AnimationBitmap( size )); |
|
277 CFbsBitmap* animMask = |
|
278 const_cast<CFbsBitmap*>(wData.AnimationMask( size )); |
|
279 if ( animBitmap && animMask ) |
|
280 { |
|
281 animationLayout.DrawImage( gc, animBitmap, animMask ); |
|
282 } |
|
283 } |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------- |
|
287 // CWmListItemDrawer::DefaultLogoImage() |
|
288 // --------------------------------------------------------- |
|
289 // |
|
290 const CFbsBitmap* CWmListItemDrawer::DefaultLogoImage() |
|
291 { |
|
292 return iDefaultLogoImage; |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------- |
|
296 // CWmListItemDrawer::DefaultLogoMask() |
|
297 // --------------------------------------------------------- |
|
298 // |
|
299 const CFbsBitmap* CWmListItemDrawer::DefaultLogoMask() |
|
300 { |
|
301 return iDefaultLogoImageMask; |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------- |
|
305 // CWmListBox::NewL |
|
306 // --------------------------------------------------------- |
|
307 // |
|
308 CWmListBox* CWmListBox::NewL( |
|
309 CWmPlugin& aWmPlugin, |
|
310 const TRect& aRect, |
|
311 const CCoeControl* aParent, |
|
312 TInt aFlags ) |
|
313 { |
|
314 CWmListBox* self = new ( ELeave ) CWmListBox( aWmPlugin); |
|
315 CleanupStack::PushL( self ); |
|
316 self->ConstructL( aRect, aParent, aFlags ); |
|
317 CleanupStack::Pop( self ); |
|
318 return self; |
|
319 } |
|
320 |
|
321 // --------------------------------------------------------- |
|
322 // CWmListBox::CWmListBox |
|
323 // --------------------------------------------------------- |
|
324 // |
|
325 CWmListBox::CWmListBox( CWmPlugin& aWmPlugin ): |
|
326 CEikFormattedCellListBox(), |
|
327 iWmPlugin( aWmPlugin ) |
|
328 { |
|
329 iFindPaneIsVisible = EFalse; |
|
330 iLogoSize = TSize( 0, 0); |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------- |
|
334 // CWmListBox::~CWmListBox |
|
335 // --------------------------------------------------------- |
|
336 // |
|
337 CWmListBox::~CWmListBox() |
|
338 { |
|
339 iVisibleWidgetArray.ResetAndDestroy(); |
|
340 iOrderDataArray.ResetAndDestroy(); |
|
341 } |
|
342 |
|
343 // --------------------------------------------------------- |
|
344 // CWmListBox::ConstructL |
|
345 // --------------------------------------------------------- |
|
346 // |
|
347 void CWmListBox::ConstructL( |
|
348 const TRect& aRect, |
|
349 const CCoeControl* aParent, |
|
350 TInt aFlags ) |
|
351 { |
|
352 CEikFormattedCellListBox::ConstructL( aParent, aFlags ); |
|
353 SetContainerWindowL( *aParent ); |
|
354 |
|
355 // set model point to the widgets array |
|
356 Model()->SetItemTextArray( &iVisibleWidgetArray ); |
|
357 Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
358 |
|
359 // set empty-text to null |
|
360 View()->SetListEmptyTextL( KNullDesC ); |
|
361 |
|
362 SetRect( aRect ); |
|
363 } |
|
364 |
|
365 // --------------------------------------------------------- |
|
366 // CWmListBox::WidgetData |
|
367 // --------------------------------------------------------- |
|
368 // |
|
369 CWmWidgetData* CWmListBox::WidgetData() |
|
370 { |
|
371 TInt index = CurrentListBoxItemIndex(); |
|
372 return (index>=0 ? iVisibleWidgetArray[index] : NULL); |
|
373 } |
|
374 |
|
375 // --------------------------------------------------------- |
|
376 // CWmListBox::WidgetData |
|
377 // --------------------------------------------------------- |
|
378 // |
|
379 CWmWidgetData& CWmListBox::WidgetData( TInt aItemIndex, TBool aIgnoreSearchIndex ) |
|
380 { |
|
381 return *iVisibleWidgetArray[ RealIndex( aItemIndex, aIgnoreSearchIndex ) ]; |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------- |
|
385 // CWmListBox::AddWidgetDataL |
|
386 // --------------------------------------------------------- |
|
387 // |
|
388 void CWmListBox::AddWidgetDataL( CWmWidgetData* aWidgetData, |
|
389 TBool aRedraw ) |
|
390 { |
|
391 if ( aWidgetData ) |
|
392 { |
|
393 aWidgetData->SetObserver( this ); |
|
394 iVisibleWidgetArray.InsertInOrderAllowRepeatsL( aWidgetData, |
|
395 SortOrder(EStoredOrder) ); |
|
396 if ( aRedraw ) { HandleItemAdditionL(); } |
|
397 } |
|
398 } |
|
399 |
|
400 // --------------------------------------------------------- |
|
401 // CWmListBox::RemoveWidgetData |
|
402 // --------------------------------------------------------- |
|
403 // |
|
404 void CWmListBox::RemoveWidgetData( TInt aItemIndex, TBool aIgnoreSearchIndex ) |
|
405 { |
|
406 TInt realIndex = RealIndex( aItemIndex, aIgnoreSearchIndex ); |
|
407 TBool current = ( aItemIndex == CurrentItemIndex() ); |
|
408 // remove widget data |
|
409 CWmWidgetData* data = iVisibleWidgetArray[realIndex]; |
|
410 iVisibleWidgetArray.Remove( realIndex ); |
|
411 |
|
412 |
|
413 // Remove item from order array |
|
414 for ( TInt i = 0; i < iOrderDataArray.Count(); i++ ) |
|
415 { |
|
416 CWmWidgetOrderData* order = iOrderDataArray[i]; |
|
417 if ( order->EqualsTo( data->Uid(), data->PublisherId() ) ) |
|
418 { |
|
419 iOrderDataArray.Remove( i ); |
|
420 delete order; |
|
421 order = NULL; |
|
422 break; |
|
423 } |
|
424 } |
|
425 |
|
426 if ( aIgnoreSearchIndex ) |
|
427 { |
|
428 // reorganise |
|
429 TRAP_IGNORE( |
|
430 AknListBoxUtils::HandleItemRemovalAndPositionHighlightL( |
|
431 this, realIndex, current ) ); |
|
432 |
|
433 } |
|
434 // delete now |
|
435 delete data; |
|
436 data = NULL; |
|
437 } |
|
438 |
|
439 // --------------------------------------------------------- |
|
440 // CWmListBox::RedrawItem |
|
441 // --------------------------------------------------------- |
|
442 // |
|
443 void CWmListBox::RedrawItem( TInt aItemIndex ) |
|
444 { |
|
445 if ( aItemIndex >= 0 && |
|
446 aItemIndex < Model()->NumberOfItems() ) |
|
447 { |
|
448 View()->DrawItem( aItemIndex ); |
|
449 } |
|
450 } |
|
451 |
|
452 // --------------------------------------------------------- |
|
453 // CWmListBox::SetSortOrderL |
|
454 // --------------------------------------------------------- |
|
455 // |
|
456 void CWmListBox::DoSortToVisibleArray( TSortOrder aOrder ) |
|
457 { |
|
458 // now sort the existing data |
|
459 iVisibleWidgetArray.Sort( SortOrder( aOrder ) ); |
|
460 DrawNow(); |
|
461 } |
|
462 |
|
463 // --------------------------------------------------------- |
|
464 // CWmListBox::CreateItemDrawerL |
|
465 // --------------------------------------------------------- |
|
466 // |
|
467 void CWmListBox::CreateItemDrawerL() |
|
468 { |
|
469 CFormattedCellListBoxData* cellData = CFormattedCellListBoxData::NewL(); |
|
470 CleanupStack::PushL( cellData ); |
|
471 iItemDrawer = CWmListItemDrawer::NewL( |
|
472 iWmPlugin, |
|
473 Model(), |
|
474 iEikonEnv->DenseFont(), |
|
475 cellData, |
|
476 this ); |
|
477 CleanupStack::Pop(); // cellData |
|
478 } |
|
479 |
|
480 // --------------------------------------------------------- |
|
481 // CWmListBox::HandleLayoutChanged |
|
482 // --------------------------------------------------------- |
|
483 // |
|
484 void CWmListBox::HandleLayoutChanged() |
|
485 { |
|
486 iLogoSize = TSize( 0, 0); |
|
487 iLogoSize = LogoSize(); |
|
488 for ( TInt i=0; i<iVisibleWidgetArray.Count(); i++) |
|
489 { |
|
490 iVisibleWidgetArray[i]->UpdateLogo( iLogoSize, EFalse ); |
|
491 } |
|
492 } |
|
493 |
|
494 // --------------------------------------------------------- |
|
495 // CWmListBox::HandleWidgetDataChanged |
|
496 // --------------------------------------------------------- |
|
497 // |
|
498 void CWmListBox::HandleWidgetDataChanged( CWmWidgetData* aWidgetData ) |
|
499 { |
|
500 if ( !iFindPaneIsVisible ) |
|
501 { |
|
502 // spontaneous change in the model. Cause table to redraw |
|
503 TInt index = iVisibleWidgetArray.Find( aWidgetData ); |
|
504 if ( index >= 0 ) |
|
505 { |
|
506 // redraw item. |
|
507 RedrawItem( RealIndex( index ) ); |
|
508 } |
|
509 } |
|
510 else |
|
511 { |
|
512 // redraw everything |
|
513 Parent()->DrawDeferred(); |
|
514 } |
|
515 } |
|
516 |
|
517 // --------------------------------------------------------- |
|
518 // CWmListBox::SortOrder |
|
519 // --------------------------------------------------------- |
|
520 // |
|
521 TLinearOrder<CWmWidgetData> CWmListBox::SortOrder( TSortOrder aOrder ) |
|
522 { |
|
523 if ( aOrder == EStoredOrder ) |
|
524 { |
|
525 return TLinearOrder<CWmWidgetData>( |
|
526 CWmWidgetData::CompareByPersistentWidgetOrder ); |
|
527 } |
|
528 else |
|
529 { |
|
530 return TLinearOrder<CWmWidgetData>( |
|
531 CWmWidgetData::CompareByName ); |
|
532 } |
|
533 } |
|
534 |
|
535 // --------------------------------------------------------- |
|
536 // CWmListBox::CurrentListBoxItemIndex |
|
537 // --------------------------------------------------------- |
|
538 // |
|
539 TInt CWmListBox::CurrentListBoxItemIndex() |
|
540 { |
|
541 TInt index( KErrNotFound ); |
|
542 if ( Model()->NumberOfItems() > 0 ) |
|
543 { |
|
544 index = CurrentItemIndex(); |
|
545 } |
|
546 return RealIndex( index ); |
|
547 } |
|
548 |
|
549 // --------------------------------------------------------- |
|
550 // CWmListBox::RealIndex |
|
551 // --------------------------------------------------------- |
|
552 // |
|
553 TInt CWmListBox::RealIndex( TInt aIndex, TBool aIgnoreSearchIndex ) |
|
554 { |
|
555 TInt realIndex = aIndex; |
|
556 if ( ( iFindPaneIsVisible && aIndex >= 0 ) && !aIgnoreSearchIndex ) |
|
557 { |
|
558 realIndex = static_cast<CAknFilteredTextListBoxModel*>(Model())->Filter() |
|
559 ->FilteredItemIndex( aIndex ); |
|
560 } |
|
561 return realIndex; |
|
562 } |
|
563 |
|
564 // --------------------------------------------------------- |
|
565 // CWmListBox::SizeChanged |
|
566 // --------------------------------------------------------- |
|
567 // |
|
568 void CWmListBox::SizeChanged() |
|
569 { |
|
570 CEikFormattedCellListBox::SizeChanged(); |
|
571 |
|
572 CWmListItemDrawer* itemDrawer = |
|
573 static_cast <CWmListItemDrawer*>( iItemDrawer ); |
|
574 if ( itemDrawer ) |
|
575 { |
|
576 itemDrawer->UpdateItemHeight(); |
|
577 } |
|
578 } |
|
579 |
|
580 // --------------------------------------------------------- |
|
581 // CWmListBox::Draw |
|
582 // --------------------------------------------------------- |
|
583 // |
|
584 void CWmListBox::Draw( const TRect& aRect ) const |
|
585 { |
|
586 CWindowGc& gc = SystemGc(); |
|
587 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
588 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
589 AknsDrawUtils::Background( skin, cc, this, gc, Rect() ); |
|
590 CEikFormattedCellListBox::Draw( aRect ); |
|
591 } |
|
592 |
|
593 // --------------------------------------------------------- |
|
594 // CWmListBox::LogoSize |
|
595 // --------------------------------------------------------- |
|
596 // |
|
597 TSize CWmListBox::LogoSize() |
|
598 { |
|
599 TSize size( iLogoSize ); |
|
600 if ( size.iWidth == 0 || size.iHeight == 0 ) |
|
601 { |
|
602 TAknLayoutRect rowLayoutRect; |
|
603 rowLayoutRect.LayoutRect( Rect(), |
|
604 AknLayoutScalable_Apps::listrow_wgtman_pane().LayoutLine() ); |
|
605 TAknLayoutRect logoLayoutRect; |
|
606 logoLayoutRect.LayoutRect( rowLayoutRect.Rect(), |
|
607 AknLayoutScalable_Apps::listrow_wgtman_pane_g1().LayoutLine() ); |
|
608 size = logoLayoutRect.Rect().Size(); |
|
609 iLogoSize = size; |
|
610 } |
|
611 return size; |
|
612 } |
|
613 |
|
614 |
|
615 // --------------------------------------------------------- |
|
616 // CWmListBox::DefaultLogo |
|
617 // --------------------------------------------------------- |
|
618 // |
|
619 const CFbsBitmap* CWmListBox::DefaultLogo() |
|
620 { |
|
621 CWmListItemDrawer* itemDrawer = |
|
622 static_cast <CWmListItemDrawer*>( iItemDrawer ); |
|
623 if ( itemDrawer ) |
|
624 { |
|
625 return itemDrawer->DefaultLogoImage(); |
|
626 } |
|
627 return NULL; |
|
628 } |
|
629 |
|
630 // --------------------------------------------------------- |
|
631 // CWmListBox::DefaultMask |
|
632 // --------------------------------------------------------- |
|
633 // |
|
634 const CFbsBitmap* CWmListBox::DefaultMask() |
|
635 { |
|
636 CWmListItemDrawer* itemDrawer = |
|
637 static_cast <CWmListItemDrawer*>( iItemDrawer ); |
|
638 if ( itemDrawer ) |
|
639 { |
|
640 return itemDrawer->DefaultLogoMask(); |
|
641 } |
|
642 return NULL; |
|
643 } |
|
644 |
|
645 // --------------------------------------------------------- |
|
646 // CWmListBox::SortOrderToOrderData |
|
647 // --------------------------------------------------------- |
|
648 // |
|
649 TLinearOrder<CWmWidgetOrderData> CWmListBox::SortOrderToOrderData( TSortOrder aOrder ) |
|
650 { |
|
651 if ( aOrder == EStoredOrder ) |
|
652 { |
|
653 return TLinearOrder<CWmWidgetOrderData>( |
|
654 CWmWidgetOrderData::CompareByPersistentWidgetOrder ); |
|
655 } |
|
656 else |
|
657 { |
|
658 return TLinearOrder<CWmWidgetOrderData>( |
|
659 CWmWidgetOrderData::CompareByName ); |
|
660 } |
|
661 } |
|
662 |
|
663 // --------------------------------------------------------- |
|
664 // CWmListBox::SetSortOrderToOrderDataL |
|
665 // --------------------------------------------------------- |
|
666 // |
|
667 void CWmListBox::DoSortToOrderData( TSortOrder aOrder ) |
|
668 { |
|
669 iOrderDataArray.Sort( SortOrderToOrderData( aOrder ) ); |
|
670 } |
|
671 |
|
672 // --------------------------------------------------------- |
|
673 // CWmListBox::AddWidgetDataL |
|
674 // --------------------------------------------------------- |
|
675 // |
|
676 void CWmListBox::AddOrderDataL( CWmWidgetOrderData* aOrderData ) |
|
677 { |
|
678 if ( aOrderData ) |
|
679 { |
|
680 iOrderDataArray.InsertInOrderAllowRepeatsL( aOrderData, |
|
681 SortOrderToOrderData( EStoredOrder ) ); |
|
682 } |
|
683 } |
|
684 |
|
685 // --------------------------------------------------------- |
|
686 // CWmListBox::OrderData |
|
687 // --------------------------------------------------------- |
|
688 // |
|
689 CWmWidgetOrderData* CWmListBox::OrderData( TInt aItemIndex ) |
|
690 { |
|
691 return iOrderDataArray[ aItemIndex ]; |
|
692 } |
|
693 // End of File |
|
694 |