|
1 /* |
|
2 * Copyright (c) 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 * Version : %version: MM_49 % << Don't touch! Updated by Synergy at check-out. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "mmlistboxview.h" |
|
22 #include "mmlistbox.h" |
|
23 #include "mmlistboxitemdrawer.h" |
|
24 #include "mmlistboxmodel.h" |
|
25 #include "hnsuitemodel.h" |
|
26 #include "hnitemsorder.h" |
|
27 #include <eikfrlb.h> |
|
28 #include <AknUtils.h> |
|
29 #include <eikfrlbd.h> |
|
30 #include <eikspmod.h> |
|
31 #include <aknlayoutscalable_avkon.cdl.h> |
|
32 #include <AknsDrawUtils.h> |
|
33 |
|
34 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
35 #include <aknlistboxtfx.h> |
|
36 #include <aknlistboxtfxinternal.h> |
|
37 #include <akntransitionutils.h> |
|
38 #include <aknlistloadertfx.h> |
|
39 #endif |
|
40 |
|
41 CMmListBoxView::CMmListBoxView () |
|
42 { |
|
43 // No implementation required |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CMmListBoxView::~CMmListBoxView () |
|
51 { |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CMmListBoxView* CMmListBoxView::NewLC () |
|
59 { |
|
60 CMmListBoxView* self = new (ELeave)CMmListBoxView(); |
|
61 CleanupStack::PushL (self); |
|
62 self->ConstructL (); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CMmListBoxView* CMmListBoxView::NewL () |
|
71 { |
|
72 CMmListBoxView* self=CMmListBoxView::NewLC (); |
|
73 CleanupStack::Pop( self ); |
|
74 return self; |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CMmListBoxView::ConstructL () |
|
82 { |
|
83 iScrollbarIsVisible = ETrue; |
|
84 iPreviouslyDrawnCurrentItemIndex = KErrNotFound; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CMmListBoxView::UpdateAverageItemHeight () |
|
92 { |
|
93 TInt count( iModel->NumberOfItems() ); |
|
94 if ( !count ) |
|
95 { |
|
96 SetItemHeight( 2 ); |
|
97 } |
|
98 else |
|
99 { |
|
100 TInt totalHeight = GetTotalHeight( 0, count - 1 ); |
|
101 TInt averageItemHeight = totalHeight / count; |
|
102 if ( totalHeight % count ) |
|
103 { |
|
104 ++averageItemHeight; |
|
105 // this ensures that it is always possible to |
|
106 // scroll to the very bottom of the view by |
|
107 // using scrollbar. |
|
108 } |
|
109 SetItemHeight( averageItemHeight ); |
|
110 } |
|
111 } |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 TInt CMmListBoxView::GetTotalHeight (const TInt aStartIndex, TInt aEndIndex) const |
|
117 { |
|
118 TInt totalHeight = 0; |
|
119 |
|
120 if ( aEndIndex >= 0) |
|
121 { |
|
122 TInt itemCount = iModel->NumberOfItems (); |
|
123 aEndIndex = (aEndIndex >= itemCount ) ? itemCount-1 : aEndIndex; |
|
124 CMmListBoxItemDrawer* drawer= STATIC_CAST( CMmListBoxItemDrawer*, iItemDrawer); |
|
125 for (TInt i(aStartIndex); i <= aEndIndex; i++) |
|
126 { |
|
127 totalHeight += drawer->GetItemHeight (i, CurrentItemIndex () == i); |
|
128 } |
|
129 } |
|
130 |
|
131 return totalHeight; |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 TInt CMmListBoxView::GetLastIndexInHeight (const TInt aStartIndex, TInt aHeight) const |
|
139 { |
|
140 TInt i = aStartIndex; |
|
141 TInt totalHeight = 0; |
|
142 |
|
143 TInt itemCount(iModel->NumberOfItems () ); |
|
144 CMmListBoxItemDrawer* drawer= STATIC_CAST( CMmListBoxItemDrawer*, iItemDrawer); |
|
145 |
|
146 for (; (i > -1) && (i < itemCount); i++) |
|
147 { |
|
148 totalHeight += drawer->GetItemHeight (i, CurrentItemIndex () == i); |
|
149 if ( totalHeight > aHeight) |
|
150 break; |
|
151 } |
|
152 |
|
153 TInt ret(i - aStartIndex); |
|
154 |
|
155 if ( !AknLayoutUtils::PenEnabled() && totalHeight > aHeight ) |
|
156 { |
|
157 ret--; // exclude partial item |
|
158 } |
|
159 |
|
160 return ret; |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 TInt CMmListBoxView::NumberOfItemsThatFitInRect(const TRect& aRect) const |
|
168 { |
|
169 return GetNumberOfItemsThatFitInRect( aRect, EFalse ); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 TInt CMmListBoxView::GetNumberOfItemsThatFitInRect (const TRect& aRect, |
|
177 TBool aIncludePartialItem ) const |
|
178 { |
|
179 TInt i = iTopItemIndex; |
|
180 TInt totalHeight = iVerticalOffset; |
|
181 |
|
182 TInt itemCount( iModel->NumberOfItems () ); |
|
183 CMmListBoxItemDrawer* drawer= STATIC_CAST( CMmListBoxItemDrawer*, iItemDrawer); |
|
184 while (totalHeight < aRect.Height ()) |
|
185 { |
|
186 totalHeight += ((i > -1) && (i < itemCount )) ? drawer->GetItemHeight ( |
|
187 i, CurrentItemIndex () == i) : iItemHeight; |
|
188 ++i; |
|
189 } |
|
190 |
|
191 TInt ret(i - iTopItemIndex); |
|
192 |
|
193 if ( !AknLayoutUtils::PenEnabled() && !aIncludePartialItem && totalHeight > aRect.Height() ) |
|
194 { |
|
195 ret--; // exclude partial item |
|
196 } |
|
197 |
|
198 return ret; |
|
199 } |
|
200 |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 void CMmListBoxView::CalcBottomItemIndex () |
|
207 { |
|
208 |
|
209 TInt numberOfVisibleItems = NumberOfItemsThatFitInRect( iViewRect ); |
|
210 iBottomItemIndex = Min( iTopItemIndex + numberOfVisibleItems - 1, |
|
211 iModel->NumberOfItems() ); |
|
212 |
|
213 // The next piece of code removes filtering from find box when |
|
214 // new list items are added. |
|
215 if ( Flags () & CListBoxView::EItemCountModified) |
|
216 { |
|
217 CAknFilteredTextListBoxModel *model= STATIC_CAST(CAknFilteredTextListBoxModel*,iModel); |
|
218 CAknListBoxFilterItems *filter = model ? model->Filter () : 0; |
|
219 if ( filter) |
|
220 { |
|
221 TRAP_IGNORE(filter->ResetFilteringL()); |
|
222 } |
|
223 } |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 void CMmListBoxView::Draw (const TRect* aClipRect) const |
|
231 { |
|
232 TBool drawingInitiated(EFalse); |
|
233 if ( CAknEnv::Static()->TransparencyEnabled() && |
|
234 iWin && iWin->GetDrawRect() == TRect::EUninitialized ) |
|
235 { |
|
236 TRect a(ViewRect()); |
|
237 if (!aClipRect || *aClipRect == TRect(0,0,0,0) ) |
|
238 { |
|
239 aClipRect = &a; |
|
240 } |
|
241 drawingInitiated=ETrue; |
|
242 iWin->Invalidate( *aClipRect ); |
|
243 iWin->BeginRedraw( *aClipRect ); |
|
244 } |
|
245 |
|
246 DoDraw(aClipRect); |
|
247 |
|
248 CMmListBoxItemDrawer* itemDrawer = |
|
249 static_cast<CMmListBoxItemDrawer*>(iItemDrawer ); |
|
250 if (aClipRect) |
|
251 { |
|
252 TRect rect(*aClipRect); |
|
253 rect.iTl.iY = ItemPos( BottomItemIndex() ).iY + ItemSize( BottomItemIndex() ).iHeight; |
|
254 |
|
255 // iGc->SetClippingRect( rect ); |
|
256 // removed to prevent non-redraw drawing. Was present to prevent out of view drawing when effects are on. |
|
257 // could be removed because effects were disabled at some point in edit mode to enhance performance. |
|
258 itemDrawer->DrawFloatingItems( rect ); |
|
259 // iGc->CancelClippingRect(); |
|
260 } |
|
261 |
|
262 if ( CAknEnv::Static()->TransparencyEnabled() && |
|
263 iWin && drawingInitiated ) |
|
264 { |
|
265 drawingInitiated = EFalse; |
|
266 iWin->EndRedraw( ); |
|
267 } |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 void CMmListBoxView::DoDraw(const TRect* aClipRect) const |
|
275 { |
|
276 CMmListBoxView* view= CONST_CAST( CMmListBoxView*, this ); |
|
277 view->UpdateAverageItemHeight (); |
|
278 |
|
279 CMmListBoxModel* model = static_cast< CMmListBoxModel* > ( iModel ); |
|
280 if ( model && model->GetSuiteModel() |
|
281 && !model->GetSuiteModel()->GetItemsOrder()->IsSuiteReadyToShow() ) |
|
282 { |
|
283 return; |
|
284 } |
|
285 |
|
286 if ( RedrawDisabled () || !IsVisible () ) |
|
287 { |
|
288 return; |
|
289 } |
|
290 |
|
291 TInt i = iTopItemIndex; |
|
292 CMmListBoxItemDrawer* itemDrawer = |
|
293 static_cast<CMmListBoxItemDrawer*>(iItemDrawer ); |
|
294 MAknsSkinInstance *skin = AknsUtils::SkinInstance (); |
|
295 CCoeControl* control = itemDrawer->FormattedCellData()->Control (); |
|
296 MAknsControlContext *cc = AknsDrawUtils::ControlContext (control); |
|
297 |
|
298 if ( !cc) |
|
299 { |
|
300 cc = itemDrawer->FormattedCellData()->SkinBackgroundContext (); |
|
301 } |
|
302 |
|
303 itemDrawer->SetTopItemIndex (iTopItemIndex); |
|
304 |
|
305 if ( iModel->NumberOfItems () > 0) |
|
306 { |
|
307 TBool drawingInitiated = ETrue; |
|
308 if ( CAknEnv::Static()->TransparencyEnabled () ) |
|
309 { |
|
310 if ( iWin && iWin->GetDrawRect () == TRect::EUninitialized) |
|
311 { |
|
312 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
313 MAknListBoxTfxInternal* transApi = |
|
314 CAknListLoader::TfxApiInternal( iGc ); |
|
315 drawingInitiated = transApi && !transApi->EffectsDisabled(); |
|
316 #else |
|
317 drawingInitiated = EFalse; |
|
318 #endif |
|
319 } |
|
320 |
|
321 if ( !drawingInitiated) |
|
322 { |
|
323 iWin->Invalidate ( *aClipRect); |
|
324 iWin->BeginRedraw ( *aClipRect); |
|
325 } |
|
326 } |
|
327 |
|
328 TInt lastPotentialItemIndex = Min (iModel->NumberOfItems (), |
|
329 iTopItemIndex + GetNumberOfItemsThatFitInRect( ViewRect (), ETrue ) ); |
|
330 while (i < lastPotentialItemIndex) |
|
331 { |
|
332 DrawItem(i++); |
|
333 } |
|
334 |
|
335 RedrawBackground(); |
|
336 |
|
337 if ( CAknEnv::Static()->TransparencyEnabled () && !drawingInitiated) |
|
338 { |
|
339 iWin->EndRedraw (); |
|
340 } |
|
341 } |
|
342 |
|
343 } |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 void CMmListBoxView::DrawItem (TInt aItemIndex) const |
|
350 { |
|
351 CMmListBoxItemDrawer* itemDrawer= STATIC_CAST( CMmListBoxItemDrawer*, iItemDrawer ); |
|
352 TBool currentChanged( CurrentItemIndex() != iPreviouslyDrawnCurrentItemIndex ); |
|
353 TBool redrawConsumed(EFalse); |
|
354 if ( currentChanged ) |
|
355 { |
|
356 CMmListBoxView* view= CONST_CAST( CMmListBoxView*, this ); |
|
357 redrawConsumed = |
|
358 static_cast<CMmListBox*> (itemDrawer->Widget())->RedrawIfNecessary( |
|
359 iPreviouslyDrawnCurrentItemIndex, |
|
360 CurrentItemIndex()); |
|
361 view->SetPreviouslyDrawnCurrentItemIndex( CurrentItemIndex() ); |
|
362 } |
|
363 |
|
364 if ( !redrawConsumed ) |
|
365 { |
|
366 DrawSingleItem ( aItemIndex ); |
|
367 } |
|
368 } |
|
369 |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 TSize CMmListBoxView::ItemSize (TInt aItemIndex) const |
|
375 { |
|
376 CMmListBoxView* view= CONST_CAST( CMmListBoxView*, this ); |
|
377 view->UpdateAverageItemHeight (); |
|
378 |
|
379 CMmListBoxItemDrawer* itemDrawer= STATIC_CAST( CMmListBoxItemDrawer*, iItemDrawer ); |
|
380 TSize size(CFormattedCellListBoxView::ItemSize(aItemIndex).iWidth, itemDrawer->GetItemHeight (aItemIndex, |
|
381 CurrentItemIndex () == aItemIndex) ); |
|
382 |
|
383 if ( size.iHeight < 2) |
|
384 size.iHeight = 2; |
|
385 |
|
386 return size; |
|
387 } |
|
388 |
|
389 // ----------------------------------------------------------------------------- |
|
390 // |
|
391 // ----------------------------------------------------------------------------- |
|
392 // |
|
393 TPoint CMmListBoxView::ItemPos (TInt aItemIndex) const |
|
394 { |
|
395 TInt vRealPos = CFormattedCellListBoxView::ItemPos(TopItemIndex()).iY; |
|
396 TInt totalHeight = 0; |
|
397 if ( aItemIndex > iTopItemIndex ) |
|
398 { |
|
399 totalHeight = GetTotalHeight( iTopItemIndex, aItemIndex - 1 ); |
|
400 } |
|
401 else if ( aItemIndex < iTopItemIndex ) |
|
402 { |
|
403 totalHeight = -GetTotalHeight( aItemIndex, iTopItemIndex - 1 ); |
|
404 } |
|
405 |
|
406 return TPoint (-iHScrollOffset + iViewRect.iTl.iX, iViewRect.iTl.iY |
|
407 + totalHeight + vRealPos); |
|
408 } |
|
409 |
|
410 // ----------------------------------------------------------------------------- |
|
411 // |
|
412 // ----------------------------------------------------------------------------- |
|
413 // |
|
414 TBool CMmListBoxView::XYPosToItemIndex (TPoint aPosition, TInt& aItemIndex) const |
|
415 { |
|
416 // returns ETrue and sets aItemIndex to the index of the item whose bounding box contains aPosition |
|
417 // returns EFalse if no such item exists |
|
418 TBool itemFound = EFalse; |
|
419 if ( iViewRect.Contains (aPosition)) |
|
420 { |
|
421 TInt vRealPos = CFormattedCellListBoxView::ItemPos(TopItemIndex()).iY; |
|
422 // aPosition is inside the display area |
|
423 TInt numberOfVisibleItems = GetLastIndexInHeight (iTopItemIndex, |
|
424 aPosition.iY - iViewRect.iTl.iY - vRealPos ); |
|
425 TInt itemAtSpecifiedPos = iTopItemIndex + numberOfVisibleItems; |
|
426 aItemIndex = itemAtSpecifiedPos; |
|
427 itemFound = ( GetTotalHeight( iTopItemIndex, iBottomItemIndex ) |
|
428 >= aPosition.iY ) && ( iModel->NumberOfItems() > itemAtSpecifiedPos ); |
|
429 // if ( itemFound ) |
|
430 // { |
|
431 // // aPosition is inside the display area |
|
432 // TInt numberOfVisibleItems = GetLastIndexInHeight (iTopItemIndex, |
|
433 // aPosition.iY - iViewRect.iTl.iY); |
|
434 // TInt itemAtSpecifiedPos = iTopItemIndex + numberOfVisibleItems; |
|
435 // aItemIndex = itemAtSpecifiedPos; |
|
436 // } |
|
437 } |
|
438 return itemFound; |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 void CMmListBoxView::SetItemHeight (TInt aItemHeight) |
|
446 { |
|
447 // we need to update the iItemHeight member in widget also (there are two different item height value holders - in widget and here in widget view) |
|
448 iItemHeight = aItemHeight; |
|
449 |
|
450 CMmListBoxItemDrawer* itemDrawer = |
|
451 STATIC_CAST( CMmListBoxItemDrawer*, ItemDrawer() ); |
|
452 static_cast<CMmListBox*>(itemDrawer->Widget())->SetItemHeight( aItemHeight ); |
|
453 |
|
454 } |
|
455 |
|
456 // ----------------------------------------------------------------------------- |
|
457 // |
|
458 // ----------------------------------------------------------------------------- |
|
459 // |
|
460 TInt CMmListBoxView::CalcNewTopItemIndexSoItemIsVisible (TInt aItemIndex) const |
|
461 { |
|
462 CMmListBoxItemDrawer* itemDrawer = |
|
463 static_cast<CMmListBoxItemDrawer*>( iItemDrawer ); |
|
464 |
|
465 TInt newTopItemIndex = iTopItemIndex; |
|
466 |
|
467 TInt itemHeight = itemDrawer-> |
|
468 GetItemHeight( aItemIndex, aItemIndex == CurrentItemIndex() ); |
|
469 |
|
470 // ItemIsPartiallyVisible uses fixed iItemHeight, but we have to support |
|
471 // variable item height in lists, unfortunately ItemIsPartiallyVisible |
|
472 // is not virtual |
|
473 TPoint itemPosition( ItemPos( aItemIndex ) ); |
|
474 TBool itemPartiallyVisible = |
|
475 ( itemPosition.iY < iViewRect.iTl.iY && |
|
476 itemPosition.iY + itemHeight >= iViewRect.iTl.iY ) || |
|
477 ( itemPosition.iY <= iViewRect.iBr.iY && |
|
478 itemPosition.iY + itemHeight > iViewRect.iBr.iY ); |
|
479 |
|
480 TBool itemIsFullyVisible = ItemIsVisible( aItemIndex ) && |
|
481 !itemPartiallyVisible; |
|
482 |
|
483 TBool itemIsAboveVisibleArea = !itemIsFullyVisible && |
|
484 ItemPos( aItemIndex ).iY < ViewRect().iTl.iY; |
|
485 |
|
486 TBool itemIsBeneathVisibleArea = !itemIsFullyVisible && |
|
487 !itemIsAboveVisibleArea && ItemPos( aItemIndex ).iY + itemDrawer-> |
|
488 GetItemHeight( aItemIndex, aItemIndex == CurrentItemIndex() ) > |
|
489 ViewRect().iBr.iY; |
|
490 |
|
491 if ( itemIsAboveVisibleArea ) |
|
492 { |
|
493 newTopItemIndex = aItemIndex; |
|
494 const_cast<CMmListBoxView*>( this )->SetItemOffsetInPixels( 0 ); |
|
495 } |
|
496 |
|
497 if ( itemIsBeneathVisibleArea ) |
|
498 { |
|
499 const TInt viewHeight = ViewRect().Height(); |
|
500 newTopItemIndex = aItemIndex; |
|
501 for ( ;; ) |
|
502 { |
|
503 TInt totalHeight = GetTotalHeight( newTopItemIndex, aItemIndex ); |
|
504 if ( totalHeight >= viewHeight || newTopItemIndex == 0 ) |
|
505 { |
|
506 const_cast<CMmListBoxView*>( this )->SetItemOffsetInPixels( |
|
507 viewHeight - totalHeight ); |
|
508 break; |
|
509 } |
|
510 --newTopItemIndex; |
|
511 } |
|
512 } |
|
513 |
|
514 return newTopItemIndex; |
|
515 } |
|
516 |
|
517 // ----------------------------------------------------------------------------- |
|
518 // |
|
519 // ----------------------------------------------------------------------------- |
|
520 // |
|
521 void CMmListBoxView::RedrawBackground (TRect aUsedPortionOfViewRect, |
|
522 TRect aSmallerViewRect) const |
|
523 { |
|
524 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
525 MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal(iGc); |
|
526 if (transApi) |
|
527 { |
|
528 transApi->StartDrawing(MAknListBoxTfxInternal::EListView); |
|
529 } |
|
530 #endif |
|
531 |
|
532 CMmListBoxItemDrawer* itemDrawer = STATIC_CAST( CMmListBoxItemDrawer*, iItemDrawer ); |
|
533 MAknsSkinInstance *skin = AknsUtils::SkinInstance(); |
|
534 CCoeControl* control = itemDrawer->FormattedCellData()->Control(); |
|
535 MAknsControlContext *cc = AknsDrawUtils::ControlContext(control); |
|
536 |
|
537 if (control) |
|
538 { |
|
539 AknsDrawUtils::BackgroundBetweenRects(skin, cc, control, *iGc, |
|
540 aSmallerViewRect, aUsedPortionOfViewRect); |
|
541 } |
|
542 else |
|
543 { |
|
544 iGc->SetBrushColor(BackColor()); |
|
545 DrawUtils::ClearBetweenRects(*iGc, aSmallerViewRect, |
|
546 aUsedPortionOfViewRect); |
|
547 } |
|
548 |
|
549 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
550 if (transApi) |
|
551 { |
|
552 transApi->StopDrawing(); |
|
553 } |
|
554 #endif |
|
555 } |
|
556 |
|
557 // ----------------------------------------------------------------------------- |
|
558 // |
|
559 // ----------------------------------------------------------------------------- |
|
560 // |
|
561 void CMmListBoxView::RedrawBackground () const |
|
562 { |
|
563 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
564 CMmListBoxItemDrawer* drawer = |
|
565 static_cast<CMmListBoxItemDrawer*>( iItemDrawer ); |
|
566 CMmTemplateLibrary* templateLib = drawer->TemplateLibrary(); |
|
567 |
|
568 TInt usedPortionHeight = GetTotalHeight(iTopItemIndex, iBottomItemIndex ); |
|
569 TInt usedPortionWidth = iViewRect.Width(); |
|
570 if (templateLib->GetScrollbarVisibility()) |
|
571 { |
|
572 usedPortionWidth -= templateLib->ScrollbarWidth(); |
|
573 } |
|
574 |
|
575 TRect usedPortionOfViewRect(iViewRect.iTl, TSize(usedPortionWidth, |
|
576 usedPortionHeight)); |
|
577 usedPortionOfViewRect.Move(0, |
|
578 CFormattedCellListBoxView::ItemPos(iTopItemIndex).iY); |
|
579 |
|
580 RedrawBackground(usedPortionOfViewRect, iViewRect); |
|
581 #endif |
|
582 } |
|
583 |
|
584 // ----------------------------------------------------------------------------- |
|
585 // |
|
586 // ----------------------------------------------------------------------------- |
|
587 // |
|
588 void CMmListBoxView::SetPreviouslyDrawnCurrentItemIndex( TBool aIndex ) |
|
589 { |
|
590 iPreviouslyDrawnCurrentItemIndex = aIndex; |
|
591 } |
|
592 |
|
593 // ----------------------------------------------------------------------------- |
|
594 // |
|
595 // ----------------------------------------------------------------------------- |
|
596 // |
|
597 void CMmListBoxView::DrawSingleItem (TInt aItemIndex) const |
|
598 { |
|
599 CMmListBoxItemDrawer* itemDrawer= STATIC_CAST( CMmListBoxItemDrawer*, iItemDrawer ); |
|
600 TSize size = itemDrawer->GetItemSize( aItemIndex, CurrentItemIndex () |
|
601 == aItemIndex); |
|
602 itemDrawer->SetItemCellSize (size); |
|
603 |
|
604 // CMmListBoxView* view= CONST_CAST( CMmListBoxView*, this ); |
|
605 // view->SetItemHeight( size.iHeight ); |
|
606 // The above line (currently commented-out) was originaly needed to correct |
|
607 // some drawing-related error which used to occur when moving highlight with |
|
608 // rocker keys. It seems that this is no longer needed. If anything should |
|
609 // change, please note that now the SetItemHeight method does much more than |
|
610 // it used to, so simply uncommenting this line would be a bad idea (consider |
|
611 // setting the iItemHeight member variable directly). |
|
612 |
|
613 CFormattedCellListBoxView::DrawItem (aItemIndex); |
|
614 |
|
615 //To eliminate the effect of undrawn fragment of background, when the last |
|
616 //is drawn, background is refreshed |
|
617 if ( aItemIndex == ( iModel->NumberOfItems()-1 ) && ItemIsVisible( iModel->NumberOfItems()-1 ) ) |
|
618 { |
|
619 CMmListBoxItemDrawer* itemDrawer= STATIC_CAST( CMmListBoxItemDrawer*, iItemDrawer ); |
|
620 if ( !itemDrawer->IsEditMode() ) |
|
621 { |
|
622 RedrawBackground(); |
|
623 } |
|
624 } |
|
625 } |
|
626 |
|
627 // ----------------------------------------------------------------------------- |
|
628 // |
|
629 // ----------------------------------------------------------------------------- |
|
630 // |
|
631 TInt CMmListBoxView::VerticalItemOffset() const |
|
632 { |
|
633 return iVerticalOffset; |
|
634 } |
|
635 |
|
636 // ----------------------------------------------------------------------------- |
|
637 // |
|
638 // ----------------------------------------------------------------------------- |
|
639 // |
|
640 TBool CMmListBoxView::ScrollToMakeItemVisible(TInt aItemIndex) |
|
641 { |
|
642 TBool scrollConsumed(EFalse); |
|
643 if ( !iScrollToItemDisabled ) |
|
644 { |
|
645 scrollConsumed = CFormattedCellListBoxView::ScrollToMakeItemVisible( |
|
646 aItemIndex); |
|
647 } |
|
648 return scrollConsumed; |
|
649 } |
|
650 |
|
651 // ----------------------------------------------------------------------------- |
|
652 // |
|
653 // ----------------------------------------------------------------------------- |
|
654 // |
|
655 void CMmListBoxView::DisableScrollToItem( TBool aDisable ) |
|
656 { |
|
657 iScrollToItemDisabled = aDisable; |
|
658 } |
|
659 |
|
660 // End of file |