|
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 <StringLoader.h> |
|
22 #include <aknstyluspopupmenu.h> |
|
23 #include <AknsDrawUtils.h> |
|
24 #include <AknsFrameBackgroundControlContext.h> |
|
25 #include <AknsListBoxBackgroundControlContext.h> |
|
26 |
|
27 #include <widgetmanagerview.rsg> |
|
28 #include <widgetmanager.mbg> |
|
29 #include "wmcommon.h" |
|
30 #include "wmplugin.h" |
|
31 #include "wmresourceloader.h" |
|
32 #include "wmlistbox.h" |
|
33 #include "wmwidgetdata.h" |
|
34 |
|
35 // CONSTANTS |
|
36 const TInt KFrameRoundRadius = 4; |
|
37 const TInt KFocusFrameWidth = 2; |
|
38 const TInt KLeftMarginBig = 5; |
|
39 const TInt KRightMargin = 1; |
|
40 const TInt KTopTextMargin = 2; |
|
41 const TInt KRightTextMargin = 3; |
|
42 const TInt KRightMarginBig = 5; |
|
43 const TInt KTopMargin = 1; |
|
44 const TInt KTopMarginBig = 5; |
|
45 const TInt KBottomMargin = 1; |
|
46 const TInt KBottomMarginBig = 5; |
|
47 const TInt KLogoWidth = 55; |
|
48 const TInt KLogoHeight = 55; |
|
49 |
|
50 // MEMBER FUNCTIONS |
|
51 |
|
52 // --------------------------------------------------------- |
|
53 // CWmListItemDrawer::NewL |
|
54 // --------------------------------------------------------- |
|
55 // |
|
56 CWmListItemDrawer* CWmListItemDrawer::NewL( |
|
57 CWmPlugin& aWmPlugin, |
|
58 MTextListBoxModel* aTextListBoxModel, |
|
59 const CFont* aFont, |
|
60 CFormattedCellListBoxData* aFormattedCellData, |
|
61 CWmListBox* aListBox ) |
|
62 { |
|
63 CWmListItemDrawer* self = new ( ELeave ) CWmListItemDrawer( |
|
64 aWmPlugin, |
|
65 aTextListBoxModel, |
|
66 aFont, |
|
67 aFormattedCellData, |
|
68 aListBox ); |
|
69 CleanupStack::PushL(self); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop(self); |
|
72 return self; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // CWmListItemDrawer::CWmListItemDrawer |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 CWmListItemDrawer::CWmListItemDrawer( |
|
80 CWmPlugin& aWmPlugin, |
|
81 MTextListBoxModel* aTextListBoxModel, |
|
82 const CFont* aFont, |
|
83 CFormattedCellListBoxData* aFormattedCellData, |
|
84 CWmListBox* aListBox ) |
|
85 : CFormattedCellListBoxItemDrawer( aTextListBoxModel,aFont,aFormattedCellData ), |
|
86 iWmPlugin( aWmPlugin ) |
|
87 { |
|
88 iCellData = aFormattedCellData; |
|
89 iListBox = aListBox; |
|
90 iFont = aFont; |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CWmListItemDrawer::ConstructL |
|
95 // --------------------------------------------------------- |
|
96 // |
|
97 void CWmListItemDrawer::ConstructL() |
|
98 { |
|
99 SetSkinEnabledL( ETrue ); |
|
100 |
|
101 AknsUtils::CreateIconL( |
|
102 AknsUtils::SkinInstance(), |
|
103 KAknsIIDQgnMenuHswidget, |
|
104 iDefaultLogoImage, |
|
105 iDefaultLogoImageMask, |
|
106 iWmPlugin.ResourceLoader().IconFilePath(), |
|
107 EMbmWidgetmanagerQgn_menu_hswidget, |
|
108 EMbmWidgetmanagerQgn_menu_hswidget_mask |
|
109 ); |
|
110 |
|
111 AknsUtils::CreateIconL( |
|
112 AknsUtils::SkinInstance(), |
|
113 KAknsIIDQgnIndiWmAdd, |
|
114 iAddWidgetBtnImage, |
|
115 iAddWidgetBtnMask, |
|
116 iWmPlugin.ResourceLoader().IconFilePath(), |
|
117 EMbmWidgetmanagerAdd_widget_button, |
|
118 EMbmWidgetmanagerAdd_widget_button_mask |
|
119 ); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // CWmListItemDrawer::~CWmListItemDrawer |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 CWmListItemDrawer::~CWmListItemDrawer() |
|
127 { |
|
128 iCellData = NULL; |
|
129 iListBox = NULL; |
|
130 |
|
131 // dispose icons |
|
132 delete iDefaultLogoImage; |
|
133 delete iDefaultLogoImageMask; |
|
134 delete iAddWidgetBtnImage; |
|
135 delete iAddWidgetBtnMask; |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------- |
|
139 // CWmListItemDrawer::CalculateRectangles |
|
140 // --------------------------------------------------------- |
|
141 // |
|
142 void CWmListItemDrawer::CalculateRectangles( const TSize& aSize ) |
|
143 { |
|
144 iCurrentSize = aSize; |
|
145 |
|
146 // LOGO RECT |
|
147 TSize logoSize = iListBox->LogoSize(); |
|
148 TInt val = ( aSize.iHeight - KBottomMarginBig * 4 ); |
|
149 TSize newSize( val, val ); |
|
150 if ( logoSize != newSize || |
|
151 logoSize.iHeight >= aSize.iHeight ) |
|
152 { |
|
153 logoSize = newSize; |
|
154 } |
|
155 iRelativeLogoRect.SetRect( |
|
156 TPoint( KLeftMarginBig, KTopMarginBig ), |
|
157 TSize( logoSize ) ); |
|
158 |
|
159 // ADD BUTTON RECT |
|
160 TInt btnWidth = ( aSize.iWidth / 7 ); |
|
161 TInt btnHeight = ( aSize.iHeight / 3 ); |
|
162 TPoint btnLocation( |
|
163 ( aSize.iWidth - KRightMarginBig - btnWidth ), |
|
164 ( aSize.iHeight / 2 - btnHeight / 2 ) ); |
|
165 iRelativeAddButtonRect.SetRect( btnLocation, TSize( btnWidth, btnHeight ) ); |
|
166 |
|
167 // TEXT RECT |
|
168 iRelativeTitleRect.SetRect( |
|
169 KLeftMarginBig + logoSize.iWidth + KRightMarginBig, |
|
170 KTopMargin, |
|
171 aSize.iWidth - KRightMargin - btnWidth - KRightMargin, |
|
172 aSize.iHeight - KBottomMargin - KBottomMargin ); |
|
173 |
|
174 // RESIZE BITMAPS |
|
175 AknIconUtils::SetSize( |
|
176 iDefaultLogoImage, iRelativeLogoRect.Size(), EAspectRatioNotPreserved ); |
|
177 AknIconUtils::SetSize( |
|
178 iDefaultLogoImageMask, iRelativeLogoRect.Size(), EAspectRatioNotPreserved ); |
|
179 AknIconUtils::SetSize( |
|
180 iAddWidgetBtnImage, iRelativeAddButtonRect.Size(), EAspectRatioNotPreserved ); |
|
181 AknIconUtils::SetSize( |
|
182 iAddWidgetBtnMask, iRelativeAddButtonRect.Size(), EAspectRatioNotPreserved ); |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------- |
|
186 // CWmListItemDrawer::DrawFrame |
|
187 // --------------------------------------------------------- |
|
188 // |
|
189 void CWmListItemDrawer::DrawFrame( |
|
190 const TRect& aOutterRect, |
|
191 const TRect& aInnerRect, |
|
192 const TAknsItemID& aID, |
|
193 const TAknsItemID& aCenterID ) const |
|
194 { |
|
195 CWindowGc& gc = *Gc(); |
|
196 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
197 AknsDrawUtils::DrawFrame( skin, gc, aOutterRect, aInnerRect, |
|
198 aID, aCenterID ); |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------- |
|
202 // CWmListItemDrawer::DrawItemRect |
|
203 // --------------------------------------------------------- |
|
204 // |
|
205 void CWmListItemDrawer::DrawItemRect( |
|
206 const TRect& aActualItemRect ) const |
|
207 { |
|
208 CWindowGc& gc = *Gc(); |
|
209 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
210 MAknsControlContext *cc = AknsDrawUtils::ControlContext( iListBox ); |
|
211 AknsDrawUtils::Background( skin, cc, iListBox, gc, aActualItemRect ); |
|
212 } |
|
213 |
|
214 // --------------------------------------------------------- |
|
215 // CWmListItemDrawer::DrawItem |
|
216 // --------------------------------------------------------- |
|
217 // |
|
218 void CWmListItemDrawer::DrawItem( TInt aItemIndex, TPoint aItemRectPos, |
|
219 TBool /*aItemIsSelected*/, TBool /*aItemIsCurrent*/, |
|
220 TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/ ) const |
|
221 { |
|
222 TInt w = ItemWidthInPixels( aItemIndex ); |
|
223 TInt h = iListBox->ItemHeight(); |
|
224 CWmWidgetData& wData = iListBox->WidgetData( aItemIndex ); |
|
225 if ( iCurrentSize != TSize(w,h) ) |
|
226 { |
|
227 // re-calculate all rects |
|
228 // note: members are manipulated here, although this method is const! |
|
229 const_cast<CWmListItemDrawer&>(*this).CalculateRectangles( TSize(w,h) ); |
|
230 wData.SetLogoSize( iRelativeLogoRect.Size() ); |
|
231 } |
|
232 |
|
233 TInt selectedIndex = iListBox->CurrentItemIndex(); |
|
234 TBool isInFocus = ( selectedIndex == aItemIndex ); |
|
235 TBool listFocused = iListBox->IsFocused(); |
|
236 TRect itemRect = TRect( aItemRectPos, TSize( w, h ) ); |
|
237 TRect fullRect = TRect( aItemRectPos, |
|
238 TSize( iListBox->Rect().Width(), h ) ); |
|
239 |
|
240 DrawItemRect( fullRect ); |
|
241 |
|
242 TRect logoRect( iRelativeLogoRect ); |
|
243 logoRect.Move( aItemRectPos ); |
|
244 TRect addBtnRect( iRelativeAddButtonRect ); |
|
245 addBtnRect.Move( aItemRectPos ); |
|
246 TRect textRect( iRelativeTitleRect ); |
|
247 textRect.Move( aItemRectPos ); |
|
248 |
|
249 if ( isInFocus && listFocused ) |
|
250 { |
|
251 TRect innerRect( itemRect ); |
|
252 const TInt highlightOffset = 5; |
|
253 innerRect.Shrink( highlightOffset, highlightOffset ); |
|
254 DrawFrame( itemRect, innerRect, |
|
255 iListBox->PressedDown() ? |
|
256 KAknsIIDQsnFrListPressed : KAknsIIDQsnFrList, |
|
257 KAknsIIDQsnFrListCenter ); |
|
258 } |
|
259 |
|
260 // Get graphics context which is used for drawing. |
|
261 CWindowGc& gc = *Gc(); |
|
262 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
263 |
|
264 // DRAW LOGO |
|
265 CFbsBitmap* bitmap = const_cast<CFbsBitmap*>(wData.LogoImage()); |
|
266 CFbsBitmap* mask = const_cast<CFbsBitmap*>(wData.LogoImageMask()); |
|
267 if ( !bitmap ) |
|
268 { |
|
269 TRect bmpRect( TPoint(0,0), TSize( iDefaultLogoImage->SizeInPixels() ) ); |
|
270 gc.BitBltMasked( logoRect.iTl, iDefaultLogoImage, |
|
271 bmpRect, iDefaultLogoImageMask, ETrue ); |
|
272 } |
|
273 else |
|
274 { |
|
275 TRect bmpRect( TPoint(0,0), TSize( bitmap->SizeInPixels() ) ); |
|
276 if ( bitmap && mask ) |
|
277 { |
|
278 gc.BitBltMasked( logoRect.iTl, bitmap, |
|
279 bmpRect, mask, ETrue ); |
|
280 } |
|
281 else |
|
282 { |
|
283 gc.BitBlt( logoRect.iTl, bitmap, bmpRect ); |
|
284 } |
|
285 } |
|
286 |
|
287 TRgb textColor; |
|
288 TAknsQsnTextColorsIndex index = ( isInFocus && listFocused )? |
|
289 EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG6; |
|
290 |
|
291 AknsUtils::GetCachedColor( |
|
292 skin, textColor, KAknsIIDQsnTextColors, index ); |
|
293 |
|
294 // DRAW TEXT |
|
295 gc.UseFont( iFont ); |
|
296 gc.SetPenColor( textColor ); |
|
297 gc.SetPenSize( TSize(2,2) ); |
|
298 |
|
299 gc.DrawText( wData.Name(), textRect, |
|
300 ( KTopTextMargin + iFont->FontMaxHeight() ), |
|
301 CGraphicsContext::ELeft, KRightTextMargin ); |
|
302 |
|
303 if ( wData.HsContentInfo().CanBeAdded() ) |
|
304 { |
|
305 // DRAW ADD BUTTON |
|
306 gc.BitBltMasked( addBtnRect.iTl, iAddWidgetBtnImage, |
|
307 TRect( TPoint(0,0), iAddWidgetBtnImage->SizeInPixels() ), |
|
308 iAddWidgetBtnMask, ETrue ); |
|
309 |
|
310 // DRAW BUTTON FOCUS |
|
311 if ( isInFocus && listFocused ) |
|
312 { |
|
313 // draw focused frame around button if item is selected |
|
314 gc.SetPenStyle( CGraphicsContext::ESolidPen ); |
|
315 gc.SetPenSize( TSize( KFocusFrameWidth, KFocusFrameWidth ) ); |
|
316 //Draw the rounded rectangle |
|
317 gc.DrawRoundRect( addBtnRect, TSize( KFrameRoundRadius, KFrameRoundRadius ) ); |
|
318 gc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
319 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
320 } |
|
321 } |
|
322 |
|
323 gc.SetPenSize(TSize(1,1)); |
|
324 |
|
325 // DRAW DESCRIPTION TEXT |
|
326 HBufC* buf = wData.Description().Alloc(); |
|
327 if ( buf ) |
|
328 { |
|
329 TPtr bufPtr = buf->Des(); |
|
330 bufPtr.Copy( wData.Description() ); |
|
331 TextUtils::ClipToFit( bufPtr, *iFont, textRect.Width() ); |
|
332 gc.DrawText( bufPtr, textRect, |
|
333 ( iFont->HeightInPixels() + textRect.Height()/2 ), |
|
334 CGraphicsContext::ELeft, KRightTextMargin ); |
|
335 delete buf; |
|
336 } |
|
337 |
|
338 gc.DiscardFont(); |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------- |
|
342 // CWmListItemDrawer::DefaultLogoImage() |
|
343 // --------------------------------------------------------- |
|
344 // |
|
345 const CFbsBitmap* CWmListItemDrawer::DefaultLogoImage() |
|
346 { |
|
347 return iDefaultLogoImage; |
|
348 } |
|
349 |
|
350 // --------------------------------------------------------- |
|
351 // CWmListItemDrawer::DefaultLogoMask() |
|
352 // --------------------------------------------------------- |
|
353 // |
|
354 const CFbsBitmap* CWmListItemDrawer::DefaultLogoMask() |
|
355 { |
|
356 return iDefaultLogoImageMask; |
|
357 } |
|
358 |
|
359 // --------------------------------------------------------- |
|
360 // CWmListBox::NewL |
|
361 // --------------------------------------------------------- |
|
362 // |
|
363 CWmListBox* CWmListBox::NewL( |
|
364 CWmPlugin& aWmPlugin, |
|
365 const TRect& aRect, |
|
366 const CCoeControl* aParent, |
|
367 TInt aFlags ) |
|
368 { |
|
369 CWmListBox* self = new ( ELeave ) CWmListBox( aWmPlugin); |
|
370 CleanupStack::PushL( self ); |
|
371 self->ConstructL( aRect, aParent, aFlags ); |
|
372 CleanupStack::Pop( self ); |
|
373 return self; |
|
374 } |
|
375 |
|
376 // --------------------------------------------------------- |
|
377 // CWmListBox::CWmListBox |
|
378 // --------------------------------------------------------- |
|
379 // |
|
380 CWmListBox::CWmListBox( CWmPlugin& aWmPlugin ): |
|
381 CAknDouble2LargeStyleListBox(), |
|
382 iWmPlugin( aWmPlugin ) |
|
383 { |
|
384 iFindPaneIsVisible = EFalse; |
|
385 iPressedDown = EFalse; |
|
386 } |
|
387 |
|
388 // --------------------------------------------------------- |
|
389 // CWmListBox::~CWmListBox |
|
390 // --------------------------------------------------------- |
|
391 // |
|
392 CWmListBox::~CWmListBox() |
|
393 { |
|
394 iWidgetDatas.ResetAndDestroy(); |
|
395 } |
|
396 |
|
397 // --------------------------------------------------------- |
|
398 // CWmListBox::ConstructL |
|
399 // --------------------------------------------------------- |
|
400 // |
|
401 void CWmListBox::ConstructL( |
|
402 const TRect& aRect, |
|
403 const CCoeControl* aParent, |
|
404 TInt aFlags ) |
|
405 { |
|
406 CEikFormattedCellListBox::ConstructL( aParent, aFlags ); |
|
407 SetContainerWindowL( *aParent ); |
|
408 |
|
409 // set model point to the widgets array |
|
410 Model()->SetItemTextArray( &iWidgetDatas ); |
|
411 Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
412 |
|
413 SetRect( aRect ); |
|
414 } |
|
415 |
|
416 // --------------------------------------------------------- |
|
417 // CWmListBox::WidgetData |
|
418 // --------------------------------------------------------- |
|
419 // |
|
420 CWmWidgetData* CWmListBox::WidgetData() |
|
421 { |
|
422 TInt index = CurrentListBoxItemIndex(); |
|
423 return (index>=0 ? iWidgetDatas[index] : NULL); |
|
424 } |
|
425 |
|
426 // --------------------------------------------------------- |
|
427 // CWmListBox::WidgetData |
|
428 // --------------------------------------------------------- |
|
429 // |
|
430 CWmWidgetData& CWmListBox::WidgetData( TInt aItemIndex ) |
|
431 { |
|
432 return *iWidgetDatas[ RealIndex( aItemIndex ) ]; |
|
433 } |
|
434 |
|
435 // --------------------------------------------------------- |
|
436 // CWmListBox::AddWidgetDataL |
|
437 // --------------------------------------------------------- |
|
438 // |
|
439 void CWmListBox::AddWidgetDataL( CWmWidgetData* aWidgetData ) |
|
440 { |
|
441 aWidgetData->SetObserver( this ); |
|
442 aWidgetData->SetLogoSize( LogoSize() ); |
|
443 iWidgetDatas.InsertInOrderAllowRepeatsL( aWidgetData, |
|
444 SortOrder(EStoredOrder) ); |
|
445 } |
|
446 |
|
447 // --------------------------------------------------------- |
|
448 // CWmListBox::RemoveWidgetData |
|
449 // --------------------------------------------------------- |
|
450 // |
|
451 void CWmListBox::RemoveWidgetData( TInt aItemIndex ) |
|
452 { |
|
453 TInt realIndex = RealIndex( aItemIndex ); |
|
454 TBool current = ( aItemIndex == CurrentItemIndex() ); |
|
455 // remove widget data |
|
456 CWmWidgetData* data = iWidgetDatas[realIndex]; |
|
457 iWidgetDatas.Remove( realIndex ); |
|
458 delete data; |
|
459 |
|
460 // reorganise |
|
461 TRAP_IGNORE( |
|
462 AknListBoxUtils::HandleItemRemovalAndPositionHighlightL( |
|
463 this, realIndex, current ) ); |
|
464 } |
|
465 |
|
466 // --------------------------------------------------------- |
|
467 // CWmListBox::RedrawItem |
|
468 // --------------------------------------------------------- |
|
469 // |
|
470 void CWmListBox::RedrawItem( TInt aItemIndex ) |
|
471 { |
|
472 View()->DrawItem( aItemIndex ); |
|
473 } |
|
474 |
|
475 // --------------------------------------------------------- |
|
476 // CWmListBox::SetSortOrderL |
|
477 // --------------------------------------------------------- |
|
478 // |
|
479 void CWmListBox::SetSortOrderL( TSortOrder aOrder ) |
|
480 { |
|
481 // now sort the existing data |
|
482 iWidgetDatas.Sort( SortOrder( aOrder ) ); |
|
483 DrawNow(); |
|
484 } |
|
485 |
|
486 // --------------------------------------------------------- |
|
487 // CWmListBox::CreateItemDrawerL |
|
488 // --------------------------------------------------------- |
|
489 // |
|
490 void CWmListBox::CreateItemDrawerL() |
|
491 { |
|
492 CFormattedCellListBoxData* cellData = CFormattedCellListBoxData::NewL(); |
|
493 CleanupStack::PushL( cellData ); |
|
494 iItemDrawer = CWmListItemDrawer::NewL( |
|
495 iWmPlugin, |
|
496 Model(), |
|
497 iEikonEnv->DenseFont(), |
|
498 cellData, |
|
499 this ); |
|
500 CleanupStack::Pop(); // cellData |
|
501 } |
|
502 |
|
503 // --------------------------------------------------------- |
|
504 // CWmListBox::HandleLayoutChanged |
|
505 // --------------------------------------------------------- |
|
506 // |
|
507 void CWmListBox::HandleLayoutChanged() |
|
508 { |
|
509 TSize ls = LogoSize(); |
|
510 for ( TInt i=0; i<iWidgetDatas.Count(); i++) |
|
511 { |
|
512 iWidgetDatas[i]->ReCreateLogo( ls ); |
|
513 } |
|
514 } |
|
515 |
|
516 // --------------------------------------------------------- |
|
517 // CWmListBox::HandleWidgetDataChanged |
|
518 // --------------------------------------------------------- |
|
519 // |
|
520 void CWmListBox::HandleWidgetDataChanged( CWmWidgetData* aWidgetData ) |
|
521 { |
|
522 if ( !iFindPaneIsVisible ) |
|
523 { |
|
524 // spontaneous change in the model. Cause table to redraw |
|
525 TInt index = iWidgetDatas.Find( aWidgetData ); |
|
526 if ( index >= 0 ) |
|
527 { |
|
528 // redraw item. |
|
529 RedrawItem( RealIndex( index ) ); |
|
530 } |
|
531 } |
|
532 } |
|
533 |
|
534 // --------------------------------------------------------- |
|
535 // CWmListBox::SortOrder |
|
536 // --------------------------------------------------------- |
|
537 // |
|
538 TLinearOrder<CWmWidgetData> CWmListBox::SortOrder( TSortOrder aOrder ) |
|
539 { |
|
540 if ( aOrder == EStoredOrder ) |
|
541 { |
|
542 return TLinearOrder<CWmWidgetData>( |
|
543 CWmWidgetData::CompareByPersistentWidgetOrder ); |
|
544 } |
|
545 else |
|
546 { |
|
547 return TLinearOrder<CWmWidgetData>( |
|
548 CWmWidgetData::CompareByName ); |
|
549 } |
|
550 } |
|
551 |
|
552 // --------------------------------------------------------- |
|
553 // CWmListBox::CurrentListBoxItemIndex |
|
554 // --------------------------------------------------------- |
|
555 // |
|
556 TInt CWmListBox::CurrentListBoxItemIndex() |
|
557 { |
|
558 TInt index( KErrNotFound ); |
|
559 if ( Model()->NumberOfItems() > 0 ) |
|
560 { |
|
561 index = CurrentItemIndex(); |
|
562 } |
|
563 return RealIndex( index ); |
|
564 } |
|
565 |
|
566 // --------------------------------------------------------- |
|
567 // CWmListBox::RealIndex |
|
568 // --------------------------------------------------------- |
|
569 // |
|
570 TInt CWmListBox::RealIndex( TInt aIndex ) |
|
571 { |
|
572 TInt realIndex = aIndex; |
|
573 if ( iFindPaneIsVisible && aIndex >= 0 ) |
|
574 { |
|
575 realIndex = static_cast<CAknFilteredTextListBoxModel*>(Model())->Filter() |
|
576 ->FilteredItemIndex( aIndex ); |
|
577 } |
|
578 return realIndex; |
|
579 } |
|
580 |
|
581 // --------------------------------------------------------- |
|
582 // CWmListBox::SizeChanged |
|
583 // --------------------------------------------------------- |
|
584 // |
|
585 void CWmListBox::SizeChanged() |
|
586 { |
|
587 CAknsListBoxBackgroundControlContext* context = |
|
588 static_cast<CAknsListBoxBackgroundControlContext*>( |
|
589 ItemDrawer()->FormattedCellData()-> |
|
590 SkinBackgroundContext() ); |
|
591 if ( context ) context->SetRect( Rect() ); |
|
592 CAknDouble2LargeStyleListBox::SizeChanged(); |
|
593 } |
|
594 |
|
595 // --------------------------------------------------------- |
|
596 // CWmListBox::Draw |
|
597 // --------------------------------------------------------- |
|
598 // |
|
599 void CWmListBox::Draw( const TRect& aRect ) const |
|
600 { |
|
601 CWindowGc& gc = SystemGc(); |
|
602 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
603 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
604 AknsDrawUtils::Background( skin, cc, this, gc, Rect() ); |
|
605 CAknDouble2LargeStyleListBox::Draw( aRect ); |
|
606 } |
|
607 |
|
608 // --------------------------------------------------------- |
|
609 // CWmListBox::HandlePointerEventL |
|
610 // --------------------------------------------------------- |
|
611 // |
|
612 void CWmListBox::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
613 { |
|
614 // Check if pointer is down ( needed for drawing correct hightlight frame ) |
|
615 if ( Rect().Contains( aPointerEvent.iPosition ) ) |
|
616 { |
|
617 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
618 { |
|
619 iPressedDown = ETrue; |
|
620 RedrawItem( CurrentListBoxItemIndex() ); |
|
621 } |
|
622 else if( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
623 { |
|
624 iPressedDown = EFalse; |
|
625 RedrawItem( CurrentListBoxItemIndex() ); |
|
626 } |
|
627 } |
|
628 |
|
629 CAknDouble2LargeStyleListBox::HandlePointerEventL( aPointerEvent ); |
|
630 } |
|
631 |
|
632 // --------------------------------------------------------- |
|
633 // CWmListBox::LogoSize |
|
634 // --------------------------------------------------------- |
|
635 // |
|
636 TSize CWmListBox::LogoSize() |
|
637 { |
|
638 TSize size( KLogoWidth,KLogoHeight ); |
|
639 TInt val = ( ItemHeight() - KBottomMarginBig * 4 ); |
|
640 if ( val > 0 ) |
|
641 { |
|
642 size.SetSize( val, val ); |
|
643 } |
|
644 return size; |
|
645 } |
|
646 |
|
647 // --------------------------------------------------------- |
|
648 // CWmListBox::DefaultLogo |
|
649 // --------------------------------------------------------- |
|
650 // |
|
651 const CFbsBitmap* CWmListBox::DefaultLogo() |
|
652 { |
|
653 CWmListItemDrawer* itemDrawer = |
|
654 static_cast <CWmListItemDrawer*>( iItemDrawer ); |
|
655 if ( itemDrawer ) |
|
656 { |
|
657 return itemDrawer->DefaultLogoImage(); |
|
658 } |
|
659 return NULL; |
|
660 } |
|
661 |
|
662 // --------------------------------------------------------- |
|
663 // CWmListBox::DefaultMask |
|
664 // --------------------------------------------------------- |
|
665 // |
|
666 const CFbsBitmap* CWmListBox::DefaultMask() |
|
667 { |
|
668 CWmListItemDrawer* itemDrawer = |
|
669 static_cast <CWmListItemDrawer*>( iItemDrawer ); |
|
670 if ( itemDrawer ) |
|
671 { |
|
672 return itemDrawer->DefaultLogoMask(); |
|
673 } |
|
674 return NULL; |
|
675 } |
|
676 |
|
677 // End of File |
|
678 |