menufw/menufwui/mmwidgets/src/mmlistboxview.cpp
branchRCL_3
changeset 26 1b758917cafc
parent 23 7be2816dbabd
child 28 d721605b30d0
equal deleted inserted replaced
25:137ebc85284b 26:1b758917cafc
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15  *  Version     : %version: MM_53 % << Don't touch! Updated by Synergy at check-out.
    15  *  Version     : %version: MM_54 % << Don't touch! Updated by Synergy at check-out.
    16  *
    16  *
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 
    20 
   197 // -----------------------------------------------------------------------------
   197 // -----------------------------------------------------------------------------
   198 //
   198 //
   199 // -----------------------------------------------------------------------------
   199 // -----------------------------------------------------------------------------
   200 //
   200 //
   201 void CMmListBoxView::Draw (const TRect* aClipRect) const
   201 void CMmListBoxView::Draw (const TRect* aClipRect) const
   202   {
   202     {
   203     TBool drawingInitiated(EFalse);
   203     TBool drawingInitiated(EFalse);
   204     if ( CAknEnv::Static()->TransparencyEnabled() &&
   204     if ( CAknEnv::Static()->TransparencyEnabled() &&
   205         iWin && iWin->GetDrawRect() == TRect::EUninitialized )
   205             iWin && iWin->GetDrawRect() == TRect::EUninitialized )
   206       {
   206       {
   207       TRect a(ViewRect());
   207       TRect a(ViewRect());
   208       if (!aClipRect || *aClipRect == TRect(0,0,0,0) )
   208       if (!aClipRect || *aClipRect == TRect(0,0,0,0) )
   209         {
   209           {
   210         aClipRect = &a;
   210           aClipRect = &a;
   211         }
   211           }
   212       drawingInitiated=ETrue;
   212       drawingInitiated=ETrue;
   213     iWin->Invalidate( *aClipRect );
   213       iWin->Invalidate( *aClipRect );
   214     iWin->BeginRedraw( *aClipRect );
   214       iWin->BeginRedraw( *aClipRect );
   215       }
   215       }
   216 
   216 
   217   DoDraw(aClipRect);
   217     DoDraw(aClipRect);
   218 
   218 
   219   CMmListBoxItemDrawer* itemDrawer =
   219     CMmListBoxItemDrawer* itemDrawer =
   220       static_cast<CMmListBoxItemDrawer*>(iItemDrawer );
   220             static_cast<CMmListBoxItemDrawer*>(iItemDrawer );
   221     if (aClipRect)
   221     if( aClipRect )
   222         {
   222         {
   223         TRect rect(*aClipRect);
   223         TRect rect(*aClipRect);
   224         rect.iTl.iY = ItemPos( BottomItemIndex() ).iY + ItemSize( BottomItemIndex() ).iHeight;
   224         rect.iTl.iY = ItemPos( BottomItemIndex() ).iY;
   225 
   225 
   226 //      iGc->SetClippingRect( rect );
   226 //      iGc->SetClippingRect( rect );
   227 //		removed to prevent non-redraw drawing. Was present to prevent out of view drawing when effects are on.
   227 //		removed to prevent non-redraw drawing. Was present to prevent out of view drawing when effects are on.
   228 //      could be removed because effects were disabled at some point in edit mode to enhance performance.
   228 //      could be removed because effects were disabled at some point in edit mode to enhance performance.
   229         itemDrawer->DrawFloatingItems( rect );
   229         itemDrawer->DrawFloatingItems( rect );
   230 //      iGc->CancelClippingRect();
   230 //      iGc->CancelClippingRect();
   231         }
   231         }
   232 
   232 
   233     if ( CAknEnv::Static()->TransparencyEnabled() &&
   233     if ( CAknEnv::Static()->TransparencyEnabled() &&
   234         iWin && drawingInitiated )
   234         iWin && drawingInitiated )
   235       {
   235         {
   236       drawingInitiated = EFalse;
   236         drawingInitiated = EFalse;
   237       iWin->EndRedraw( );
   237         iWin->EndRedraw( );
   238       }
   238         }
   239   }
   239     }
   240 
   240 
   241 // -----------------------------------------------------------------------------
   241 // -----------------------------------------------------------------------------
   242 //
   242 //
   243 // -----------------------------------------------------------------------------
   243 // -----------------------------------------------------------------------------
   244 //
   244 //
   245 void CMmListBoxView::DoDraw(const TRect* aClipRect) const
   245 void CMmListBoxView::DoDraw(const TRect* aClipRect) const
   246   {
   246     {
   247   CMmListBoxView* view= CONST_CAST( CMmListBoxView*, this );
   247     CMmListBoxView* view= CONST_CAST( CMmListBoxView*, this );
   248   view->UpdateAverageItemHeight ();
   248     view->UpdateAverageItemHeight ();
   249 
   249 
   250   CMmListBoxModel* model = static_cast< CMmListBoxModel* > ( iModel );
   250     CMmListBoxModel* model = static_cast< CMmListBoxModel* > ( iModel );
   251   if ( model && model->GetSuiteModel()
   251     if ( model && model->GetSuiteModel()
   252       && !model->GetSuiteModel()->GetItemsOrder()->IsSuiteReadyToShow() )
   252             && !model->GetSuiteModel()->GetItemsOrder()->IsSuiteReadyToShow() )
   253     {
   253         {
   254     return;
   254         return;
   255     }
   255         }
   256 
   256 
   257   if ( RedrawDisabled () || !IsVisible () )
   257     if ( RedrawDisabled () || !IsVisible () )
   258     {
   258         {
   259     return;
   259         return;
   260     }
   260         }
   261 
   261 
   262   TInt i = iTopItemIndex;
   262     TInt i = iTopItemIndex;
   263   CMmListBoxItemDrawer* itemDrawer =
   263     CMmListBoxItemDrawer* itemDrawer =
   264       static_cast<CMmListBoxItemDrawer*>(iItemDrawer );
   264             static_cast<CMmListBoxItemDrawer*>(iItemDrawer );
   265   MAknsSkinInstance *skin = AknsUtils::SkinInstance ();
   265     MAknsSkinInstance *skin = AknsUtils::SkinInstance ();
   266   CCoeControl* control = itemDrawer->FormattedCellData()->Control ();
   266     CCoeControl* control = itemDrawer->FormattedCellData()->Control ();
   267   MAknsControlContext *cc = AknsDrawUtils::ControlContext (control);
   267     MAknsControlContext *cc = AknsDrawUtils::ControlContext (control);
   268 
   268 
   269   if ( !cc)
   269     if ( !cc)
   270     {
   270         {
   271     cc = itemDrawer->FormattedCellData()->SkinBackgroundContext ();
   271         cc = itemDrawer->FormattedCellData()->SkinBackgroundContext ();
   272     }
   272         }
   273 
   273 
   274   itemDrawer->SetTopItemIndex (iTopItemIndex);
   274     itemDrawer->SetTopItemIndex (iTopItemIndex);
   275 
   275 
   276   if ( iModel->NumberOfItems () > 0)
   276     if ( iModel->NumberOfItems () > 0)
   277     {
   277         {
   278     TBool drawingInitiated = ETrue;
   278         TBool drawingInitiated = ETrue;
   279     if ( CAknEnv::Static()->TransparencyEnabled () )
   279         if ( CAknEnv::Static()->TransparencyEnabled () )
   280       {
   280             {
   281       if ( iWin && iWin->GetDrawRect () == TRect::EUninitialized)
   281             if ( iWin && iWin->GetDrawRect () == TRect::EUninitialized)
   282         {
   282                 {
   283 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   283 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   284                 MAknListBoxTfxInternal* transApi =
   284                 MAknListBoxTfxInternal* transApi =
   285                   CAknListLoader::TfxApiInternal( iGc );
   285                         CAknListLoader::TfxApiInternal( iGc );
   286                 drawingInitiated = transApi && !transApi->EffectsDisabled();
   286                 drawingInitiated = transApi && !transApi->EffectsDisabled();
   287 #else
   287 #else
   288         drawingInitiated = EFalse;
   288                 drawingInitiated = EFalse;
   289 #endif
   289 #endif
   290         }
   290                 }
   291 
   291 
   292       if ( !drawingInitiated)
   292             if ( !drawingInitiated)
   293         {
   293                 {
   294         iWin->Invalidate ( *aClipRect);
   294                 iWin->Invalidate ( *aClipRect);
   295         iWin->BeginRedraw ( *aClipRect);
   295                 iWin->BeginRedraw ( *aClipRect);
   296         }
   296                 }
   297       }
   297             }
   298 
   298 
   299     TInt lastPotentialItemIndex = Min( iModel->NumberOfItems(),
   299         TInt lastPotentialItemIndex = Min( iModel->NumberOfItems(),
   300                 iTopItemIndex + NumberOfItemsThatFitInRect( ViewRect() ) );
   300                 iTopItemIndex + NumberOfItemsThatFitInRect( ViewRect() ) );
   301 
   301 
   302     if ( !itemDrawer->IsEditMode() )
   302         if ( !itemDrawer->IsEditMode() )
   303         {
   303             {
   304         itemDrawer->DrawBackground( ViewRect() );
   304             itemDrawer->DrawBackground( ViewRect() );
   305             itemDrawer->SetRedrawItemBackground( EFalse );
   305             itemDrawer->SetRedrawItemBackground( EFalse );
   306             itemDrawer->SetDrawSeparatorLines( ETrue );
   306             itemDrawer->SetDrawSeparatorLines( ETrue );
   307             while (i < lastPotentialItemIndex)
   307             while (i < lastPotentialItemIndex)
   308                 {
   308                 {
   309                 DrawItem(i++);
   309                 DrawItem(i++);
   310                 }
   310                 }
   311             itemDrawer->SetRedrawItemBackground( ETrue );
   311             itemDrawer->SetRedrawItemBackground( ETrue );
   312             itemDrawer->SetDrawSeparatorLines( EFalse );
   312             itemDrawer->SetDrawSeparatorLines( EFalse );
   313         }
   313             }
   314     else
   314         else
   315         {
   315             {
   316         while (i < lastPotentialItemIndex)
   316             while (i < lastPotentialItemIndex)
   317                 {
   317                 {
   318                 DrawItem(i++);
   318                 DrawItem(i++);
   319                 }
   319                 }
   320         // this redraws background in the view portion not covered by items
   320         // this redraws background in the view portion not covered by items
   321         RedrawBackground();
   321             RedrawBackground();
   322         }
   322             }
   323 
   323 
   324 
   324 
   325     if ( CAknEnv::Static()->TransparencyEnabled () && !drawingInitiated)
   325         if ( CAknEnv::Static()->TransparencyEnabled () && !drawingInitiated)
   326       {
   326             {
   327       iWin->EndRedraw ();
   327             iWin->EndRedraw ();
   328       }
   328             }
   329     }
   329         }
   330 
   330 
   331   }
   331     }
   332 
   332 
   333 // -----------------------------------------------------------------------------
   333 // -----------------------------------------------------------------------------
   334 //
   334 //
   335 // -----------------------------------------------------------------------------
   335 // -----------------------------------------------------------------------------
   336 //
   336 //
   488 // -----------------------------------------------------------------------------
   488 // -----------------------------------------------------------------------------
   489 //
   489 //
   490 // -----------------------------------------------------------------------------
   490 // -----------------------------------------------------------------------------
   491 //
   491 //
   492 void CMmListBoxView::RedrawBackground (TRect aUsedPortionOfViewRect,
   492 void CMmListBoxView::RedrawBackground (TRect aUsedPortionOfViewRect,
   493     TRect aSmallerViewRect) const
   493         TRect aSmallerViewRect) const
   494   {
   494     {
   495 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   495 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   496         MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal(iGc);
   496     MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal(iGc);
   497     if (transApi)
   497     if (transApi)
   498         {
   498         {
   499         transApi->StartDrawing(MAknListBoxTfxInternal::EListView);
   499         transApi->StartDrawing(MAknListBoxTfxInternal::EListView);
   500         }
   500         }
   501 #endif
   501 #endif
   502 
   502 
   503   CMmListBoxItemDrawer* itemDrawer = STATIC_CAST( CMmListBoxItemDrawer*, iItemDrawer );
   503     CMmListBoxItemDrawer* itemDrawer = STATIC_CAST( CMmListBoxItemDrawer*, iItemDrawer );
   504     MAknsSkinInstance *skin = AknsUtils::SkinInstance();
   504     MAknsSkinInstance *skin = AknsUtils::SkinInstance();
   505     CCoeControl* control = itemDrawer->FormattedCellData()->Control();
   505     CCoeControl* control = itemDrawer->FormattedCellData()->Control();
   506     MAknsControlContext *cc = AknsDrawUtils::ControlContext(control);
   506     MAknsControlContext *cc = AknsDrawUtils::ControlContext(control);
   507 
   507 
   508   if (control)
   508     if (control)
   509         {
   509         {
   510         AknsDrawUtils::BackgroundBetweenRects(skin, cc, control, *iGc,
   510         AknsDrawUtils::BackgroundBetweenRects( skin, cc, control, *iGc,
   511                 aSmallerViewRect, aUsedPortionOfViewRect);
   511                 aSmallerViewRect, aUsedPortionOfViewRect);
   512         }
   512         }
   513     else
   513     else
   514         {
   514         {
   515         iGc->SetBrushColor(BackColor());
   515         iGc->SetBrushColor(BackColor());
   516         DrawUtils::ClearBetweenRects(*iGc, aSmallerViewRect,
   516         DrawUtils::ClearBetweenRects(*iGc, aSmallerViewRect,
   517                 aUsedPortionOfViewRect);
   517                 aUsedPortionOfViewRect);
   518         }
   518         }
   519 
   519 
   520 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   520 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   521     if (transApi)
   521     if( transApi )
   522         {
   522         {
   523         transApi->StopDrawing();
   523         transApi->StopDrawing();
   524         }
   524         }
   525 #endif
   525 #endif
   526   }
   526   }