325 } |
325 } |
326 } |
326 } |
327 |
327 |
328 TInt lastPotentialItemIndex = Min (iModel->NumberOfItems (), |
328 TInt lastPotentialItemIndex = Min (iModel->NumberOfItems (), |
329 iTopItemIndex + GetNumberOfItemsThatFitInRect( ViewRect (), ETrue ) ); |
329 iTopItemIndex + GetNumberOfItemsThatFitInRect( ViewRect (), ETrue ) ); |
330 while (i < lastPotentialItemIndex) |
330 |
331 { |
331 if ( !itemDrawer->IsEditMode() ) |
332 DrawItem(i++); |
332 { |
333 } |
333 itemDrawer->DrawBackgroundAndSeparatorLines( ViewRect() ); |
334 |
334 itemDrawer->SetRedrawItemBackground( EFalse ); |
335 RedrawBackground(); |
335 while (i < lastPotentialItemIndex) |
|
336 { |
|
337 DrawItem(i++); |
|
338 } |
|
339 itemDrawer->SetRedrawItemBackground( ETrue ); |
|
340 } |
|
341 else |
|
342 { |
|
343 while (i < lastPotentialItemIndex) |
|
344 { |
|
345 DrawItem(i++); |
|
346 } |
|
347 // this redraws background in the view portion not covered by items |
|
348 RedrawBackground(); |
|
349 } |
|
350 |
336 |
351 |
337 if ( CAknEnv::Static()->TransparencyEnabled () && !drawingInitiated) |
352 if ( CAknEnv::Static()->TransparencyEnabled () && !drawingInitiated) |
338 { |
353 { |
339 iWin->EndRedraw (); |
354 iWin->EndRedraw (); |
340 } |
355 } |
358 static_cast<CMmListBox*> (itemDrawer->Widget())->RedrawIfNecessary( |
373 static_cast<CMmListBox*> (itemDrawer->Widget())->RedrawIfNecessary( |
359 iPreviouslyDrawnCurrentItemIndex, |
374 iPreviouslyDrawnCurrentItemIndex, |
360 CurrentItemIndex()); |
375 CurrentItemIndex()); |
361 view->SetPreviouslyDrawnCurrentItemIndex( CurrentItemIndex() ); |
376 view->SetPreviouslyDrawnCurrentItemIndex( CurrentItemIndex() ); |
362 } |
377 } |
363 |
378 |
364 if ( !redrawConsumed ) |
379 if ( !redrawConsumed ) |
365 { |
380 { |
366 DrawSingleItem ( aItemIndex ); |
381 DrawSingleItem ( aItemIndex ); |
367 } |
382 } |
368 } |
383 } |
444 // |
459 // |
445 void CMmListBoxView::SetItemHeight (TInt aItemHeight) |
460 void CMmListBoxView::SetItemHeight (TInt aItemHeight) |
446 { |
461 { |
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) |
462 // 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; |
463 iItemHeight = aItemHeight; |
449 |
464 |
450 CMmListBoxItemDrawer* itemDrawer = |
465 CMmListBoxItemDrawer* itemDrawer = |
451 STATIC_CAST( CMmListBoxItemDrawer*, ItemDrawer() ); |
466 STATIC_CAST( CMmListBoxItemDrawer*, ItemDrawer() ); |
452 static_cast<CMmListBox*>(itemDrawer->Widget())->SetItemHeight( aItemHeight ); |
467 static_cast<CMmListBox*>(itemDrawer->Widget())->SetItemHeight( aItemHeight ); |
453 |
468 |
454 } |
469 } |
455 |
470 |
456 // ----------------------------------------------------------------------------- |
471 // ----------------------------------------------------------------------------- |
457 // |
472 // |
458 // ----------------------------------------------------------------------------- |
473 // ----------------------------------------------------------------------------- |
464 |
479 |
465 TInt newTopItemIndex = iTopItemIndex; |
480 TInt newTopItemIndex = iTopItemIndex; |
466 |
481 |
467 TInt itemHeight = itemDrawer-> |
482 TInt itemHeight = itemDrawer-> |
468 GetItemHeight( aItemIndex, aItemIndex == CurrentItemIndex() ); |
483 GetItemHeight( aItemIndex, aItemIndex == CurrentItemIndex() ); |
469 |
484 |
470 // ItemIsPartiallyVisible uses fixed iItemHeight, but we have to support |
485 // ItemIsPartiallyVisible uses fixed iItemHeight, but we have to support |
471 // variable item height in lists, unfortunately ItemIsPartiallyVisible |
486 // variable item height in lists, unfortunately ItemIsPartiallyVisible |
472 // is not virtual |
487 // is not virtual |
473 TPoint itemPosition( ItemPos( aItemIndex ) ); |
488 TPoint itemPosition( ItemPos( aItemIndex ) ); |
474 TBool itemPartiallyVisible = |
489 TBool itemPartiallyVisible = |
475 ( itemPosition.iY < iViewRect.iTl.iY && |
490 ( itemPosition.iY < iViewRect.iTl.iY && |
476 itemPosition.iY + itemHeight >= iViewRect.iTl.iY ) || |
491 itemPosition.iY + itemHeight >= iViewRect.iTl.iY ) || |
477 ( itemPosition.iY <= iViewRect.iBr.iY && |
492 ( itemPosition.iY <= iViewRect.iBr.iY && |
478 itemPosition.iY + itemHeight > iViewRect.iBr.iY ); |
493 itemPosition.iY + itemHeight > iViewRect.iBr.iY ); |
479 |
494 |
480 TBool itemIsFullyVisible = ItemIsVisible( aItemIndex ) && |
495 TBool itemIsFullyVisible = ItemIsVisible( aItemIndex ) && |
481 !itemPartiallyVisible; |
496 !itemPartiallyVisible; |
482 |
497 |
483 TBool itemIsAboveVisibleArea = !itemIsFullyVisible && |
498 TBool itemIsAboveVisibleArea = !itemIsFullyVisible && |
484 ItemPos( aItemIndex ).iY < ViewRect().iTl.iY; |
499 ItemPos( aItemIndex ).iY < ViewRect().iTl.iY; |
485 |
500 |
486 TBool itemIsBeneathVisibleArea = !itemIsFullyVisible && |
501 TBool itemIsBeneathVisibleArea = !itemIsFullyVisible && |
487 !itemIsAboveVisibleArea && ItemPos( aItemIndex ).iY + itemDrawer-> |
502 !itemIsAboveVisibleArea && ItemPos( aItemIndex ).iY + itemDrawer-> |
488 GetItemHeight( aItemIndex, aItemIndex == CurrentItemIndex() ) > |
503 GetItemHeight( aItemIndex, aItemIndex == CurrentItemIndex() ) > |
489 ViewRect().iBr.iY; |
504 ViewRect().iBr.iY; |
490 |
505 |
494 const_cast<CMmListBoxView*>( this )->SetItemOffsetInPixels( 0 ); |
509 const_cast<CMmListBoxView*>( this )->SetItemOffsetInPixels( 0 ); |
495 } |
510 } |
496 |
511 |
497 if ( itemIsBeneathVisibleArea ) |
512 if ( itemIsBeneathVisibleArea ) |
498 { |
513 { |
499 const TInt viewHeight = ViewRect().Height(); |
514 const TInt viewHeight = ViewRect().Height(); |
500 newTopItemIndex = aItemIndex; |
515 newTopItemIndex = aItemIndex; |
501 for ( ;; ) |
516 for ( ;; ) |
502 { |
517 { |
503 TInt totalHeight = GetTotalHeight( newTopItemIndex, aItemIndex ); |
518 TInt totalHeight = GetTotalHeight( newTopItemIndex, aItemIndex ); |
504 if ( totalHeight >= viewHeight || newTopItemIndex == 0 ) |
519 if ( totalHeight >= viewHeight || newTopItemIndex == 0 ) |
574 |
589 |
575 TRect usedPortionOfViewRect(iViewRect.iTl, TSize(usedPortionWidth, |
590 TRect usedPortionOfViewRect(iViewRect.iTl, TSize(usedPortionWidth, |
576 usedPortionHeight)); |
591 usedPortionHeight)); |
577 usedPortionOfViewRect.Move(0, |
592 usedPortionOfViewRect.Move(0, |
578 CFormattedCellListBoxView::ItemPos(iTopItemIndex).iY); |
593 CFormattedCellListBoxView::ItemPos(iTopItemIndex).iY); |
579 |
594 |
580 RedrawBackground(usedPortionOfViewRect, iViewRect); |
595 RedrawBackground(usedPortionOfViewRect, iViewRect); |
581 #endif |
596 #endif |
582 } |
597 } |
583 |
598 |
584 // ----------------------------------------------------------------------------- |
599 // ----------------------------------------------------------------------------- |
601 TBool highlightVisible = !( itemDrawer->Flags() |
616 TBool highlightVisible = !( itemDrawer->Flags() |
602 & CListItemDrawer::ESingleClickDisabledHighlight ); |
617 & CListItemDrawer::ESingleClickDisabledHighlight ); |
603 TSize size = itemDrawer->GetItemSize( aItemIndex, highlightVisible && |
618 TSize size = itemDrawer->GetItemSize( aItemIndex, highlightVisible && |
604 CurrentItemIndex() == aItemIndex ); |
619 CurrentItemIndex() == aItemIndex ); |
605 itemDrawer->SetItemCellSize( size ); |
620 itemDrawer->SetItemCellSize( size ); |
606 |
621 |
607 // CMmListBoxView* view= CONST_CAST( CMmListBoxView*, this ); |
622 // CMmListBoxView* view= CONST_CAST( CMmListBoxView*, this ); |
608 // view->SetItemHeight( size.iHeight ); |
623 // view->SetItemHeight( size.iHeight ); |
609 // The above line (currently commented-out) was originaly needed to correct |
624 // The above line (currently commented-out) was originaly needed to correct |
610 // some drawing-related error which used to occur when moving highlight with |
625 // some drawing-related error which used to occur when moving highlight with |
611 // rocker keys. It seems that this is no longer needed. If anything should |
626 // rocker keys. It seems that this is no longer needed. If anything should |
612 // change, please note that now the SetItemHeight method does much more than |
627 // change, please note that now the SetItemHeight method does much more than |
613 // it used to, so simply uncommenting this line would be a bad idea (consider |
628 // it used to, so simply uncommenting this line would be a bad idea (consider |
614 // setting the iItemHeight member variable directly). |
629 // setting the iItemHeight member variable directly). |
615 |
630 |
616 CFormattedCellListBoxView::DrawItem (aItemIndex); |
631 CFormattedCellListBoxView::DrawItem (aItemIndex); |
617 |
632 |
618 //To eliminate the effect of undrawn fragment of background, when the last |
633 //To eliminate the effect of undrawn fragment of background, when the last |
619 //is drawn, background is refreshed |
634 //is drawn, background is refreshed |
620 if ( aItemIndex == ( iModel->NumberOfItems()-1 ) && ItemIsVisible( iModel->NumberOfItems()-1 ) ) |
635 if ( aItemIndex == ( iModel->NumberOfItems()-1 ) && ItemIsVisible( iModel->NumberOfItems()-1 ) ) |