uifw/AvKon/aknhlist/src/akntreelistview.cpp
branchRCL_3
changeset 12 941195f2d488
parent 10 3d340a0166ff
child 15 c52421ed5f07
equal deleted inserted replaced
10:3d340a0166ff 12:941195f2d488
    27 #include <AknTasHook.h> // for testability hooks
    27 #include <AknTasHook.h> // for testability hooks
    28 #include <AknPriv.hrh>
    28 #include <AknPriv.hrh>
    29 #include <AknIconArray.h>
    29 #include <AknIconArray.h>
    30 #include <avkon.mbg>
    30 #include <avkon.mbg>
    31 #include <gulicon.h>
    31 #include <gulicon.h>
       
    32 #include <aknmarkingmodeobserver.h>
    32 #include "akntreelistview.h"
    33 #include "akntreelistview.h"
    33 #include "akntree.h"
    34 #include "akntree.h"
    34 #include "akntreelist.h"
    35 #include "akntreelist.h"
    35 #include "akntreeiterator.h"
    36 #include "akntreeiterator.h"
    36 #include "akntreelistphysicshandler.h"
    37 #include "akntreelistphysicshandler.h"
    50 const TInt KLongPressInterval = 600000; // 0.6 seconds
    51 const TInt KLongPressInterval = 600000; // 0.6 seconds
    51 
    52 
    52 // Number of additional items to draw
    53 // Number of additional items to draw
    53 const TInt KAdditionalItems = 2;
    54 const TInt KAdditionalItems = 2;
    54 
    55 
    55 // Space for check box in marking mode
    56 // Number of icons in marking mode icon array
    56 const TInt KCheckBoxOffset = 30;
    57 const TInt KMarkingModeIconArraySize = 2;
    57 
    58 
    58 // Tree list view flag definitions.
    59 // Tree list view flag definitions.
    59 enum TAknTreeListViewFlags
    60 enum TAknTreeListViewFlags
    60     {
    61     {
    61     EFlagStructureLines,
    62     EFlagStructureLines,
    71     EFlagCtrlKeyPressed,
    72     EFlagCtrlKeyPressed,
    72     EFlagShiftKeyPressed,
    73     EFlagShiftKeyPressed,
    73     EFlagSaveFocusAfterSorting,
    74     EFlagSaveFocusAfterSorting,
    74     EFlagSingleClickEnabled,
    75     EFlagSingleClickEnabled,
    75     EFlagHighlightEnabled, // Is highlight drawing enabled
    76     EFlagHighlightEnabled, // Is highlight drawing enabled
    76     EFlagIgnoreButtonUpEvent // Up event ignored (when styluspopup menu open)
    77     EFlagIsPressedDownState,
       
    78     EFlagIsDragged,
       
    79     EFlagScrollPhysicsTop, // Physics view adjusted according to top item
       
    80     EFlagMirroredLayoutInUse, // Mirrored layout in use
       
    81     EFlagMarkingMode // Marking mode activated    
    77     };
    82     };
    78 
    83 
    79 
    84 
    80 // ======== MEMBER FUNCTIONS ========
    85 // ======== MEMBER FUNCTIONS ========
    81 
    86 
   480 // SelectItem
   485 // SelectItem
   481 // ---------------------------------------------------------------------------
   486 // ---------------------------------------------------------------------------
   482 //     
   487 //     
   483 void CAknTreeListView::SelectItem( CAknTreeItem* aSelectedItem )
   488 void CAknTreeListView::SelectItem( CAknTreeItem* aSelectedItem )
   484     {
   489     {
   485     if ( iMarkingMode )
   490     if ( iFlags.IsSet( EFlagMarkingMode ) )
   486         {
   491         {
   487         if ( aSelectedItem->IsMarkable() )
   492         if ( aSelectedItem->IsMarkable() )
   488             {
   493             {
   489             MarkItem( aSelectedItem, !aSelectedItem->IsMarked(), ETrue );
   494             MarkItem( aSelectedItem, !aSelectedItem->IsMarked(), ETrue );
   490             }
   495             }
   516 // SetPressedDownState
   521 // SetPressedDownState
   517 // ---------------------------------------------------------------------------
   522 // ---------------------------------------------------------------------------
   518 //     
   523 //     
   519 void CAknTreeListView::SetPressedDownState( const TBool& aPressedDown )
   524 void CAknTreeListView::SetPressedDownState( const TBool& aPressedDown )
   520     {
   525     {
   521     iIsPressedDownState = aPressedDown;
   526     if ( aPressedDown )
       
   527         {
       
   528         iFlags.Set( EFlagIsPressedDownState );
       
   529         }
       
   530     else
       
   531         {
       
   532         iFlags.Clear( EFlagIsPressedDownState );
       
   533         }
   522     }
   534     }
   523     
   535     
   524 
   536 
   525 // ---------------------------------------------------------------------------
   537 // ---------------------------------------------------------------------------
   526 // UpdateTreeListView
   538 // UpdateTreeListView
   831             break;
   843             break;
   832             }
   844             }
   833 
   845 
   834         case KEikDynamicLayoutVariantSwitch:
   846         case KEikDynamicLayoutVariantSwitch:
   835             {
   847             {
   836             iMirroredLayoutInUse = AknLayoutUtils::LayoutMirrored();
   848             if ( AknLayoutUtils::LayoutMirrored() )
       
   849                 {
       
   850                 iFlags.Set( EFlagMirroredLayoutInUse );
       
   851                 }
       
   852             else
       
   853                 {
       
   854                 iFlags.Clear( EFlagMirroredLayoutInUse );
       
   855                 }
   837 
   856 
   838             CAknTreeItem* focusedItem( FocusedItem() );
   857             CAknTreeItem* focusedItem( FocusedItem() );
   839             if ( focusedItem )
   858             if ( focusedItem )
   840                 {
   859                 {
   841                 if ( !FocusedItemVisible() )
   860                 if ( !FocusedItemVisible() )
   850                     TInt index = 0;
   869                     TInt index = 0;
   851                     if ( firstItemIndex < iTree.VisibleItemIndex( focusedItem ) )
   870                     if ( firstItemIndex < iTree.VisibleItemIndex( focusedItem ) )
   852                         {
   871                         {
   853                         index = iItems.Count() - 1;
   872                         index = iItems.Count() - 1;
   854                         }
   873                         }
   855     
   874 
   856                     SetFocusedItem( focusedItem, index, ETrue );
   875                     if( HighlightEnabled() )
       
   876                         {
       
   877                         SetFocusedItem( focusedItem, index, ETrue );
       
   878                         }
   857                     }
   879                     }
   858                 else
   880                 else
   859                     {
   881                     {
   860                     SetFocusedItem( focusedItem, FocusIndex(), ETrue );
   882                     SetFocusedItem( focusedItem, FocusIndex(), ETrue );
   861 
   883 
   889             break;
   911             break;
   890             }
   912             }
   891             
   913             
   892         case KAknMessageFocusLost:
   914         case KAknMessageFocusLost:
   893             {
   915             {
   894             if ( HighlightEnabled() )
   916             if ( SingleClickEnabled() && HighlightEnabled() &&
       
   917                  ( iOldWinPos == KErrNotFound || 
       
   918                    iOldWinPos == DrawableWindow()->OrdinalPosition() ) )
   895                 {
   919                 {
   896                 EnableHighlight( EFalse );
   920                 EnableHighlight( EFalse );
   897                 // Redraw item
   921                 // Redraw item
   898                 SetFocusedItem( FocusedItem(), FocusIndex(), ETrue );
   922                 SetFocusedItem( FocusedItem(), FocusIndex(), ETrue );
   899                 }
   923                 }
   916 // focused.
   940 // focused.
   917 // ---------------------------------------------------------------------------
   941 // ---------------------------------------------------------------------------
   918 //
   942 //
   919 void CAknTreeListView::HandlePointerEventL( const TPointerEvent& aPointerEvent )
   943 void CAknTreeListView::HandlePointerEventL( const TPointerEvent& aPointerEvent )
   920     {
   944     {
   921     if ( iFlags.IsSet( EFlagIgnoreButtonUpEvent ) 
       
   922          && aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   923         {
       
   924         return;
       
   925         }
       
   926     
       
   927     if ( GrabbingComponent() )
   945     if ( GrabbingComponent() )
   928         {
   946         {
   929         iPhysicsHandler->ResetEventBlockingStatus();
   947         iPhysicsHandler->ResetEventBlockingStatus();
   930         }
   948         }
   931     else
   949     else
   932         {
   950         {
   933         if( aPointerEvent.iType == TPointerEvent::EButton1Down )  
   951         if( aPointerEvent.iType == TPointerEvent::EButton1Down )  
   934             {
   952             {
   935             iFlags.Clear( EFlagIgnoreButtonUpEvent );
       
   936             iPreviouslyFocusedItem = FocusedItem(); 
   953             iPreviouslyFocusedItem = FocusedItem(); 
   937             }
   954             }
   938 
   955 
   939         iPhysicsHandler->HandlePointerEventL( aPointerEvent, iViewLevel, 
   956         iPhysicsHandler->HandlePointerEventL( aPointerEvent, iViewLevel, 
   940             MarkingOngoing(), iFlags.IsSet( EFlagShiftKeyPressed ), 
   957             MarkingOngoing(), iFlags.IsSet( EFlagShiftKeyPressed ), 
   978         {
   995         {
   979         EnableHighlight( EFalse );
   996         EnableHighlight( EFalse );
   980         }
   997         }
   981 
   998 
   982     TInt thumbPosition = aScrollBar->ThumbPosition();
   999     TInt thumbPosition = aScrollBar->ThumbPosition();
   983     if ( iMirroredLayoutInUse &&
  1000     if ( iFlags.IsSet( EFlagMirroredLayoutInUse ) &&
   984          aScrollBar != iScrollbarFrame->VerticalScrollBar() )
  1001          aScrollBar != iScrollbarFrame->VerticalScrollBar() )
   985         {
  1002         {
   986         const TEikScrollBarModel* model = aScrollBar->Model();
  1003         const TEikScrollBarModel* model = aScrollBar->Model();
   987         thumbPosition = ( model->iScrollSpan - model->iThumbSpan )
  1004         thumbPosition = ( model->iScrollSpan - model->iThumbSpan )
   988             - thumbPosition;
  1005             - thumbPosition;
  1267       iViewLevel( 0 ),
  1284       iViewLevel( 0 ),
  1268       iMaxViewLevel( 0 ),
  1285       iMaxViewLevel( 0 ),
  1269       iStylusDownItemIndex( -1 ),
  1286       iStylusDownItemIndex( -1 ),
  1270       iAnimationIID( KAknsIIDQsnAnimList ),
  1287       iAnimationIID( KAknsIIDQsnAnimList ),
  1271       iIndentionWidth( -1 ),
  1288       iIndentionWidth( -1 ),
  1272       iPhysicsHandler( NULL ),
  1289       iPhysicsHandler( NULL )
  1273       iScrollPhysicsTop( ETrue )
       
  1274       #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  1290       #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  1275       ,iGc(NULL)
  1291       ,iGc(NULL)
  1276       #endif //RD_UI_TRANSITION_EFFECTS_LIST
  1292       #endif //RD_UI_TRANSITION_EFFECTS_LIST
  1277       ,iItemActionMenu( NULL ),
  1293       ,iItemActionMenu( NULL ),
  1278       iLongTapDetector( NULL )       
  1294       iLongTapDetector( NULL ),
       
  1295       iOldWinPos( KErrNotFound )
  1279     {
  1296     {
  1280     if ( static_cast<CAknAppUi*>( 
  1297     if ( static_cast<CAknAppUi*>( 
  1281             iCoeEnv->AppUi() )->IsSingleClickCompatible() )
  1298             iCoeEnv->AppUi() )->IsSingleClickCompatible() )
  1282         {
  1299         {
  1283         iFlags.Set( EFlagSingleClickEnabled );
  1300         iFlags.Set( EFlagSingleClickEnabled );
  1284         }
  1301         }
  1285   
  1302   
  1286     iFlags.Set( EFlagStructureLines );
  1303     iFlags.Set( EFlagStructureLines );
  1287     iFlags.Set( EFlagIndention );
  1304     iFlags.Set( EFlagIndention );
       
  1305     iFlags.Set( EFlagScrollPhysicsTop );
  1288     }
  1306     }
  1289 
  1307 
  1290 
  1308 
  1291 // ---------------------------------------------------------------------------
  1309 // ---------------------------------------------------------------------------
  1292 // Second phase constructor.
  1310 // Second phase constructor.
  1320         iPhysicsHandler = CAknTreeListPhysicsHandler::NewL( this,
  1338         iPhysicsHandler = CAknTreeListPhysicsHandler::NewL( this,
  1321                                                             &iTree,
  1339                                                             &iTree,
  1322                                                             &iItems );
  1340                                                             &iItems );
  1323         }
  1341         }
  1324 
  1342 
  1325     iIsPressedDownState = EFalse;
  1343     iFlags.Clear( EFlagIsPressedDownState );   
  1326     iIsDragged = EFalse;
  1344     iFlags.Clear( EFlagIsDragged );
  1327     iItemActionMenu = CAknItemActionMenu::RegisterCollectionL( *this, this );
  1345     iItemActionMenu = CAknItemActionMenu::RegisterCollectionL( *this, this );
  1328 
  1346 
  1329     if ( iItemActionMenu )
  1347     if ( iItemActionMenu )
  1330         {
  1348         {
  1331         iLongTapDetector = CAknLongTapDetector::NewL( this );
  1349         iLongTapDetector = CAknLongTapDetector::NewL( this );
  1337         }
  1355         }
  1338     else
  1356     else
  1339         {
  1357         {
  1340         EnableHighlight( ETrue );
  1358         EnableHighlight( ETrue );
  1341         }
  1359         }
  1342     
  1360     if ( AknLayoutUtils::LayoutMirrored() )
  1343     iMirroredLayoutInUse = AknLayoutUtils::LayoutMirrored();
  1361         {
       
  1362         iFlags.Set( EFlagMirroredLayoutInUse );
       
  1363         }
       
  1364     else
       
  1365         {
       
  1366         iFlags.Clear( EFlagMirroredLayoutInUse );
       
  1367         }
  1344     LoadMarkingIconsL();
  1368     LoadMarkingIconsL();
  1345     }
  1369     }
  1346 
  1370 
  1347 
  1371 
  1348 // ---------------------------------------------------------------------------
  1372 // ---------------------------------------------------------------------------
  1671 void CAknTreeListView::HandleSelectionKeyEvent()
  1695 void CAknTreeListView::HandleSelectionKeyEvent()
  1672     {
  1696     {
  1673     CAknTreeItem* item = FocusedItem();
  1697     CAknTreeItem* item = FocusedItem();
  1674     if ( item )
  1698     if ( item )
  1675         {
  1699         {
  1676         if ( iMarkingMode )
  1700         if ( iFlags.IsSet( EFlagMarkingMode ) )
  1677             {
  1701             {
  1678             if ( item->IsMarkable() )
  1702             if ( item->IsMarkable() )
  1679                 {
  1703                 {
  1680                 MarkItem( item, !item->IsMarked(), ETrue );
  1704                 MarkItem( item, !item->IsMarked(), ETrue );
  1681                 }
  1705                 }
  1692 // Handles right arrow key event.
  1716 // Handles right arrow key event.
  1693 // ---------------------------------------------------------------------------
  1717 // ---------------------------------------------------------------------------
  1694 //
  1718 //
  1695 void CAknTreeListView::HandleRightArrowKeyEvent()
  1719 void CAknTreeListView::HandleRightArrowKeyEvent()
  1696     {
  1720     {
  1697     if ( iMirroredLayoutInUse )
  1721     if ( iFlags.IsSet( EFlagMirroredLayoutInUse ) )
  1698         {
  1722         {
  1699         AscendFocus();
  1723         AscendFocus();
  1700         }
  1724         }
  1701     else
  1725     else
  1702         {
  1726         {
  1709 // Handles left arrow key event.
  1733 // Handles left arrow key event.
  1710 // ---------------------------------------------------------------------------
  1734 // ---------------------------------------------------------------------------
  1711 //
  1735 //
  1712 void CAknTreeListView::HandleLeftArrowKeyEvent()
  1736 void CAknTreeListView::HandleLeftArrowKeyEvent()
  1713     {
  1737     {
  1714     if ( iMirroredLayoutInUse )
  1738     if ( iFlags.IsSet( EFlagMirroredLayoutInUse ) )
  1715         {
  1739         {
  1716         DescendFocus();
  1740         DescendFocus();
  1717         }
  1741         }
  1718     else
  1742     else
  1719         {
  1743         {
  2023     if ( first )
  2047     if ( first )
  2024         {
  2048         {
  2025         iterator.SetCurrent( first );
  2049         iterator.SetCurrent( first );
  2026         iterator.Previous();
  2050         iterator.Previous();
  2027         }
  2051         }
  2028 
  2052     if ( iFlags.IsSet( EFlagMarkingMode ) )    
  2029     if ( iMarkingMode )
  2053 
  2030         {
  2054         {
  2031         itemRect.iBr.iX -= KCheckBoxOffset;
  2055         itemRect.iBr.iX -= 
       
  2056                 AknLayoutScalable_Avkon::list_double_graphic_pane_t1( 
       
  2057                         0 ).LayoutLine().il;
  2032         }
  2058         }
  2033 
  2059 
  2034     // Update items and their rectangles.
  2060     // Update items and their rectangles.
  2035     for ( TInt ii = 0; ii < iItems.Count(); ++ii )
  2061     for ( TInt ii = 0; ii < iItems.Count(); ++ii )
  2036         {
  2062         {
  2088             // Disable the scrollbar background drawing for the duration
  2114             // Disable the scrollbar background drawing for the duration
  2089             // of this call.
  2115             // of this call.
  2090             iScrollbarFrame->DrawBackground( EFalse, EFalse );
  2116             iScrollbarFrame->DrawBackground( EFalse, EFalse );
  2091             }
  2117             }
  2092             
  2118             
       
  2119         iPhysicsHandler->UpdateScrollIndex( 
       
  2120                 iFlags.IsSet( EFlagScrollPhysicsTop ) );
       
  2121         iFlags.Set( EFlagScrollPhysicsTop );
  2093     
  2122     
  2094         iPhysicsHandler->UpdateScrollIndex( iScrollPhysicsTop );
       
  2095         iScrollPhysicsTop = ETrue;
       
  2096         
  2123         
  2097         // Get values for horizontal scrollbar.
  2124         // Get values for horizontal scrollbar.
  2098         TInt hThumbPos = iViewLevel;
  2125         TInt hThumbPos = iViewLevel;
  2099         TInt hThumbSpan = iHorizontalViewSpan;
  2126         TInt hThumbSpan = iHorizontalViewSpan;
  2100         TInt hScrollSpan = Max( hThumbPos + hThumbSpan, iMaxViewLevel );
  2127         TInt hScrollSpan = Max( hThumbPos + hThumbSpan, iMaxViewLevel );
  2106             TInt c = iItems[0].ItemRect( iViewLevel, Indention(),
  2133             TInt c = iItems[0].ItemRect( iViewLevel, Indention(),
  2107                 IndentionWidth() ).Width();
  2134                 IndentionWidth() ).Width();
  2108             hThumbSpan = a/b;
  2135             hThumbSpan = a/b;
  2109             hScrollSpan = Max( hThumbPos + hThumbSpan, c/b );
  2136             hScrollSpan = Max( hThumbPos + hThumbSpan, c/b );
  2110             }
  2137             }
  2111 
  2138         if ( iFlags.IsSet( EFlagMirroredLayoutInUse ) )
  2112         if ( iMirroredLayoutInUse )
  2139 
  2113             {
  2140             {
  2114             hThumbPos = hScrollSpan - ( hThumbPos + hThumbSpan );
  2141             hThumbPos = hScrollSpan - ( hThumbPos + hThumbSpan );
  2115             }
  2142             }
  2116         TEikScrollBarModel hModel( hScrollSpan, hThumbSpan, hThumbPos );
  2143         TEikScrollBarModel hModel( hScrollSpan, hThumbSpan, hThumbPos );
  2117 
  2144 
  2815     CWindowGc& gc = iGc && !empty ? *iGc : SystemGc();
  2842     CWindowGc& gc = iGc && !empty ? *iGc : SystemGc();
  2816 #else
  2843 #else
  2817     CWindowGc& gc = SystemGc();
  2844     CWindowGc& gc = SystemGc();
  2818 #endif
  2845 #endif
  2819 
  2846 
       
  2847     TInt checkBoxOffset = 
       
  2848             AknLayoutScalable_Avkon::list_double_graphic_pane_t1( 
       
  2849                     0 ).LayoutLine().il;                                         
  2820 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2850 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2821     MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( &gc );
  2851     MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( &gc );
  2822     if ( !empty && transApi )
  2852     if ( !empty && transApi )
  2823         {
  2853         {
  2824         
  2854         
  2865         TRgb textColor( KRgbBlack );
  2895         TRgb textColor( KRgbBlack );
  2866         AknsUtils::GetCachedColor( skin,
  2896         AknsUtils::GetCachedColor( skin,
  2867                                    textColor, 
  2897                                    textColor, 
  2868                                    KAknsIIDQsnTextColors,
  2898                                    KAknsIIDQsnTextColors,
  2869                                    EAknsCIQsnTextColorsCG6 );
  2899                                    EAknsCIQsnTextColorsCG6 );
  2870 
  2900         if ( iFlags.IsSet( EFlagMarkingMode ) 
  2871         if ( iMarkingMode && iMarkingIconArray && iMarkingIconArray->Count()== 2 )
  2901                 && iMarkingIconArray 
       
  2902                 && iMarkingIconArray->Count() == KMarkingModeIconArraySize  )
       
  2903 
  2872             {
  2904             {
  2873             // Set sizes for marking icon bitmaps
  2905             // Set sizes for marking icon bitmaps
  2874             TRect drawRect; 
  2906             TRect drawRect; 
  2875             if ( iItems.Count() > 0 ) 
  2907             drawRect = iItems[0].Rect();
  2876                 {
       
  2877                 drawRect = iItems[0].Rect();
       
  2878                 drawRect.iBr.iX += KCheckBoxOffset;
       
  2879                 }
       
  2880 
  2908 
  2881             // Rect for the marking icon
  2909             // Rect for the marking icon
  2882             TRect iconRect = RectFromLayout( drawRect,
  2910             TRect iconRect = RectFromLayout( drawRect,
  2883                     AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) );
  2911                     AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) );
  2884             iconRect.Move( 0, -offset );
       
  2885             
       
  2886             gc.SetPenColor( textColor );
       
  2887             gc.SetPenStyle( CGraphicsContext::ESolidPen );
       
  2888             
  2912             
  2889             for ( TInt ii = 0; ii < iMarkingIconArray->Count(); ++ii )
  2913             for ( TInt ii = 0; ii < iMarkingIconArray->Count(); ++ii )
  2890                 {
  2914                 {
  2891                 CGulIcon* icon = (*iMarkingIconArray)[ii];
  2915                 CGulIcon* icon = ( *iMarkingIconArray )[ii];            
  2892                 CFbsBitmap* bitmap = icon->Bitmap();
  2916                 CFbsBitmap* bitmap = icon->Bitmap();
  2893 
  2917 
  2894                 if ( bitmap )
  2918                 if ( bitmap )
  2895                     {
  2919                     {
  2896                     TSize size( bitmap->SizeInPixels() ); // set size if not already
  2920                     TSize size( bitmap->SizeInPixels() ); // set size if not already
  2908         const TInt itemCount = iItems.Count();
  2932         const TInt itemCount = iItems.Count();
  2909         for ( TInt ii = 0; ii < itemCount; ++ii )
  2933         for ( TInt ii = 0; ii < itemCount; ++ii )
  2910             {
  2934             {
  2911             TRect drawRect( iItems[ii].Rect() );
  2935             TRect drawRect( iItems[ii].Rect() );
  2912 
  2936 
  2913             if ( iMarkingMode )
  2937             if ( iFlags.IsSet( EFlagMarkingMode ) )
  2914                 {
  2938                 {
  2915                 drawRect.iBr.iX += KCheckBoxOffset;
  2939                 drawRect.iBr.iX += checkBoxOffset;                    
  2916                 }
  2940                 }
  2917 
  2941 
  2918             if ( iItems[ii].Item() )
  2942             if ( iItems[ii].Item() )
  2919                 {
  2943                 {
  2920 
  2944 
  2956                     {
  2980                     {
  2957                     transApi->StopDrawing();
  2981                     transApi->StopDrawing();
  2958                     }
  2982                     }
  2959 #endif
  2983 #endif
  2960 
  2984 
  2961                 if ( iMarkingMode && iMarkingIconArray && iMarkingIconArray->Count()== 2 )
  2985                 if ( iFlags.IsSet( EFlagMarkingMode ) && iMarkingIconArray 
       
  2986                         && iMarkingIconArray->Count() == 
       
  2987                                 KMarkingModeIconArraySize )
  2962                     {
  2988                     {
  2963                     // Rect for the marking icon
  2989                     // Rect for the marking icon
  2964                     TRect iconRect = RectFromLayout( drawRect,
  2990                     TRect iconRect = RectFromLayout( drawRect,
  2965                         AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) );
  2991                         AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) );
  2966             
  2992             
  2967                     iconRect.Move( 0, -offset );
  2993                     iconRect.Move( 0, -offset );
  2968                     CGulIcon* icon = (*iMarkingIconArray)[1]; // unchecked
  2994                     // unchecked icon
       
  2995                     CGulIcon* icon = ( *iMarkingIconArray )[1];                    
  2969 
  2996 
  2970                     TBool marked = ( iItems[ii].Item()->IsMarked() );
  2997                     TBool marked = ( iItems[ii].Item()->IsMarked() );
  2971                     if ( marked )
  2998                     if ( marked )
  2972                         {
  2999                         {
  2973                         icon = (*iMarkingIconArray)[0];
  3000                         icon = (*iMarkingIconArray)[0];
  2987                     TRect offsetRect( drawRect );
  3014                     TRect offsetRect( drawRect );
  2988                     offsetRect.Move( 0, -offset );
  3015                     offsetRect.Move( 0, -offset );
  2989                     AknListUtils::DrawSeparator( gc, offsetRect, textColor, skin );
  3016                     AknListUtils::DrawSeparator( gc, offsetRect, textColor, skin );
  2990                     }
  3017                     }
  2991 
  3018 
  2992                 if ( iMarkingMode )
  3019                 if ( iFlags.IsSet( EFlagMarkingMode ) )
  2993                     {
  3020                     {
  2994                     gc.SetOrigin( TPoint( KCheckBoxOffset, 0 ) );
  3021                     gc.SetOrigin( TPoint( checkBoxOffset, 0 ) );
  2995                     drawRect.iBr.iX -= KCheckBoxOffset;
  3022                     drawRect.iBr.iX -= checkBoxOffset;                
  2996                     }
  3023                     }
  2997 
  3024 
  2998                 TBool focused = ( FocusedItem() &&
  3025                 TBool focused = ( FocusedItem() &&
  2999                     iItems[ii].Item() == FocusedItem() );
  3026                     iItems[ii].Item() == FocusedItem() );
  3000 
  3027 
  3012 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3039 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3013                         TRect tfxHighlightRect( highlightRect );
  3040                         TRect tfxHighlightRect( highlightRect );
  3014                         tfxHighlightRect.Move( 0, -offset );
  3041                         tfxHighlightRect.Move( 0, -offset );
  3015 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3042 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3016 
  3043 
  3017                     if ( iIsPressedDownState || !DrawAnimation( gc, highlightRect ) )
  3044                     if ( iFlags.IsSet( EFlagIsPressedDownState ) 
       
  3045                             || !DrawAnimation( gc, highlightRect ) )
  3018                         {
  3046                         {
  3019 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3047 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3020                         if ( transApi )
  3048                         if ( transApi )
  3021                             {
  3049                             {
  3022                             transApi->Invalidate(MAknListBoxTfxInternal::EListHighlight );
  3050                             transApi->Invalidate(MAknListBoxTfxInternal::EListHighlight );
  3023                             transApi->BeginRedraw( MAknListBoxTfxInternal::EListHighlight,
  3051                             transApi->BeginRedraw( MAknListBoxTfxInternal::EListHighlight,
  3024                                                    tfxHighlightRect );
  3052                                                    tfxHighlightRect );
  3025                             transApi->StartDrawing( MAknListBoxTfxInternal::EListHighlight );
  3053                             transApi->StartDrawing( MAknListBoxTfxInternal::EListHighlight );
  3026                             }
  3054                             }
  3027 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3055 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3028 
  3056                         DrawHighlight( gc, highlightRect, 
  3029                         DrawHighlight( gc, highlightRect, iIsPressedDownState );
  3057                                 iFlags.IsSet( EFlagIsPressedDownState ) );
       
  3058 
  3030 
  3059 
  3031 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3060 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3032                         if ( transApi )
  3061                         if ( transApi )
  3033                             {
  3062                             {
  3034                             transApi->StopDrawing();
  3063                             transApi->StopDrawing();
  3055                         iTree.VisibleItemIndex( iItems[ii].Item() ) );
  3084                         iTree.VisibleItemIndex( iItems[ii].Item() ) );
  3056                     transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
  3085                     transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
  3057                     }
  3086                     }
  3058 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3087 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3059 
  3088 
  3060                 if ( iMarkingMode )
  3089                 if ( iFlags.IsSet( EFlagMarkingMode ) )
  3061                     {
  3090                     {
  3062                     TBool marked = iItems[ii].Item()->IsMarked();
  3091                     TBool marked = iItems[ii].Item()->IsMarked();
  3063                     if ( marked )
  3092                     if ( marked )
  3064                         {
  3093                         {
  3065                         iItems[ii].Item()->SetMarked( EFalse );
  3094                         iItems[ii].Item()->SetMarked( EFalse );
  3087                         iTree.VisibleItemIndex( iItems[ii].Item() ) );
  3116                         iTree.VisibleItemIndex( iItems[ii].Item() ) );
  3088                     }
  3117                     }
  3089                 }
  3118                 }
  3090 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3119 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3091 
  3120 
  3092                 if ( iMarkingMode )
  3121                 if ( iFlags.IsSet( EFlagMarkingMode ) )
  3093                     {
  3122                     {
  3094                     gc.SetOrigin( TPoint( 0, 0 ) );
  3123                     gc.SetOrigin( TPoint( 0, 0 ) );
  3095                     }
  3124                     }
  3096                 }
  3125                 }
  3097             }
  3126             }
  3181                     SetFocusIndex( ii );
  3210                     SetFocusIndex( ii );
  3182                     }
  3211                     }
  3183                 item = iterator.Previous();
  3212                 item = iterator.Previous();
  3184                 }
  3213                 }
  3185             }
  3214             }
  3186         iScrollPhysicsTop = EFalse;
  3215         iFlags.Clear( EFlagScrollPhysicsTop );
  3187         }
  3216         }
  3188         
  3217         
  3189     }
  3218     }
  3190 
  3219 
  3191 
  3220 
  3266 
  3295 
  3267     if ( iList.Flags() & KAknTreeListMarkable )
  3296     if ( iList.Flags() & KAknTreeListMarkable )
  3268         {
  3297         {
  3269         state |= MAknCollection::EStateMultipleSelection;        
  3298         state |= MAknCollection::EStateMultipleSelection;        
  3270         }
  3299         }
  3271 
  3300     TBool markedItems( EFalse );
       
  3301     TRAP_IGNORE( markedItems = HasMarkedItemsL() );
       
  3302     if ( markedItems )
       
  3303         {
       
  3304         state |= MAknCollection::EStateMarkedItems; 
       
  3305         }
  3272     return state;
  3306     return state;
  3273     }
  3307     }
  3274 
  3308 
  3275 // -----------------------------------------------------------------------------
  3309 // -----------------------------------------------------------------------------
  3276 // CAknTreeListView::ItemActionMenuClosed
  3310 // CAknTreeListView::ItemActionMenuClosed
  3277 // -----------------------------------------------------------------------------
  3311 // -----------------------------------------------------------------------------
  3278 //
  3312 //
  3279 void CAknTreeListView::ItemActionMenuClosed()
  3313 void CAknTreeListView::ItemActionMenuClosed()
  3280     {
  3314     {
  3281     iFlags.Clear( EFlagIgnoreButtonUpEvent );
  3315     iOldWinPos = KErrNotFound;
  3282     EnableHighlight( EFalse );
  3316     EnableHighlight( EFalse );
  3283     DrawDeferred();
  3317     DrawDeferred();
  3284     }
  3318     }
  3285 
  3319 
  3286 // -----------------------------------------------------------------------------
  3320 // -----------------------------------------------------------------------------
  3303 // CAknTreeListView::SetMultipleMarkingState
  3337 // CAknTreeListView::SetMultipleMarkingState
  3304 // -----------------------------------------------------------------------------
  3338 // -----------------------------------------------------------------------------
  3305 //
  3339 //
  3306 void CAknTreeListView::SetMultipleMarkingState( TBool aActive )
  3340 void CAknTreeListView::SetMultipleMarkingState( TBool aActive )
  3307     {
  3341     {
  3308     if ( iMarkingMode != aActive )
  3342     if ( iFlags.IsSet( EFlagMarkingMode ) != aActive )
  3309         {
  3343         {
  3310         if ( !aActive )
  3344         if ( !aActive )
  3311             {
  3345             {
  3312             TBool markedItems( EFalse );
  3346             TBool markedItems( EFalse );
  3313             TRAP_IGNORE( markedItems = HasMarkedItemsL() );
  3347             TRAP_IGNORE( markedItems = HasMarkedItemsL() );
  3316                 UnmarkAll();
  3350                 UnmarkAll();
  3317                 }
  3351                 }
  3318             }
  3352             }
  3319         
  3353         
  3320         EnableMarking( aActive );
  3354         EnableMarking( aActive );
  3321         iMarkingMode = aActive;
  3355         if ( aActive )
       
  3356             {
       
  3357             iFlags.Set( EFlagMarkingMode );
       
  3358             }
       
  3359         else
       
  3360             {
       
  3361             iFlags.Clear( EFlagMarkingMode );
       
  3362             }
       
  3363         if ( aActive )
       
  3364             {
       
  3365             // Expand all items when entering marking mode
       
  3366             iTree.Expand(); 
       
  3367             }
  3322         LayoutView();
  3368         LayoutView();
  3323         DrawDeferred();
  3369         DrawDeferred();
  3324 
  3370 
  3325         if ( iList.MarkingModeObserver() )
  3371         if ( iList.MarkingModeObserver() )
  3326             {
  3372             {
  3336 //
  3382 //
  3337 TUint CAknTreeListView::MarkingState() const
  3383 TUint CAknTreeListView::MarkingState() const
  3338     {
  3384     {
  3339     TUint state( 0 );
  3385     TUint state( 0 );
  3340 
  3386 
  3341     if ( iMarkingMode )
  3387     if ( iFlags.IsSet( EFlagMarkingMode ) )
  3342         {
  3388         {
  3343         state |= MAknMarkingCollection::EStateMarkingMode;
  3389         state |= MAknMarkingCollection::EStateMarkingMode;
  3344 
  3390 
  3345         TBool markedItems ( EFalse );
  3391         TBool markedItems ( EFalse );
  3346         TRAP_IGNORE( markedItems = HasMarkedItemsL() );
  3392         TRAP_IGNORE( markedItems = HasMarkedItemsL() );
  3361 // CAknTreeListView::MarkCurrentItemL
  3407 // CAknTreeListView::MarkCurrentItemL
  3362 // -----------------------------------------------------------------------------
  3408 // -----------------------------------------------------------------------------
  3363 //
  3409 //
  3364 void CAknTreeListView::MarkCurrentItemL()
  3410 void CAknTreeListView::MarkCurrentItemL()
  3365     {
  3411     {
  3366     if ( iMarkingMode && FocusedItem() && FocusedItem()->IsMarkable() )
  3412     if ( iFlags.IsSet( EFlagMarkingMode ) && FocusedItem() && 
       
  3413             FocusedItem()->IsMarkable() )    
  3367         {
  3414         {
  3368         MarkItem( FocusedItem(), ETrue, ETrue );
  3415         MarkItem( FocusedItem(), ETrue, ETrue );
  3369         }
  3416         }
  3370     }
  3417     }
  3371 
  3418 
  3374 // CAknTreeListView::MarkAllL
  3421 // CAknTreeListView::MarkAllL
  3375 // -----------------------------------------------------------------------------
  3422 // -----------------------------------------------------------------------------
  3376 //
  3423 //
  3377 void CAknTreeListView::MarkAllL()
  3424 void CAknTreeListView::MarkAllL()
  3378     {
  3425     {
  3379     if ( iMarkingMode )
  3426     if ( iFlags.IsSet( EFlagMarkingMode ) )
  3380         {
  3427         {
  3381         TAknTreeIterator iterator = iTree.Iterator();
  3428         TAknTreeIterator iterator = iTree.Iterator();
  3382         CAknTreeItem* item = NULL;
  3429         CAknTreeItem* item = NULL;
  3383         item = iterator.First(); 
  3430         item = iterator.First(); 
  3384         while ( item && iterator.HasNext() )
  3431         while ( item && iterator.HasNext() )
  3398 // CAknTreeListView::UnmarkAll
  3445 // CAknTreeListView::UnmarkAll
  3399 // -----------------------------------------------------------------------------
  3446 // -----------------------------------------------------------------------------
  3400 //
  3447 //
  3401 void CAknTreeListView::UnmarkAll()
  3448 void CAknTreeListView::UnmarkAll()
  3402     {
  3449     {
  3403     if ( iMarkingMode )
  3450     if ( iFlags.IsSet( EFlagMarkingMode ) )
  3404         {
  3451         {
  3405         TAknTreeIterator iterator = iTree.Iterator();
  3452         TAknTreeIterator iterator = iTree.Iterator();
  3406         CAknTreeItem* item = NULL;
  3453         CAknTreeItem* item = NULL;
  3407         item = iterator.First(); 
  3454         item = iterator.First(); 
  3408         while ( item && iterator.HasNext() )
  3455         while ( item && iterator.HasNext() )
  3461 //
  3508 //
  3462 void CAknTreeListView::HandleLongTapEventL(
  3509 void CAknTreeListView::HandleLongTapEventL(
  3463         const TPoint& /*aPenEventLocation*/,
  3510         const TPoint& /*aPenEventLocation*/,
  3464         const TPoint& aPenEventScreenLocation)
  3511         const TPoint& aPenEventScreenLocation)
  3465     {
  3512     {
  3466     iFlags.Set( EFlagIgnoreButtonUpEvent );
       
  3467     iItemActionMenu->ShowMenuL( aPenEventScreenLocation, 0 );
  3513     iItemActionMenu->ShowMenuL( aPenEventScreenLocation, 0 );
       
  3514     iOldWinPos = DrawableWindow()->OrdinalPosition();
       
  3515     IgnoreEventsUntilNextPointerUp();
  3468     }
  3516     }
  3469 
  3517 
  3470 // ---------------------------------------------------------------------------
  3518 // ---------------------------------------------------------------------------
  3471 // CAknTreeListView::LongTapPointerEventL
  3519 // CAknTreeListView::LongTapPointerEventL
  3472 // ---------------------------------------------------------------------------
  3520 // ---------------------------------------------------------------------------
  3503     RArray<TInt> selection;
  3551     RArray<TInt> selection;
  3504     CleanupClosePushL( selection );
  3552     CleanupClosePushL( selection );
  3505     iList.GetMarkedItemsL( selection );
  3553     iList.GetMarkedItemsL( selection );
  3506     TInt count( selection.Count() );
  3554     TInt count( selection.Count() );
  3507     CleanupStack::PopAndDestroy( &selection );
  3555     CleanupStack::PopAndDestroy( &selection );
  3508     if ( count > 0 )
  3556     return ( count > 0 );
  3509          {
       
  3510          return ETrue;
       
  3511          }
       
  3512     return EFalse;
       
  3513     }
  3557     }
  3514 
  3558 
  3515 
  3559 
  3516 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3560 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3517 // ---------------------------------------------------------------------------
  3561 // ---------------------------------------------------------------------------
  3584 //
  3628 //
  3585 void CAknTreeListView::LoadMarkingIconsL()
  3629 void CAknTreeListView::LoadMarkingIconsL()
  3586     {
  3630     {
  3587     if ( !iMarkingIconArray )
  3631     if ( !iMarkingIconArray )
  3588         {
  3632         {
  3589         iMarkingIconArray = new ( ELeave ) CAknIconArray( 2 );
  3633         iMarkingIconArray = new ( ELeave ) 
       
  3634             CAknIconArray( KMarkingModeIconArraySize ); 
  3590         }
  3635         }
  3591     else
  3636     else
  3592         {
  3637         {
  3593         iMarkingIconArray->ResetAndDestroy();
  3638         iMarkingIconArray->ResetAndDestroy();
  3594         }
  3639         }