uifw/AvKon/aknhlist/src/akntreelistview.cpp
branchRCL_3
changeset 15 08e69e956a8c
parent 10 9f56a4e1b8ab
child 16 71dd06cfe933
equal deleted inserted replaced
10:9f56a4e1b8ab 15:08e69e956a8c
    30 #include "akntree.h"
    30 #include "akntree.h"
    31 #include "akntreelist.h"
    31 #include "akntreelist.h"
    32 #include "akntreeiterator.h"
    32 #include "akntreeiterator.h"
    33 #include "akntreelistphysicshandler.h"
    33 #include "akntreelistphysicshandler.h"
    34 
    34 
    35 
    35 #include "akntrace.h"
    36 
    36 
    37 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
    37 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
    38 
    38 
    39 #include <aknlistboxtfxinternal.h> // LISTBOX EFFECTS IMPLEMENTATION
    39 #include <aknlistboxtfxinternal.h> // LISTBOX EFFECTS IMPLEMENTATION
    40 #include <aknlistloadertfx.h>
    40 #include <aknlistloadertfx.h>
   161 
   161 
   162     if ( aDrawNow )
   162     if ( aDrawNow )
   163         {
   163         {
   164         Window().Invalidate( Rect() );
   164         Window().Invalidate( Rect() );
   165         }
   165         }
   166     UpdateScrollbars();
   166 
       
   167     UpdateScrollbars( ETrue );
   167     }
   168     }
   168 
   169 
   169 
   170 
   170 // ---------------------------------------------------------------------------
   171 // ---------------------------------------------------------------------------
   171 // Sets the focused item and its position in the view.
   172 // Sets the focused item and its position in the view.
   211     UpdateAnimation();
   212     UpdateAnimation();
   212             
   213             
   213     // Draw always
   214     // Draw always
   214     Window().Invalidate( Rect() );
   215     Window().Invalidate( Rect() );
   215         
   216         
   216     UpdateScrollbars();
   217     UpdateScrollbars( ETrue );
   217     }
   218     }
   218 
   219 
   219 
   220 
   220 
   221 
   221 // ---------------------------------------------------------------------------
   222 // ---------------------------------------------------------------------------
   420 void CAknTreeListView::SetEmptyTextL(const TDesC& aText)
   421 void CAknTreeListView::SetEmptyTextL(const TDesC& aText)
   421     {
   422     {
   422     delete iEmptyListText;
   423     delete iEmptyListText;
   423     iEmptyListText = NULL;
   424     iEmptyListText = NULL;
   424     iEmptyListText = aText.AllocL();
   425     iEmptyListText = aText.AllocL();
   425     UpdateScrollbars(); 
   426     UpdateScrollbars( ETrue ); 
   426     }
   427     }
   427 
   428 
   428 
   429 
   429 // ---------------------------------------------------------------------------
   430 // ---------------------------------------------------------------------------
   430 // InitPhysicsL
   431 // InitPhysicsL
   502 void CAknTreeListView::UpdateTreeListView( const TInt& aFirstItem,
   503 void CAknTreeListView::UpdateTreeListView( const TInt& aFirstItem,
   503                                            const TBool& aDrawNow )
   504                                            const TBool& aDrawNow )
   504     {
   505     {
   505     CAknTreeItem* first = iTree.VisibleItem( aFirstItem );
   506     CAknTreeItem* first = iTree.VisibleItem( aFirstItem );
   506     UpdateVisibleItems( 0, first );
   507     UpdateVisibleItems( 0, first );
   507     UpdateScrollbars();
   508     UpdateScrollbars( ETrue );
   508     UpdateAnimation();
   509     UpdateAnimation();
   509     
   510     
   510     if ( aDrawNow )
   511     if ( aDrawNow )
   511         {
   512         {
   512         DrawNow();
   513         DrawNow();
   740 // ---------------------------------------------------------------------------
   741 // ---------------------------------------------------------------------------
   741 //
   742 //
   742 void CAknTreeListView::MakeVisible( TBool aVisible )
   743 void CAknTreeListView::MakeVisible( TBool aVisible )
   743     {
   744     {
   744     CAknControl::MakeVisible( aVisible );
   745     CAknControl::MakeVisible( aVisible );
   745 
   746     UpdateScrollbars( aVisible );
   746     if ( aVisible )
       
   747         {
       
   748         UpdateScrollbars();
       
   749         }
       
   750     }
   747     }
   751 
   748 
   752 
   749 
   753 // ---------------------------------------------------------------------------
   750 // ---------------------------------------------------------------------------
   754 // From class CCoeControl.
   751 // From class CCoeControl.
   769     
   766     
   770     Window().SetPointerGrab( ETrue );
   767     Window().SetPointerGrab( ETrue );
   771 
   768 
   772     iScrollbarFrame = new ( ELeave ) CEikScrollBarFrame( this, this );
   769     iScrollbarFrame = new ( ELeave ) CEikScrollBarFrame( this, this );
   773     iScrollbarFrame->CreateDoubleSpanScrollBarsL( EFalse, EFalse );
   770     iScrollbarFrame->CreateDoubleSpanScrollBarsL( EFalse, EFalse );
       
   771     if ( CAknEnv::Static()->TransparencyEnabled() && iPhysicsHandler )
       
   772         {
       
   773         // disable background drawing of scrollbar 
       
   774         iScrollbarFrame->DrawBackground( EFalse, EFalse );
       
   775         }
   774     }
   776     }
   775 
   777 
   776 
   778 
   777 // ---------------------------------------------------------------------------
   779 // ---------------------------------------------------------------------------
   778 // From class CCoeControl.
   780 // From class CCoeControl.
   780 // ---------------------------------------------------------------------------
   782 // ---------------------------------------------------------------------------
   781 //
   783 //
   782 void CAknTreeListView::HandleResourceChange( TInt aType )
   784 void CAknTreeListView::HandleResourceChange( TInt aType )
   783     {
   785     {
   784     CAknControl::HandleResourceChange( aType );
   786     CAknControl::HandleResourceChange( aType );
   785     if ( aType == KAknsMessageSkinChange )
   787     
   786         {
   788     switch ( aType )
   787         TRAPD( error, CreateAnimationL() )
   789         {
   788         if ( error )
   790         case KAknsMessageSkinChange:
   789             {
   791             {
   790             delete iAnimation;
   792             TRAPD( error, CreateAnimationL() )
   791             iAnimation = NULL;
   793             if ( error )
   792             }
   794                 {
   793         }
   795                 delete iAnimation;
   794     else if ( aType == KEikDynamicLayoutVariantSwitch && FocusedItem() )
   796                 iAnimation = NULL;
   795         {
   797                 }
   796         if ( !FocusedItemVisible() )
   798             break;
   797             {
   799             }
   798             TInt firstItemIndex = 0;
   800 
   799             if ( iItems.Count() && iItems[0].Item() )
   801         case KEikDynamicLayoutVariantSwitch:
   800                 {
   802             {
   801                 firstItemIndex = iTree.VisibleItemIndex( iItems[0].Item() );
   803             iMirroredLayoutInUse = AknLayoutUtils::LayoutMirrored();
   802                 }
   804 
   803 
   805             CAknTreeItem* focusedItem( FocusedItem() );
   804             TInt index = 0;
   806             if ( focusedItem )
   805             if ( firstItemIndex < iTree.VisibleItemIndex( FocusedItem() ) )
   807                 {
   806                 {
   808                 if ( !FocusedItemVisible() )
   807                 index = iItems.Count() - 1;
   809                     {
   808                 }
   810                     TInt firstItemIndex = 0;
   809 
   811                     if ( iItems.Count() && iItems[0].Item() )
   810             SetFocusedItem( FocusedItem(), index, ETrue );
   812                         {
   811             }
   813                         firstItemIndex =
   812         else
   814                             iTree.VisibleItemIndex( iItems[0].Item() );
   813             {
   815                         }
   814             SetFocusedItem( FocusedItem(), FocusIndex(), ETrue );
   816     
       
   817                     TInt index = 0;
       
   818                     if ( firstItemIndex < iTree.VisibleItemIndex( focusedItem ) )
       
   819                         {
       
   820                         index = iItems.Count() - 1;
       
   821                         }
       
   822     
       
   823                     SetFocusedItem( focusedItem, index, ETrue );
       
   824                     }
       
   825                 else
       
   826                     {
       
   827                     SetFocusedItem( focusedItem, FocusIndex(), ETrue );
       
   828 
       
   829                     // This block moves visible view after layout switch
       
   830                     // if there are not enough items to fill whole screen
       
   831                     TInt visibleItemIndex =
       
   832                         iTree.VisibleItemIndex( focusedItem );
       
   833                     if ( visibleItemIndex != KErrNotFound )
       
   834                         {
       
   835                         TInt focusedItemIndex = FocusedItemIndex();
       
   836                         if ( focusedItemIndex != -1 )
       
   837                             {
       
   838                             TInt visibleItemCount( iTree.VisibleItemCount() );
       
   839                         
       
   840                             TInt height =
       
   841                                 visibleItemCount - visibleItemIndex + focusedItemIndex;
       
   842                             TInt itemCountLimit = iItems.Count();
       
   843                             
       
   844                             if ( height < itemCountLimit &&
       
   845                                  height < visibleItemCount )
       
   846                                 {
       
   847                                 TInt move = itemCountLimit - height;                
       
   848                                 UpdateVisibleItems(
       
   849                                     focusedItemIndex + move, focusedItem );
       
   850                                 }
       
   851                             }
       
   852                         }
       
   853                     // end of block
       
   854                     }
       
   855                 }
       
   856             break;
       
   857             }
   815             
   858             
       
   859         case KAknMessageFocusLost:
       
   860             {
       
   861             if ( HighlightEnabled() )
       
   862                 {
       
   863                 EnableHighlight( EFalse );
       
   864                 }
       
   865             break;
       
   866             }
   816             
   867             
   817             // This block moves visible view after layout switch
   868         default:
   818             // if there are not enough items to fill whole screen
   869             {
   819             TInt visibleItemIndex = iTree.VisibleItemIndex( FocusedItem() );
   870             break;
   820             if ( visibleItemIndex != KErrNotFound)
   871             }
   821                 {
       
   822                 TInt focusedItemIndex = FocusedItemIndex();
       
   823                 if (focusedItemIndex != -1)
       
   824                     {
       
   825                     TInt height =  iTree.VisibleItemCount() - visibleItemIndex + focusedItemIndex;
       
   826                     TInt itemCountLimit = iItems.Count();
       
   827                     
       
   828                     if ( height < itemCountLimit && height < iTree.VisibleItemCount() )
       
   829                         {
       
   830                         TInt move = itemCountLimit - height;                
       
   831                         UpdateVisibleItems( focusedItemIndex + move, FocusedItem() );
       
   832                         }
       
   833                     }
       
   834                 }
       
   835             // end of block
       
   836             }
       
   837         }
       
   838     else if ( aType == KAknMessageFocusLost && HighlightEnabled() )
       
   839         {
       
   840         EnableHighlight( EFalse );
       
   841         }
   872         }
   842     }
   873     }
   843 
   874 
   844 
   875 
   845 // ---------------------------------------------------------------------------
   876 // ---------------------------------------------------------------------------
   856          && aPointerEvent.iType == TPointerEvent::EButton1Up )
   887          && aPointerEvent.iType == TPointerEvent::EButton1Up )
   857         {
   888         {
   858         return;
   889         return;
   859         }
   890         }
   860     
   891     
   861     if ( GrabbingComponent() != NULL )
   892     if ( GrabbingComponent() )
   862         {
   893         {
   863         iPhysicsHandler->ResetEventBlockingStatus();
   894         iPhysicsHandler->ResetEventBlockingStatus();
   864         }
   895         }
   865     else
   896     else
   866         {
   897         {
   911         {
   942         {
   912         EnableHighlight( EFalse );
   943         EnableHighlight( EFalse );
   913         }
   944         }
   914 
   945 
   915     TInt thumbPosition = aScrollBar->ThumbPosition();
   946     TInt thumbPosition = aScrollBar->ThumbPosition();
   916     if ( AknLayoutUtils::LayoutMirrored() &&
   947     if ( iMirroredLayoutInUse &&
   917          aScrollBar != iScrollbarFrame->VerticalScrollBar() )
   948          aScrollBar != iScrollbarFrame->VerticalScrollBar() )
   918         {
   949         {
   919         const TEikScrollBarModel* model = aScrollBar->Model();
   950         const TEikScrollBarModel* model = aScrollBar->Model();
   920         thumbPosition = ( model->iScrollSpan - model->iThumbSpan )
   951         thumbPosition = ( model->iScrollSpan - model->iThumbSpan )
   921             - thumbPosition;
   952             - thumbPosition;
   930         case EEikScrollLeft:
   961         case EEikScrollLeft:
   931         case EEikScrollRight:
   962         case EEikScrollRight:
   932         case EEikScrollPageLeft:
   963         case EEikScrollPageLeft:
   933         case EEikScrollPageRight:
   964         case EEikScrollPageRight:
   934             iViewLevel = thumbPosition;
   965             iViewLevel = thumbPosition;
   935             UpdateScrollbars();
   966             UpdateScrollbars( ETrue );
   936             UpdateAnimation();
   967             UpdateAnimation();
   937             Window().Invalidate( Rect() );
   968             Window().Invalidate( Rect() );
   938             break;
   969             break;
   939 
   970 
   940         case EEikScrollThumbDragHoriz:
   971         case EEikScrollThumbDragHoriz:
   942             UpdateAnimation();
   973             UpdateAnimation();
   943             Window().Invalidate( Rect() );
   974             Window().Invalidate( Rect() );
   944             break;
   975             break;
   945 
   976 
   946         case EEikScrollThumbReleaseHoriz:
   977         case EEikScrollThumbReleaseHoriz:
   947             UpdateScrollbars();
   978             UpdateScrollbars( ETrue );
   948             break;
   979             break;
   949 
   980 
   950         case EEikScrollHome:
   981         case EEikScrollHome:
   951             // Not in use!
   982             // Not in use
   952             break;
   983             break;
   953 
   984 
   954        case EEikScrollEnd:
   985        case EEikScrollEnd:
   955            // Not in use!
   986            // Not in use
   956            break;
   987            break;
   957 
   988 
   958         default:
   989         default:
   959             break;
   990             break;
   960         }
   991         }
  1049             break;
  1080             break;
  1050         }
  1081         }
  1051 
  1082 
  1052     if ( aDrawNow )
  1083     if ( aDrawNow )
  1053         {
  1084         {
  1054 		// it should be DrawNow() here for fixing bug JLAI-7UE9RN
  1085 		// DrawNow must be used here.
  1055         DrawNow();
  1086         DrawNow();
  1056         //Window().Invalidate( Rect() );
       
  1057         }
  1087         }
  1058     }
  1088     }
  1059 
  1089 
  1060 
  1090 
  1061 // ---------------------------------------------------------------------------
  1091 // ---------------------------------------------------------------------------
  1135         {
  1165         {
  1136         Window().Invalidate( Rect() );
  1166         Window().Invalidate( Rect() );
  1137         }
  1167         }
  1138     else if ( IsFocused() && FocusedItemVisible() )
  1168     else if ( IsFocused() && FocusedItemVisible() )
  1139         {
  1169         {
  1140         TRect rect = iItems[FocusIndex()].HighlightRect( iViewLevel, Indention(), IndentionWidth() );
  1170         TRect rect = iItems[FocusIndex()].HighlightRect( iViewLevel,
       
  1171                                                          Indention(),
       
  1172                                                          IndentionWidth() );
  1141         Window().Invalidate( rect );
  1173         Window().Invalidate( rect );
  1142         }
  1174         }
  1143         
  1175         
  1144     ReportTreeListEvent( MAknTreeListObserver::EItemFocused,
  1176     ReportTreeListEvent( MAknTreeListObserver::EItemFocused,
  1145         iTree.Id( FocusedItem() ) );
  1177         iTree.Id( FocusedItem() ) );
  1155     {
  1187     {
  1156     // Get layout for the view.
  1188     // Get layout for the view.
  1157     LayoutView();
  1189     LayoutView();
  1158 
  1190 
  1159     // Update scrollbars.
  1191     // Update scrollbars.
  1160     UpdateScrollbars();
  1192     UpdateScrollbars( ETrue );
  1161 
  1193 
  1162     UpdateIndexes();
  1194     UpdateIndexes();
  1163     AknsUtils::RegisterControlPosition( this, PositionRelativeToScreen() );
  1195     AknsUtils::RegisterControlPosition( this, PositionRelativeToScreen() );
  1164     
  1196     
  1165     TRAP_IGNORE( InitPhysicsL() );
  1197     TRAP_IGNORE( InitPhysicsL() );
  1268         }
  1300         }
  1269     else
  1301     else
  1270         {
  1302         {
  1271         EnableHighlight( ETrue );
  1303         EnableHighlight( ETrue );
  1272         }
  1304         }
       
  1305     
       
  1306     iMirroredLayoutInUse = AknLayoutUtils::LayoutMirrored();
  1273     }
  1307     }
  1274 
  1308 
  1275 
  1309 
  1276 // ---------------------------------------------------------------------------
  1310 // ---------------------------------------------------------------------------
  1277 // Handles an addition of new item into tree list. The focused item is kept
  1311 // Handles an addition of new item into tree list. The focused item is kept
  1280 // ---------------------------------------------------------------------------
  1314 // ---------------------------------------------------------------------------
  1281 //
  1315 //
  1282 void CAknTreeListView::HandleItemAddedEvent( CAknTreeItem* /*aItem*/, TBool aDrawNow )
  1316 void CAknTreeListView::HandleItemAddedEvent( CAknTreeItem* /*aItem*/, TBool aDrawNow )
  1283     {
  1317     {
  1284     UpdateVisibleItems();
  1318     UpdateVisibleItems();
  1285     if (aDrawNow)
  1319     UpdateScrollbars( aDrawNow );
  1286         {
       
  1287         UpdateScrollbars();
       
  1288         }
       
  1289     }
  1320     }
  1290 
  1321 
  1291 
  1322 
  1292 // ---------------------------------------------------------------------------
  1323 // ---------------------------------------------------------------------------
  1293 // Handles the movement of a tree item. Movement of focused item has to be
  1324 // Handles the movement of a tree item. Movement of focused item has to be
  1298     {
  1329     {
  1299     // Note: This method cannot deduce, which items in the view have actually
  1330     // Note: This method cannot deduce, which items in the view have actually
  1300     // been changed, unless the it receives information from where the
  1331     // been changed, unless the it receives information from where the
  1301     // specified item was moved.
  1332     // specified item was moved.
  1302     UpdateVisibleItems();
  1333     UpdateVisibleItems();
  1303     UpdateScrollbars();
  1334     UpdateScrollbars( ETrue );
  1304     }
  1335     }
  1305 
  1336 
  1306 
  1337 
  1307 // ---------------------------------------------------------------------------
  1338 // ---------------------------------------------------------------------------
  1308 // Prepares view for the item removal by moving the focus from the removed
  1339 // Prepares view for the item removal by moving the focus from the removed
  1353 // ---------------------------------------------------------------------------
  1384 // ---------------------------------------------------------------------------
  1354 //
  1385 //
  1355 void CAknTreeListView::HandleItemRemovedEvent( CAknTreeItem* /*aItem*/, TBool aDrawNow )
  1386 void CAknTreeListView::HandleItemRemovedEvent( CAknTreeItem* /*aItem*/, TBool aDrawNow )
  1356     {
  1387     {
  1357     UpdateVisibleItems();
  1388     UpdateVisibleItems();
  1358     if (aDrawNow)
  1389     UpdateScrollbars( aDrawNow );
  1359         {
       
  1360         UpdateScrollbars();
       
  1361         }
       
  1362     }
  1390     }
  1363 
  1391 
  1364 
  1392 
  1365 // ---------------------------------------------------------------------------
  1393 // ---------------------------------------------------------------------------
  1366 // Handles an expansion of a tree node. If the expanded node is focused, it is
  1394 // Handles an expansion of a tree node. If the expanded node is focused, it is
  1379         }
  1407         }
  1380     else
  1408     else
  1381         {
  1409         {
  1382         UpdateVisibleItems();
  1410         UpdateVisibleItems();
  1383         }
  1411         }
  1384     UpdateScrollbars();
  1412 
       
  1413     UpdateScrollbars( ETrue );
  1385     }
  1414     }
  1386 
  1415 
  1387 
  1416 
  1388 // ---------------------------------------------------------------------------
  1417 // ---------------------------------------------------------------------------
  1389 // Handles a collapse of a tree node. If one of the items in collapsed node
  1418 // Handles a collapse of a tree node. If one of the items in collapsed node
  1419         // visible
  1448         // visible
  1420         UpdateViewItemAsVisible( aNode );
  1449         UpdateViewItemAsVisible( aNode );
  1421         }
  1450         }
  1422 
  1451 
  1423     UpdateVisibleItems();
  1452     UpdateVisibleItems();
  1424     UpdateScrollbars();
  1453     UpdateScrollbars( ETrue );
  1425     }
  1454     }
  1426 
  1455 
  1427 
  1456 
  1428 // ---------------------------------------------------------------------------
  1457 // ---------------------------------------------------------------------------
  1429 // Handles a change in tree item.
  1458 // Handles a change in tree item.
  1471                 {
  1500                 {
  1472                 iItems[ii].SetItem( iterator.Next() );
  1501                 iItems[ii].SetItem( iterator.Next() );
  1473                 }
  1502                 }
  1474             }
  1503             }
  1475         }
  1504         }
  1476     if ( aDrawNow )
  1505 
  1477         {
  1506     UpdateScrollbars( aDrawNow );
  1478         UpdateScrollbars();
       
  1479         }
       
  1480     }
  1507     }
  1481 
  1508 
  1482 
  1509 
  1483 // ---------------------------------------------------------------------------
  1510 // ---------------------------------------------------------------------------
  1484 // Updates the view items so that the specified item is located at the
  1511 // Updates the view items so that the specified item is located at the
  1624 // Handles right arrow key event.
  1651 // Handles right arrow key event.
  1625 // ---------------------------------------------------------------------------
  1652 // ---------------------------------------------------------------------------
  1626 //
  1653 //
  1627 void CAknTreeListView::HandleRightArrowKeyEvent()
  1654 void CAknTreeListView::HandleRightArrowKeyEvent()
  1628     {
  1655     {
  1629     if ( AknLayoutUtils::LayoutMirrored() )
  1656     if ( iMirroredLayoutInUse )
  1630         {
  1657         {
  1631         AscendFocus();
  1658         AscendFocus();
  1632         }
  1659         }
  1633     else
  1660     else
  1634         {
  1661         {
  1641 // Handles left arrow key event.
  1668 // Handles left arrow key event.
  1642 // ---------------------------------------------------------------------------
  1669 // ---------------------------------------------------------------------------
  1643 //
  1670 //
  1644 void CAknTreeListView::HandleLeftArrowKeyEvent()
  1671 void CAknTreeListView::HandleLeftArrowKeyEvent()
  1645     {
  1672     {
  1646     if ( AknLayoutUtils::LayoutMirrored() )
  1673     if ( iMirroredLayoutInUse )
  1647         {
  1674         {
  1648         DescendFocus();
  1675         DescendFocus();
  1649         }
  1676         }
  1650     else
  1677     else
  1651         {
  1678         {
  1979     TRect viewRect( listRect );
  2006     TRect viewRect( listRect );
  1980     
  2007     
  1981     // Fill whole control area with list items when physics enabled
  2008     // Fill whole control area with list items when physics enabled
  1982     // and threre is no horizontal scrollbar.  
  2009     // and threre is no horizontal scrollbar.  
  1983     if ( iScrollbarFrame &&
  2010     if ( iScrollbarFrame &&
  1984          iScrollbarFrame->ScrollBarVisibility( CEikScrollBar::EHorizontal ) != CEikScrollBarFrame::EOn && 
  2011          iScrollbarFrame->ScrollBarVisibility(
       
  2012              CEikScrollBar::EHorizontal ) != CEikScrollBarFrame::EOn && 
  1985          viewRect.Height() < Rect().Height() )
  2013          viewRect.Height() < Rect().Height() )
  1986         {
  2014         {
  1987         viewRect.iTl.iY = Rect().iTl.iY;
  2015         viewRect.iTl.iY = Rect().iTl.iY;
  1988         viewRect.iBr.iY = Rect().iBr.iY;
  2016         viewRect.iBr.iY = Rect().iBr.iY;
  1989         }
  2017         }
  1997 // Updates the span, thumb size and position for both of the scrollbars. New
  2025 // Updates the span, thumb size and position for both of the scrollbars. New
  1998 // layout for the view is applied, if the visibility of either of the
  2026 // layout for the view is applied, if the visibility of either of the
  1999 // scrollbars changes.
  2027 // scrollbars changes.
  2000 // ---------------------------------------------------------------------------
  2028 // ---------------------------------------------------------------------------
  2001 //
  2029 //
  2002 void CAknTreeListView::UpdateScrollbars()
  2030 void CAknTreeListView::UpdateScrollbars( TBool aDrawNow )
  2003     {
  2031     {
  2004     if ( iScrollbarFrame )
  2032     if ( iScrollbarFrame )
  2005         {
  2033         {
       
  2034         TBool drawHorizontal;
       
  2035         TBool drawVertical;
       
  2036         if ( !aDrawNow )
       
  2037             {
       
  2038             // Backup the old values.
       
  2039             iScrollbarFrame->DrawBackgroundState( drawHorizontal,
       
  2040                                                   drawVertical );
       
  2041         
       
  2042             // Disable the scrollbar background drawing for the duration
       
  2043             // of this call.
       
  2044             iScrollbarFrame->DrawBackground( EFalse, EFalse );
       
  2045             }
       
  2046             
       
  2047     
  2006         iPhysicsHandler->UpdateScrollIndex( iScrollPhysicsTop );
  2048         iPhysicsHandler->UpdateScrollIndex( iScrollPhysicsTop );
  2007         iScrollPhysicsTop = ETrue;
  2049         iScrollPhysicsTop = ETrue;
  2008         
  2050         
  2009         // Get values for horizontal scrollbar.
  2051         // Get values for horizontal scrollbar.
  2010         TInt hThumbPos = iViewLevel;
  2052         TInt hThumbPos = iViewLevel;
  2019                 IndentionWidth() ).Width();
  2061                 IndentionWidth() ).Width();
  2020             hThumbSpan = a/b;
  2062             hThumbSpan = a/b;
  2021             hScrollSpan = Max( hThumbPos + hThumbSpan, c/b );
  2063             hScrollSpan = Max( hThumbPos + hThumbSpan, c/b );
  2022             }
  2064             }
  2023 
  2065 
  2024         if ( AknLayoutUtils::LayoutMirrored() )
  2066         if ( iMirroredLayoutInUse )
  2025             {
  2067             {
  2026             hThumbPos = hScrollSpan - ( hThumbPos + hThumbSpan );
  2068             hThumbPos = hScrollSpan - ( hThumbPos + hThumbSpan );
  2027             }
  2069             }
  2028         TEikScrollBarModel hModel( hScrollSpan, hThumbSpan, hThumbPos );
  2070         TEikScrollBarModel hModel( hScrollSpan, hThumbSpan, hThumbPos );
  2029 
  2071 
  2066 
  2108 
  2067             // Set new model for scrollbars.
  2109             // Set new model for scrollbars.
  2068             iScrollbarFrame->Tile( &hModel, &vModel );
  2110             iScrollbarFrame->Tile( &hModel, &vModel );
  2069 
  2111 
  2070             LayoutView();
  2112             LayoutView();
  2071             UpdateScrollbars(); // Recursion
  2113             UpdateScrollbars( aDrawNow ); // Recursion
  2072             
  2114             
  2073             // Update animation in case that scrollbar visibility change
  2115             // Update animation in case that scrollbar visibility change
  2074             // has affected the highlight size of focused item.
  2116             // has affected the highlight size of focused item.
  2075             UpdateAnimation();
  2117             UpdateAnimation();
  2076             }
  2118             }
  2077         else
  2119         else
  2078             {
  2120             {
  2079             // Set new model for scrollbars.
  2121             // Set new model for scrollbars.
  2080             iScrollbarFrame->Tile( &hModel, &vModel );  
  2122             iScrollbarFrame->Tile( &hModel, &vModel );  
  2081             }        
  2123             }
       
  2124         
       
  2125         if ( !aDrawNow )
       
  2126             {
       
  2127             // Restore the previous draw background state values.
       
  2128             iScrollbarFrame->DrawBackground( drawHorizontal, drawVertical );
       
  2129             }
  2082         }
  2130         }
  2083        
  2131        
  2084     }
  2132     }
  2085     
  2133     
  2086     
  2134     
  2780             {
  2828             {
  2781             TRect drawRect( iItems[ii].Rect() );
  2829             TRect drawRect( iItems[ii].Rect() );
  2782 
  2830 
  2783             if ( iItems[ii].Item() )
  2831             if ( iItems[ii].Item() )
  2784                 {
  2832                 {
       
  2833                 if ( !aRect.Intersects(drawRect) )
       
  2834                     {
       
  2835                     //invisible item yet
       
  2836                     continue;
       
  2837                     }
       
  2838 
  2785 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2839 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2786                 TRect tfxDrawRect( drawRect );
  2840                 TRect tfxDrawRect( drawRect );
  2787                 tfxDrawRect.Move( 0, -offset );
  2841                 tfxDrawRect.Move( 0, -offset );
  2788 
  2842 
  2789                 if ( transApi )
  2843                 if ( transApi )
  2790                     {
  2844                     {
  2791                     transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified );
  2845                     transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified );
  2792                     }
  2846                     }
  2793 
  2847 
  2794   
       
  2795                 TRect clippingRect( tfxDrawRect );
  2848                 TRect clippingRect( tfxDrawRect );
  2796                 
  2849                 
  2797                 // If horizontal scrollbar on, reduce clipping rect
  2850                 // If horizontal scrollbar on, reduce clipping rect
  2798                 // based on view rect from layout data 
  2851                 // based on view rect from layout data 
  2799                 if ( iScrollbarFrame->ScrollBarVisibility( CEikScrollBar::EHorizontal )
  2852                 if ( iScrollbarFrame->ScrollBarVisibility( CEikScrollBar::EHorizontal )
  2807                     }
  2860                     }
  2808                 
  2861                 
  2809                 // Set clipping rect.    
  2862                 // Set clipping rect.    
  2810                 gc.SetClippingRect( clippingRect );
  2863                 gc.SetClippingRect( clippingRect );
  2811 
  2864 
  2812 
       
  2813                 if ( transApi )
  2865                 if ( transApi )
  2814                     {
  2866                     {
  2815                     transApi->StopDrawing();
  2867                     transApi->StopDrawing();
  2816                     }
  2868                     }
  2817 #endif
  2869 #endif
  2818                 if ( ii < iBottomIndex )
  2870                 if ( ii < iBottomIndex )
  2819                     {
  2871                     {
  2820                     AknListUtils::DrawSeparator( gc, drawRect, textColor, skin );
  2872                     TRect offsetRect( drawRect );
       
  2873                     offsetRect.Move( 0, -offset );
       
  2874                     AknListUtils::DrawSeparator( gc, offsetRect, textColor, skin );
  2821                     }
  2875                     }
  2822 
  2876 
  2823                 TBool focused = ( IsFocused() && FocusedItem() &&
  2877                 TBool focused = ( IsFocused() && FocusedItem() &&
  2824                     iItems[ii].Item() == FocusedItem() );
  2878                     iItems[ii].Item() == FocusedItem() );
  2825 
  2879 
  2843                         {
  2897                         {
  2844 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2898 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2845                         if ( transApi )
  2899                         if ( transApi )
  2846                             {
  2900                             {
  2847                             transApi->Invalidate(MAknListBoxTfxInternal::EListHighlight );
  2901                             transApi->Invalidate(MAknListBoxTfxInternal::EListHighlight );
  2848                             transApi->BeginRedraw( MAknListBoxTfxInternal::EListHighlight, tfxHighlightRect );
  2902                             transApi->BeginRedraw( MAknListBoxTfxInternal::EListHighlight,
       
  2903                                                    tfxHighlightRect );
  2849                             transApi->StartDrawing( MAknListBoxTfxInternal::EListHighlight );
  2904                             transApi->StartDrawing( MAknListBoxTfxInternal::EListHighlight );
  2850                             }
  2905                             }
  2851 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  2906 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  2852 
  2907 
  2853                         DrawHighlight( gc, highlightRect, iIsPressedDownState );
  2908                         DrawHighlight( gc, highlightRect, iIsPressedDownState );
  2871 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2926 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2872                 if (iItems[ii].Item()) 
  2927                 if (iItems[ii].Item()) 
  2873                 {
  2928                 {
  2874                 if ( transApi )
  2929                 if ( transApi )
  2875                     {
  2930                     {
  2876                     transApi->BeginRedraw(MAknListBoxTfxInternal::EListItem, tfxDrawRect, iTree.VisibleItemIndex(iItems[ii].Item()));
  2931                     transApi->BeginRedraw(
       
  2932                         MAknListBoxTfxInternal::EListItem,
       
  2933                         tfxDrawRect,
       
  2934                         iTree.VisibleItemIndex( iItems[ii].Item() ) );
  2877                     transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
  2935                     transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
  2878                     }
  2936                     }
  2879 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  2937 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  2880 
  2938 
  2881                 // Draw item.
  2939                 // Draw item.
  2884 
  2942 
  2885 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2943 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2886                 if ( transApi )
  2944                 if ( transApi )
  2887                     {
  2945                     {
  2888                     transApi->StopDrawing();
  2946                     transApi->StopDrawing();
  2889                     transApi->EndRedraw(MAknListBoxTfxInternal::EListItem, iTree.VisibleItemIndex(iItems[ii].Item()));
  2947                     transApi->EndRedraw(
       
  2948                         MAknListBoxTfxInternal::EListItem,
       
  2949                         iTree.VisibleItemIndex( iItems[ii].Item() ) );
  2890                     }
  2950                     }
  2891                 }
  2951                 }
  2892 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  2952 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  2893 
  2953 
  2894                 }
  2954                 }