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