uifw/eikctl/src/EIKCLB.CPP
branchRCL_3
changeset 18 0aa5fbdfbc30
parent 16 71dd06cfe933
child 23 3d340a0166ff
equal deleted inserted replaced
16:71dd06cfe933 18:0aa5fbdfbc30
     1 /*
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   810 #define ITEM_EXISTS_ONCE(x) (((x) > -1) && ((x) < iModel->NumberOfItems()))
   810 #define ITEM_EXISTS_ONCE(x) (((x) > -1) && ((x) < iModel->NumberOfItems()))
   811 
   811 
   812 EXPORT_C void
   812 EXPORT_C void
   813 CColumnListBoxView::Draw( const TRect* aRect ) const
   813 CColumnListBoxView::Draw( const TRect* aRect ) const
   814     {
   814     {
   815 
   815     if ( RedrawDisabled() || !IsVisible() )
   816     if (RedrawDisabled() || !IsVisible())
       
   817         {
   816         {
   818         return;
   817         return;
   819         }
   818         }
   820 
   819 
   821     TInt i=0;
   820     TInt i = 0;
   822 
   821 
   823     CColumnListBoxItemDrawer* lbi = (CColumnListBoxItemDrawer*)ItemDrawer();
   822     CColumnListBoxItemDrawer* lbi =
   824     CEikListBox* listbox = static_cast<CEikListBox*>( lbi->ColumnData()->Control() );
   823         static_cast<CColumnListBoxItemDrawer*>( ItemDrawer() );
   825     MAknsSkinInstance *skin = AknsUtils::SkinInstance();
   824     CEikListBox* listbox =
   826     MAknsControlContext *cc = AknsDrawUtils::ControlContext( listbox );
   825         static_cast<CEikListBox*>( lbi->ColumnData()->Control() );
       
   826     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   827     MAknsControlContext* cc = AknsDrawUtils::ControlContext( listbox );
   827 
   828 
   828     if ( !cc )
   829     if ( !cc )
   829         {
   830         {
   830         cc = lbi->ColumnData()->SkinBackgroundContext();
   831         cc = lbi->ColumnData()->SkinBackgroundContext();
   831         }
   832         }
   832 
   833 
   833     // draw the whole background at once, this is faster than drawing it in separate items
   834     // Draw the whole background at once, this is faster than drawing
       
   835     // it in separate items.
   834     if ( listbox && listbox->BackgroundDrawingSuppressed() )
   836     if ( listbox && listbox->BackgroundDrawingSuppressed() )
   835         {
   837         {
   836 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   838 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   837             MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc );
   839             MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc );
   838             if ( transApi )
   840             if ( transApi )
   854         {
   856         {
   855         iGc->Clear();
   857         iGc->Clear();
   856         }
   858         }
   857 
   859 
   858     TInt firstPotentialItemIndex = iTopItemIndex;
   860     TInt firstPotentialItemIndex = iTopItemIndex;
   859     TInt lastPotentialItemIndex = iTopItemIndex + NumberOfItemsThatFitInRect(iViewRect);
   861     TInt lastPotentialItemIndex =
   860 
   862         iTopItemIndex + NumberOfItemsThatFitInRect( iViewRect ) - 1;
   861     if (iModel->NumberOfItems() == 0)
   863 
       
   864     if ( iModel->NumberOfItems() == 0 )
   862         {
   865         {
   863         // Empty
   866         // Empty
   864         }
   867         }
   865     else
   868     else
   866         {
   869         {
   867         if ( lastPotentialItemIndex > iBottomItemIndex )
   870         if ( lastPotentialItemIndex > iBottomItemIndex )
   868             {
   871             {
   869             // Fix for EAAA-797CKC
       
   870             lastPotentialItemIndex = iBottomItemIndex;
   872             lastPotentialItemIndex = iBottomItemIndex;
   871             }
   873             }
       
   874 
   872         ITEM_EXISTS_BEGIN;
   875         ITEM_EXISTS_BEGIN;
   873         for (i = firstPotentialItemIndex; i <= lastPotentialItemIndex; i++)
   876         for ( i = firstPotentialItemIndex; i <= lastPotentialItemIndex; i++ )
   874             {
   877             {
   875             if (ITEM_EXISTS(i))
   878             if ( ITEM_EXISTS( i ) )
   876                 {
   879                 {
   877                 DrawItem(i);
   880                 DrawItem( i );
   878                 }
   881                 }
   879             else
   882             else
   880                 {
   883                 {
   881                 break;
   884                 break;
   882                 }
   885                 }
   883             }
   886             }
   884         }
   887         }
   885 
   888 
   886     if ( listbox && !listbox->BackgroundDrawingSuppressed() )
   889     if ( listbox && !listbox->BackgroundDrawingSuppressed() )
   887         {
   890         {
   888         // clear the unused portion of the viewing area (this handles drawing the vertical line too :)
   891         // Clear the unused portion of the viewing area
       
   892         // (this handles drawing the vertical line too :)
   889 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   893 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   890         MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc );
   894         MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iGc );
   891 
   895 
   892         if ( transApi )
   896         if ( transApi )
   893             {
   897             {
   894             transApi->StartDrawing( MAknListBoxTfxInternal::EListView );
   898             transApi->StartDrawing( MAknListBoxTfxInternal::EListView );
   895             }
   899             }
   896 #endif // RD_UI_TRANSITION_EFFECTS_LIST
   900 #endif // RD_UI_TRANSITION_EFFECTS_LIST
   897 
   901 
   898         TRect usedPortionOfViewRect( iViewRect.iTl + TSize( 0, iVerticalOffset ), TSize( iViewRect.Width(), ( i - iTopItemIndex ) * iItemHeight ) );
   902         TRect usedPortionOfViewRect(
   899 
   903             iViewRect.iTl + TSize( 0, iVerticalOffset ),
   900         // also clear area behind scroll bar.
   904             TSize( iViewRect.Width(), ( i - iTopItemIndex ) * iItemHeight ) );
   901         // this is a terrible hack, which is unfortunately needed since layouts
   905 
   902         // leave 2 pixel (in double res) wide margins to both sides of the
   906         // Also draw the area behind scroll bar.
   903         // scroll bar, and there is no other way to do this. This hack is
   907         TRect sbbg( iViewRect ); // whole area behind scroll bar
   904         // only really valid for main pane lists, but it does not seem to
       
   905         // break popup lists, popup field lists or setting page radiobutton
       
   906         // lists.
       
   907         TRect sbbg( iViewRect );   // whole area behind scroll bar
       
   908         TRect margin( iViewRect ); // it gets even worse in mirrored layouts
       
   909 
   908 
   910         if ( AknLayoutUtils::LayoutMirrored() )
   909         if ( AknLayoutUtils::LayoutMirrored() )
   911             {
   910             {
   912             sbbg.iBr.iX = iViewRect.iBr.iX - lbi->LafItemSize().iWidth;
   911             sbbg.iBr.iX = iViewRect.iBr.iX - lbi->LafItemSize().iWidth;
   913 
       
   914             // in mirrored layouts we also need to draw a margin slice in right
       
   915             TRect mainPane;
       
   916             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   917                                                mainPane );
       
   918             TAknLayoutRect listscrollAppPane;
       
   919             listscrollAppPane.LayoutRect( mainPane,
       
   920                                           AknLayoutScalable_Avkon::listscroll_app_pane( 0 ) );
       
   921 
       
   922             TInt rMargin = mainPane.iBr.iX - listscrollAppPane.Rect().iBr.iX;
       
   923             margin.iTl.iX = margin.iBr.iX - rMargin;
       
   924             }
   912             }
   925         else
   913         else
   926             {
   914             {
   927             sbbg.iTl.iX = iViewRect.iTl.iX + lbi->LafItemSize().iWidth;
   915             sbbg.iTl.iX = iViewRect.iTl.iX + lbi->LafItemSize().iWidth;
   928             }
   916             }
   935                                                    listbox,
   923                                                    listbox,
   936                                                    *iGc,
   924                                                    *iGc,
   937                                                    iViewRect,
   925                                                    iViewRect,
   938                                                    usedPortionOfViewRect );
   926                                                    usedPortionOfViewRect );
   939 
   927 
   940             AknsDrawUtils::Background( skin, cc, listbox, *iGc, sbbg );
   928             if ( !sbbg.IsEmpty() )
   941 
   929                 {
   942             if ( AknLayoutUtils::LayoutMirrored() )
   930                 AknsDrawUtils::Background( skin, cc, listbox, *iGc, sbbg );
   943                 {
       
   944                 AknsDrawUtils::Background( skin, cc, listbox, *iGc, margin );
       
   945                 }
   931                 }
   946             }
   932             }
   947         else
   933         else
   948             {
   934             {
   949             iGc->SetBrushColor( BackColor() );
   935             iGc->SetBrushColor( BackColor() );
   950             DrawUtils::ClearBetweenRects( *iGc, iViewRect, usedPortionOfViewRect );
   936             DrawUtils::ClearBetweenRects( *iGc, iViewRect, usedPortionOfViewRect );
   951             iGc->Clear( sbbg );
   937             
   952 
   938             if ( !sbbg.IsEmpty() )
   953             if ( AknLayoutUtils::LayoutMirrored() )
   939                 {
   954                 {
   940                 iGc->Clear( sbbg );
   955                 iGc->Clear( margin );
       
   956                 }
   941                 }
   957             }
   942             }
   958 
   943 
   959 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   944 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
   960         if ( transApi )
   945         if ( transApi )