branch | RCL_3 |
changeset 56 | d48ab3b357f1 |
parent 55 | aecbbf00d063 |
child 64 | 85902f042028 |
55:aecbbf00d063 | 56:d48ab3b357f1 |
---|---|
1 /* |
1 /* |
2 * Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006-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". |
24 #include <barsread.h> |
24 #include <barsread.h> |
25 #include <aknappui.h> |
25 #include <aknappui.h> |
26 #include <aknitemactionmenu.h> |
26 #include <aknitemactionmenu.h> |
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> |
|
30 #include <avkon.mbg> |
|
31 #include <gulicon.h> |
|
32 #include <aknmarkingmodeobserver.h> |
|
29 #include "akntreelistview.h" |
33 #include "akntreelistview.h" |
30 #include "akntree.h" |
34 #include "akntree.h" |
31 #include "akntreelist.h" |
35 #include "akntreelist.h" |
32 #include "akntreeiterator.h" |
36 #include "akntreeiterator.h" |
33 #include "akntreelistphysicshandler.h" |
37 #include "akntreelistphysicshandler.h" |
34 |
38 |
35 |
39 #include "akntrace.h" |
36 |
40 |
37 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
41 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
38 |
42 |
39 #include <aknlistboxtfxinternal.h> // LISTBOX EFFECTS IMPLEMENTATION |
43 #include <aknlistboxtfxinternal.h> // LISTBOX EFFECTS IMPLEMENTATION |
40 #include <aknlistloadertfx.h> |
44 #include <aknlistloadertfx.h> |
47 const TInt KLongPressInterval = 600000; // 0.6 seconds |
51 const TInt KLongPressInterval = 600000; // 0.6 seconds |
48 |
52 |
49 // Number of additional items to draw |
53 // Number of additional items to draw |
50 const TInt KAdditionalItems = 2; |
54 const TInt KAdditionalItems = 2; |
51 |
55 |
56 // Number of icons in marking mode icon array |
|
57 const TInt KMarkingModeIconArraySize = 2; |
|
52 |
58 |
53 // Tree list view flag definitions. |
59 // Tree list view flag definitions. |
54 enum TAknTreeListViewFlags |
60 enum TAknTreeListViewFlags |
55 { |
61 { |
56 EFlagStructureLines, |
62 EFlagStructureLines, |
57 EFlagIndention, |
63 EFlagIndention, |
58 EFlagLooping, |
64 EFlagLooping, |
59 EFlagUpdateBackground, |
65 EFlagUpdateBackground, |
60 EFlagMarkingEnabled, // Marking of list items is enabled. |
66 EFlagMarkingEnabled, // Marking of list items is enabled. |
61 EFlagMarkingMode, // List in marking mode (MSK controlled by list). |
67 EFlagMarkingState, // List in marking state (MSK controlled by list). |
62 EFlagMark, // List items are being marked. |
68 EFlagMark, // List items are being marked. |
63 EFlagUnmark, // List items are being unmarked. |
69 EFlagUnmark, // List items are being unmarked. |
64 EFlagSimultaneousMarking, // Simultaneous marking ongoing. |
70 EFlagSimultaneousMarking, // Simultaneous marking ongoing. |
65 EFlagHashKeyPressed, |
71 EFlagHashKeyPressed, |
66 EFlagCtrlKeyPressed, |
72 EFlagCtrlKeyPressed, |
67 EFlagShiftKeyPressed, |
73 EFlagShiftKeyPressed, |
68 EFlagSaveFocusAfterSorting, |
74 EFlagSaveFocusAfterSorting, |
69 EFlagSingleClickEnabled, |
75 EFlagSingleClickEnabled, |
70 EFlagHighlightEnabled, // Is highlight drawing enabled |
76 EFlagHighlightEnabled, // Is highlight drawing enabled |
71 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 |
|
72 }; |
82 }; |
73 |
83 |
74 |
84 |
75 // ======== MEMBER FUNCTIONS ======== |
85 // ======== MEMBER FUNCTIONS ======== |
76 |
86 |
110 { |
120 { |
111 iItemActionMenu->RemoveCollection( *this ); |
121 iItemActionMenu->RemoveCollection( *this ); |
112 } |
122 } |
113 delete iLongTapDetector; |
123 delete iLongTapDetector; |
114 |
124 |
125 if ( iMarkingIconArray ) |
|
126 { |
|
127 iMarkingIconArray->ResetAndDestroy(); |
|
128 } |
|
129 |
|
130 delete iMarkingIconArray; |
|
131 |
|
115 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
132 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
116 if ( CAknListLoader::TfxApiInternal( iGc ) ) |
133 if ( CAknListLoader::TfxApiInternal( iGc ) ) |
117 { |
134 { |
118 delete iGc; |
135 delete iGc; |
119 } |
136 } |
161 |
178 |
162 if ( aDrawNow ) |
179 if ( aDrawNow ) |
163 { |
180 { |
164 Window().Invalidate( Rect() ); |
181 Window().Invalidate( Rect() ); |
165 } |
182 } |
166 UpdateScrollbars(); |
183 |
184 UpdateScrollbars( ETrue ); |
|
167 } |
185 } |
168 |
186 |
169 |
187 |
170 // --------------------------------------------------------------------------- |
188 // --------------------------------------------------------------------------- |
171 // Sets the focused item and its position in the view. |
189 // Sets the focused item and its position in the view. |
211 UpdateAnimation(); |
229 UpdateAnimation(); |
212 |
230 |
213 // Draw always |
231 // Draw always |
214 Window().Invalidate( Rect() ); |
232 Window().Invalidate( Rect() ); |
215 |
233 |
216 UpdateScrollbars(); |
234 UpdateScrollbars( ETrue ); |
217 } |
235 } |
218 |
236 |
219 |
237 |
220 |
238 |
221 // --------------------------------------------------------------------------- |
239 // --------------------------------------------------------------------------- |
420 void CAknTreeListView::SetEmptyTextL(const TDesC& aText) |
438 void CAknTreeListView::SetEmptyTextL(const TDesC& aText) |
421 { |
439 { |
422 delete iEmptyListText; |
440 delete iEmptyListText; |
423 iEmptyListText = NULL; |
441 iEmptyListText = NULL; |
424 iEmptyListText = aText.AllocL(); |
442 iEmptyListText = aText.AllocL(); |
443 UpdateScrollbars( ETrue ); |
|
425 } |
444 } |
426 |
445 |
427 |
446 |
428 // --------------------------------------------------------------------------- |
447 // --------------------------------------------------------------------------- |
429 // InitPhysicsL |
448 // InitPhysicsL |
466 // SelectItem |
485 // SelectItem |
467 // --------------------------------------------------------------------------- |
486 // --------------------------------------------------------------------------- |
468 // |
487 // |
469 void CAknTreeListView::SelectItem( CAknTreeItem* aSelectedItem ) |
488 void CAknTreeListView::SelectItem( CAknTreeItem* aSelectedItem ) |
470 { |
489 { |
471 SelectItem( aSelectedItem, EFalse ); |
490 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
491 { |
|
492 if ( aSelectedItem->IsMarkable() ) |
|
493 { |
|
494 MarkItem( aSelectedItem, !aSelectedItem->IsMarked(), ETrue ); |
|
495 } |
|
496 else if ( aSelectedItem->IsNode() ) |
|
497 { |
|
498 SelectItem( aSelectedItem, EFalse ); |
|
499 } |
|
500 } |
|
501 else |
|
502 { |
|
503 SelectItem( aSelectedItem, EFalse ); |
|
504 } |
|
472 } |
505 } |
473 |
506 |
474 |
507 |
475 // --------------------------------------------------------------------------- |
508 // --------------------------------------------------------------------------- |
476 // VisibleItemCount |
509 // VisibleItemCount |
488 // SetPressedDownState |
521 // SetPressedDownState |
489 // --------------------------------------------------------------------------- |
522 // --------------------------------------------------------------------------- |
490 // |
523 // |
491 void CAknTreeListView::SetPressedDownState( const TBool& aPressedDown ) |
524 void CAknTreeListView::SetPressedDownState( const TBool& aPressedDown ) |
492 { |
525 { |
493 iIsPressedDownState = aPressedDown; |
526 if ( aPressedDown ) |
527 { |
|
528 iFlags.Set( EFlagIsPressedDownState ); |
|
529 } |
|
530 else |
|
531 { |
|
532 iFlags.Clear( EFlagIsPressedDownState ); |
|
533 } |
|
494 } |
534 } |
495 |
535 |
496 |
536 |
497 // --------------------------------------------------------------------------- |
537 // --------------------------------------------------------------------------- |
498 // UpdateTreeListView |
538 // UpdateTreeListView |
501 void CAknTreeListView::UpdateTreeListView( const TInt& aFirstItem, |
541 void CAknTreeListView::UpdateTreeListView( const TInt& aFirstItem, |
502 const TBool& aDrawNow ) |
542 const TBool& aDrawNow ) |
503 { |
543 { |
504 CAknTreeItem* first = iTree.VisibleItem( aFirstItem ); |
544 CAknTreeItem* first = iTree.VisibleItem( aFirstItem ); |
505 UpdateVisibleItems( 0, first ); |
545 UpdateVisibleItems( 0, first ); |
506 UpdateScrollbars(); |
546 UpdateScrollbars( ETrue ); |
507 UpdateAnimation(); |
547 UpdateAnimation(); |
508 |
548 |
509 if ( aDrawNow ) |
549 if ( aDrawNow ) |
510 { |
550 { |
511 DrawNow(); |
551 DrawNow(); |
739 // --------------------------------------------------------------------------- |
779 // --------------------------------------------------------------------------- |
740 // |
780 // |
741 void CAknTreeListView::MakeVisible( TBool aVisible ) |
781 void CAknTreeListView::MakeVisible( TBool aVisible ) |
742 { |
782 { |
743 CAknControl::MakeVisible( aVisible ); |
783 CAknControl::MakeVisible( aVisible ); |
744 |
784 UpdateScrollbars( aVisible ); |
745 if ( aVisible ) |
|
746 { |
|
747 UpdateScrollbars(); |
|
748 } |
|
749 } |
785 } |
750 |
786 |
751 |
787 |
752 // --------------------------------------------------------------------------- |
788 // --------------------------------------------------------------------------- |
753 // From class CCoeControl. |
789 // From class CCoeControl. |
768 |
804 |
769 Window().SetPointerGrab( ETrue ); |
805 Window().SetPointerGrab( ETrue ); |
770 |
806 |
771 iScrollbarFrame = new ( ELeave ) CEikScrollBarFrame( this, this ); |
807 iScrollbarFrame = new ( ELeave ) CEikScrollBarFrame( this, this ); |
772 iScrollbarFrame->CreateDoubleSpanScrollBarsL( EFalse, EFalse ); |
808 iScrollbarFrame->CreateDoubleSpanScrollBarsL( EFalse, EFalse ); |
809 if ( CAknEnv::Static()->TransparencyEnabled() && iPhysicsHandler ) |
|
810 { |
|
811 // disable background drawing of scrollbar |
|
812 iScrollbarFrame->DrawBackground( EFalse, EFalse ); |
|
813 } |
|
773 } |
814 } |
774 |
815 |
775 |
816 |
776 // --------------------------------------------------------------------------- |
817 // --------------------------------------------------------------------------- |
777 // From class CCoeControl. |
818 // From class CCoeControl. |
779 // --------------------------------------------------------------------------- |
820 // --------------------------------------------------------------------------- |
780 // |
821 // |
781 void CAknTreeListView::HandleResourceChange( TInt aType ) |
822 void CAknTreeListView::HandleResourceChange( TInt aType ) |
782 { |
823 { |
783 CAknControl::HandleResourceChange( aType ); |
824 CAknControl::HandleResourceChange( aType ); |
784 if ( aType == KAknsMessageSkinChange ) |
825 |
785 { |
826 switch ( aType ) |
786 TRAPD( error, CreateAnimationL() ) |
827 { |
787 if ( error ) |
828 case KEikMessageWindowsFadeChange: |
788 { |
829 { |
789 delete iAnimation; |
830 ReportCollectionChangedEvent(); |
790 iAnimation = NULL; |
831 } |
791 } |
832 |
792 } |
833 case KAknsMessageSkinChange: |
793 else if ( aType == KEikDynamicLayoutVariantSwitch && FocusedItem() ) |
834 { |
794 { |
835 TRAPD( error, CreateAnimationL() ) |
795 if ( !FocusedItemVisible() ) |
836 if ( error ) |
796 { |
837 { |
797 TInt firstItemIndex = 0; |
838 delete iAnimation; |
798 if ( iItems.Count() && iItems[0].Item() ) |
839 iAnimation = NULL; |
799 { |
840 } |
800 firstItemIndex = iTree.VisibleItemIndex( iItems[0].Item() ); |
841 |
801 } |
842 TRAP_IGNORE( LoadMarkingIconsL() ); |
802 |
843 break; |
803 TInt index = 0; |
844 } |
804 if ( firstItemIndex < iTree.VisibleItemIndex( FocusedItem() ) ) |
845 |
805 { |
846 case KEikDynamicLayoutVariantSwitch: |
806 index = iItems.Count() - 1; |
847 { |
807 } |
848 if ( AknLayoutUtils::LayoutMirrored() ) |
808 |
849 { |
809 SetFocusedItem( FocusedItem(), index, ETrue ); |
850 iFlags.Set( EFlagMirroredLayoutInUse ); |
810 } |
851 } |
811 else |
852 else |
812 { |
853 { |
813 SetFocusedItem( FocusedItem(), FocusIndex(), ETrue ); |
854 iFlags.Clear( EFlagMirroredLayoutInUse ); |
855 } |
|
856 |
|
857 CAknTreeItem* focusedItem( FocusedItem() ); |
|
858 if ( focusedItem ) |
|
859 { |
|
860 if ( !FocusedItemVisible() ) |
|
861 { |
|
862 TInt firstItemIndex = 0; |
|
863 if ( iItems.Count() && iItems[0].Item() ) |
|
864 { |
|
865 firstItemIndex = |
|
866 iTree.VisibleItemIndex( iItems[0].Item() ); |
|
867 } |
|
868 |
|
869 TInt index = 0; |
|
870 if ( firstItemIndex < iTree.VisibleItemIndex( focusedItem ) ) |
|
871 { |
|
872 index = iItems.Count() - 1; |
|
873 } |
|
874 |
|
875 if( HighlightEnabled() ) |
|
876 { |
|
877 SetFocusedItem( focusedItem, index, ETrue ); |
|
878 } |
|
879 else |
|
880 { |
|
881 // This block moves visible view after layout switch |
|
882 // if there are not enough items to fill whole screen |
|
883 TInt visibleItemIndex = iTree.VisibleItemIndex( focusedItem ); |
|
884 if ( visibleItemIndex != KErrNotFound ) |
|
885 { |
|
886 TInt visibleItemCount( iTree.VisibleItemCount() ); |
|
887 TInt itemCountLimit = iItems.Count(); |
|
888 if ( visibleItemCount <= itemCountLimit - KAdditionalItems ) |
|
889 { |
|
890 UpdateVisibleItems( visibleItemIndex, focusedItem ); |
|
891 } |
|
892 } |
|
893 } |
|
894 |
|
895 } |
|
896 else |
|
897 { |
|
898 SetFocusedItem( focusedItem, FocusIndex(), ETrue ); |
|
899 |
|
900 // This block moves visible view after layout switch |
|
901 // if there are not enough items to fill whole screen |
|
902 TInt visibleItemIndex = |
|
903 iTree.VisibleItemIndex( focusedItem ); |
|
904 if ( visibleItemIndex != KErrNotFound ) |
|
905 { |
|
906 TInt focusedItemIndex = FocusedItemIndex(); |
|
907 if ( focusedItemIndex != -1 ) |
|
908 { |
|
909 TInt visibleItemCount( iTree.VisibleItemCount() ); |
|
910 |
|
911 TInt height = |
|
912 visibleItemCount - visibleItemIndex + focusedItemIndex; |
|
913 TInt itemCountLimit = iItems.Count(); |
|
914 |
|
915 if ( height < itemCountLimit && |
|
916 height < visibleItemCount ) |
|
917 { |
|
918 TInt move = itemCountLimit - height; |
|
919 UpdateVisibleItems( focusedItemIndex + move, focusedItem ); |
|
920 } |
|
921 } |
|
922 } |
|
923 // end of block |
|
924 } |
|
925 } |
|
926 break; |
|
927 } |
|
814 |
928 |
929 case KAknMessageFocusLost: |
|
930 { |
|
931 if ( SingleClickEnabled() && HighlightEnabled() && |
|
932 ( iOldWinPos == KErrNotFound || |
|
933 iOldWinPos == DrawableWindow()->OrdinalPosition() ) ) |
|
934 { |
|
935 EnableHighlight( EFalse ); |
|
936 // Redraw item |
|
937 SetFocusedItem( FocusedItem(), FocusIndex(), ETrue ); |
|
938 } |
|
939 break; |
|
940 } |
|
815 |
941 |
816 // This block moves visible view after layout switch |
942 default: |
817 // if there are not enough items to fill whole screen |
943 { |
818 TInt visibleItemIndex = iTree.VisibleItemIndex( FocusedItem() ); |
944 break; |
819 if ( visibleItemIndex != KErrNotFound) |
945 } |
820 { |
|
821 TInt focusedItemIndex = FocusedItemIndex(); |
|
822 if (focusedItemIndex != -1) |
|
823 { |
|
824 TInt height = iTree.VisibleItemCount() - visibleItemIndex + focusedItemIndex; |
|
825 TInt itemCountLimit = iItems.Count(); |
|
826 |
|
827 if ( height < itemCountLimit && height < iTree.VisibleItemCount() ) |
|
828 { |
|
829 TInt move = itemCountLimit - height; |
|
830 UpdateVisibleItems( focusedItemIndex + move, FocusedItem() ); |
|
831 } |
|
832 } |
|
833 } |
|
834 // end of block |
|
835 } |
|
836 } |
|
837 else if ( aType == KAknMessageFocusLost && HighlightEnabled() ) |
|
838 { |
|
839 EnableHighlight( EFalse ); |
|
840 } |
946 } |
841 } |
947 } |
842 |
948 |
843 |
949 |
844 // --------------------------------------------------------------------------- |
950 // --------------------------------------------------------------------------- |
849 // focused. |
955 // focused. |
850 // --------------------------------------------------------------------------- |
956 // --------------------------------------------------------------------------- |
851 // |
957 // |
852 void CAknTreeListView::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
958 void CAknTreeListView::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
853 { |
959 { |
854 if ( iFlags.IsSet( EFlagIgnoreButtonUpEvent ) |
960 if ( GrabbingComponent() ) |
855 && aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
856 { |
|
857 return; |
|
858 } |
|
859 |
|
860 if ( GrabbingComponent() != NULL ) |
|
861 { |
961 { |
862 iPhysicsHandler->ResetEventBlockingStatus(); |
962 iPhysicsHandler->ResetEventBlockingStatus(); |
863 } |
963 } |
864 else |
964 else |
865 { |
965 { |
910 { |
1010 { |
911 EnableHighlight( EFalse ); |
1011 EnableHighlight( EFalse ); |
912 } |
1012 } |
913 |
1013 |
914 TInt thumbPosition = aScrollBar->ThumbPosition(); |
1014 TInt thumbPosition = aScrollBar->ThumbPosition(); |
915 if ( AknLayoutUtils::LayoutMirrored() && |
1015 if ( iFlags.IsSet( EFlagMirroredLayoutInUse ) && |
916 aScrollBar != iScrollbarFrame->VerticalScrollBar() ) |
1016 aScrollBar != iScrollbarFrame->VerticalScrollBar() ) |
917 { |
1017 { |
918 const TEikScrollBarModel* model = aScrollBar->Model(); |
1018 const TEikScrollBarModel* model = aScrollBar->Model(); |
919 thumbPosition = ( model->iScrollSpan - model->iThumbSpan ) |
1019 thumbPosition = ( model->iScrollSpan - model->iThumbSpan ) |
920 - thumbPosition; |
1020 - thumbPosition; |
929 case EEikScrollLeft: |
1029 case EEikScrollLeft: |
930 case EEikScrollRight: |
1030 case EEikScrollRight: |
931 case EEikScrollPageLeft: |
1031 case EEikScrollPageLeft: |
932 case EEikScrollPageRight: |
1032 case EEikScrollPageRight: |
933 iViewLevel = thumbPosition; |
1033 iViewLevel = thumbPosition; |
934 UpdateScrollbars(); |
1034 UpdateScrollbars( ETrue ); |
935 UpdateAnimation(); |
1035 UpdateAnimation(); |
936 Window().Invalidate( Rect() ); |
1036 Window().Invalidate( Rect() ); |
937 break; |
1037 break; |
938 |
1038 |
939 case EEikScrollThumbDragHoriz: |
1039 case EEikScrollThumbDragHoriz: |
941 UpdateAnimation(); |
1041 UpdateAnimation(); |
942 Window().Invalidate( Rect() ); |
1042 Window().Invalidate( Rect() ); |
943 break; |
1043 break; |
944 |
1044 |
945 case EEikScrollThumbReleaseHoriz: |
1045 case EEikScrollThumbReleaseHoriz: |
946 UpdateScrollbars(); |
1046 UpdateScrollbars( ETrue ); |
947 break; |
1047 break; |
948 |
1048 |
949 case EEikScrollHome: |
1049 case EEikScrollHome: |
950 // Not in use! |
1050 // Not in use |
951 break; |
1051 break; |
952 |
1052 |
953 case EEikScrollEnd: |
1053 case EEikScrollEnd: |
954 // Not in use! |
1054 // Not in use |
955 break; |
1055 break; |
956 |
1056 |
957 default: |
1057 default: |
958 break; |
1058 break; |
959 } |
1059 } |
1048 break; |
1148 break; |
1049 } |
1149 } |
1050 |
1150 |
1051 if ( aDrawNow ) |
1151 if ( aDrawNow ) |
1052 { |
1152 { |
1053 Window().Invalidate( Rect() ); |
1153 // DrawNow must be used here. |
1154 DrawNow(); |
|
1054 } |
1155 } |
1055 } |
1156 } |
1056 |
1157 |
1057 |
1158 |
1058 // --------------------------------------------------------------------------- |
1159 // --------------------------------------------------------------------------- |
1132 { |
1233 { |
1133 Window().Invalidate( Rect() ); |
1234 Window().Invalidate( Rect() ); |
1134 } |
1235 } |
1135 else if ( IsFocused() && FocusedItemVisible() ) |
1236 else if ( IsFocused() && FocusedItemVisible() ) |
1136 { |
1237 { |
1137 TRect rect = iItems[FocusIndex()].HighlightRect( iViewLevel, Indention(), IndentionWidth() ); |
1238 TRect rect = iItems[FocusIndex()].HighlightRect( iViewLevel, |
1239 Indention(), |
|
1240 IndentionWidth() ); |
|
1138 Window().Invalidate( rect ); |
1241 Window().Invalidate( rect ); |
1139 } |
1242 } |
1140 |
1243 |
1141 ReportTreeListEvent( MAknTreeListObserver::EItemFocused, |
1244 ReportTreeListEvent( MAknTreeListObserver::EItemFocused, |
1142 iTree.Id( FocusedItem() ) ); |
1245 iTree.Id( FocusedItem() ) ); |
1152 { |
1255 { |
1153 // Get layout for the view. |
1256 // Get layout for the view. |
1154 LayoutView(); |
1257 LayoutView(); |
1155 |
1258 |
1156 // Update scrollbars. |
1259 // Update scrollbars. |
1157 UpdateScrollbars(); |
1260 UpdateScrollbars( ETrue ); |
1158 |
1261 |
1159 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
1160 UpdateIndexes(); |
1262 UpdateIndexes(); |
1161 #endif |
|
1162 AknsUtils::RegisterControlPosition( this, PositionRelativeToScreen() ); |
1263 AknsUtils::RegisterControlPosition( this, PositionRelativeToScreen() ); |
1163 |
1264 |
1164 TRAP_IGNORE( InitPhysicsL() ); |
1265 TRAP_IGNORE( InitPhysicsL() ); |
1165 } |
1266 } |
1166 |
1267 |
1198 iViewLevel( 0 ), |
1299 iViewLevel( 0 ), |
1199 iMaxViewLevel( 0 ), |
1300 iMaxViewLevel( 0 ), |
1200 iStylusDownItemIndex( -1 ), |
1301 iStylusDownItemIndex( -1 ), |
1201 iAnimationIID( KAknsIIDQsnAnimList ), |
1302 iAnimationIID( KAknsIIDQsnAnimList ), |
1202 iIndentionWidth( -1 ), |
1303 iIndentionWidth( -1 ), |
1203 iPhysicsHandler( NULL ), |
1304 iPhysicsHandler( NULL ) |
1204 iScrollPhysicsTop( ETrue ) |
|
1205 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1305 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1206 ,iGc(NULL) |
1306 ,iGc(NULL) |
1207 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
1307 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
1208 ,iItemActionMenu( NULL ), |
1308 ,iItemActionMenu( NULL ), |
1209 iLongTapDetector( NULL ) |
1309 iLongTapDetector( NULL ), |
1310 iOldWinPos( KErrNotFound ) |
|
1210 { |
1311 { |
1211 if ( static_cast<CAknAppUi*>( |
1312 if ( static_cast<CAknAppUi*>( |
1212 iCoeEnv->AppUi() )->IsSingleClickCompatible() ) |
1313 iCoeEnv->AppUi() )->IsSingleClickCompatible() ) |
1213 { |
1314 { |
1214 iFlags.Set( EFlagSingleClickEnabled ); |
1315 iFlags.Set( EFlagSingleClickEnabled ); |
1215 } |
1316 } |
1216 |
1317 |
1217 iFlags.Set( EFlagStructureLines ); |
1318 iFlags.Set( EFlagStructureLines ); |
1218 iFlags.Set( EFlagIndention ); |
1319 iFlags.Set( EFlagIndention ); |
1320 iFlags.Set( EFlagScrollPhysicsTop ); |
|
1219 } |
1321 } |
1220 |
1322 |
1221 |
1323 |
1222 // --------------------------------------------------------------------------- |
1324 // --------------------------------------------------------------------------- |
1223 // Second phase constructor. |
1325 // Second phase constructor. |
1251 iPhysicsHandler = CAknTreeListPhysicsHandler::NewL( this, |
1353 iPhysicsHandler = CAknTreeListPhysicsHandler::NewL( this, |
1252 &iTree, |
1354 &iTree, |
1253 &iItems ); |
1355 &iItems ); |
1254 } |
1356 } |
1255 |
1357 |
1256 iIsPressedDownState = EFalse; |
1358 iFlags.Clear( EFlagIsPressedDownState ); |
1257 iIsDragged = EFalse; |
1359 iFlags.Clear( EFlagIsDragged ); |
1258 iItemActionMenu = CAknItemActionMenu::RegisterCollectionL( *this ); |
1360 iItemActionMenu = CAknItemActionMenu::RegisterCollectionL( *this, this ); |
1361 |
|
1259 if ( iItemActionMenu ) |
1362 if ( iItemActionMenu ) |
1260 { |
1363 { |
1261 iLongTapDetector = CAknLongTapDetector::NewL( this ); |
1364 iLongTapDetector = CAknLongTapDetector::NewL( this ); |
1262 } |
1365 } |
1263 |
1366 |
1267 } |
1370 } |
1268 else |
1371 else |
1269 { |
1372 { |
1270 EnableHighlight( ETrue ); |
1373 EnableHighlight( ETrue ); |
1271 } |
1374 } |
1375 if ( AknLayoutUtils::LayoutMirrored() ) |
|
1376 { |
|
1377 iFlags.Set( EFlagMirroredLayoutInUse ); |
|
1378 } |
|
1379 else |
|
1380 { |
|
1381 iFlags.Clear( EFlagMirroredLayoutInUse ); |
|
1382 } |
|
1383 LoadMarkingIconsL(); |
|
1272 } |
1384 } |
1273 |
1385 |
1274 |
1386 |
1275 // --------------------------------------------------------------------------- |
1387 // --------------------------------------------------------------------------- |
1276 // Handles an addition of new item into tree list. The focused item is kept |
1388 // Handles an addition of new item into tree list. The focused item is kept |
1279 // --------------------------------------------------------------------------- |
1391 // --------------------------------------------------------------------------- |
1280 // |
1392 // |
1281 void CAknTreeListView::HandleItemAddedEvent( CAknTreeItem* /*aItem*/, TBool aDrawNow ) |
1393 void CAknTreeListView::HandleItemAddedEvent( CAknTreeItem* /*aItem*/, TBool aDrawNow ) |
1282 { |
1394 { |
1283 UpdateVisibleItems(); |
1395 UpdateVisibleItems(); |
1284 if (aDrawNow) |
1396 UpdateScrollbars( aDrawNow ); |
1285 { |
|
1286 UpdateScrollbars(); |
|
1287 } |
|
1288 } |
1397 } |
1289 |
1398 |
1290 |
1399 |
1291 // --------------------------------------------------------------------------- |
1400 // --------------------------------------------------------------------------- |
1292 // Handles the movement of a tree item. Movement of focused item has to be |
1401 // Handles the movement of a tree item. Movement of focused item has to be |
1297 { |
1406 { |
1298 // Note: This method cannot deduce, which items in the view have actually |
1407 // Note: This method cannot deduce, which items in the view have actually |
1299 // been changed, unless the it receives information from where the |
1408 // been changed, unless the it receives information from where the |
1300 // specified item was moved. |
1409 // specified item was moved. |
1301 UpdateVisibleItems(); |
1410 UpdateVisibleItems(); |
1302 UpdateScrollbars(); |
1411 UpdateScrollbars( ETrue ); |
1303 } |
1412 } |
1304 |
1413 |
1305 |
1414 |
1306 // --------------------------------------------------------------------------- |
1415 // --------------------------------------------------------------------------- |
1307 // Prepares view for the item removal by moving the focus from the removed |
1416 // Prepares view for the item removal by moving the focus from the removed |
1352 // --------------------------------------------------------------------------- |
1461 // --------------------------------------------------------------------------- |
1353 // |
1462 // |
1354 void CAknTreeListView::HandleItemRemovedEvent( CAknTreeItem* /*aItem*/, TBool aDrawNow ) |
1463 void CAknTreeListView::HandleItemRemovedEvent( CAknTreeItem* /*aItem*/, TBool aDrawNow ) |
1355 { |
1464 { |
1356 UpdateVisibleItems(); |
1465 UpdateVisibleItems(); |
1357 if (aDrawNow) |
1466 UpdateScrollbars( aDrawNow ); |
1358 { |
|
1359 UpdateScrollbars(); |
|
1360 } |
|
1361 } |
1467 } |
1362 |
1468 |
1363 |
1469 |
1364 // --------------------------------------------------------------------------- |
1470 // --------------------------------------------------------------------------- |
1365 // Handles an expansion of a tree node. If the expanded node is focused, it is |
1471 // Handles an expansion of a tree node. If the expanded node is focused, it is |
1378 } |
1484 } |
1379 else |
1485 else |
1380 { |
1486 { |
1381 UpdateVisibleItems(); |
1487 UpdateVisibleItems(); |
1382 } |
1488 } |
1383 UpdateScrollbars(); |
1489 |
1490 UpdateScrollbars( ETrue ); |
|
1384 } |
1491 } |
1385 |
1492 |
1386 |
1493 |
1387 // --------------------------------------------------------------------------- |
1494 // --------------------------------------------------------------------------- |
1388 // Handles a collapse of a tree node. If one of the items in collapsed node |
1495 // Handles a collapse of a tree node. If one of the items in collapsed node |
1418 // visible |
1525 // visible |
1419 UpdateViewItemAsVisible( aNode ); |
1526 UpdateViewItemAsVisible( aNode ); |
1420 } |
1527 } |
1421 |
1528 |
1422 UpdateVisibleItems(); |
1529 UpdateVisibleItems(); |
1423 UpdateScrollbars(); |
1530 UpdateScrollbars( ETrue ); |
1424 } |
1531 } |
1425 |
1532 |
1426 |
1533 |
1427 // --------------------------------------------------------------------------- |
1534 // --------------------------------------------------------------------------- |
1428 // Handles a change in tree item. |
1535 // Handles a change in tree item. |
1470 { |
1577 { |
1471 iItems[ii].SetItem( iterator.Next() ); |
1578 iItems[ii].SetItem( iterator.Next() ); |
1472 } |
1579 } |
1473 } |
1580 } |
1474 } |
1581 } |
1475 if ( aDrawNow ) |
1582 |
1476 { |
1583 UpdateScrollbars( aDrawNow ); |
1477 UpdateScrollbars(); |
|
1478 } |
|
1479 } |
1584 } |
1480 |
1585 |
1481 |
1586 |
1482 // --------------------------------------------------------------------------- |
1587 // --------------------------------------------------------------------------- |
1483 // Updates the view items so that the specified item is located at the |
1588 // Updates the view items so that the specified item is located at the |
1488 void CAknTreeListView::UpdateVisibleItems( TInt aIndex, CAknTreeItem* aItem ) |
1593 void CAknTreeListView::UpdateVisibleItems( TInt aIndex, CAknTreeItem* aItem ) |
1489 { |
1594 { |
1490 SetFocusIndex( KMinTInt ); |
1595 SetFocusIndex( KMinTInt ); |
1491 if ( !iItems.Count() ) |
1596 if ( !iItems.Count() ) |
1492 { |
1597 { |
1493 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
1494 UpdateIndexes(); |
1598 UpdateIndexes(); |
1495 #endif |
|
1496 return; |
1599 return; |
1497 } |
1600 } |
1498 |
1601 |
1499 TInt index = Min( aIndex, iTree.VisibleItemIndex( aItem ) ); |
1602 TInt index = Min( aIndex, iTree.VisibleItemIndex( aItem ) ); |
1500 |
1603 |
1528 if ( iItems[ii].Item() == FocusedItem() ) |
1631 if ( iItems[ii].Item() == FocusedItem() ) |
1529 { |
1632 { |
1530 SetFocusIndex( ii ); |
1633 SetFocusIndex( ii ); |
1531 } |
1634 } |
1532 } |
1635 } |
1533 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
1534 UpdateIndexes(); |
1636 UpdateIndexes(); |
1535 #endif |
|
1536 } |
1637 } |
1537 |
1638 |
1538 |
1639 |
1539 // --------------------------------------------------------------------------- |
1640 // --------------------------------------------------------------------------- |
1540 // Updates the view items so that the focused item remains in the same |
1641 // Updates the view items so that the focused item remains in the same |
1576 SetFocusIndex( ii ); |
1677 SetFocusIndex( ii ); |
1577 } |
1678 } |
1578 item = iterator.Next(); |
1679 item = iterator.Next(); |
1579 } |
1680 } |
1580 } |
1681 } |
1581 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
1582 UpdateIndexes(); |
1682 UpdateIndexes(); |
1583 #endif |
|
1584 } |
1683 } |
1585 else if ( itemCount && iItems.Count() ) |
1684 else if ( itemCount && iItems.Count() ) |
1586 { |
1685 { |
1587 if ( FocusedItemVisible() ) |
1686 if ( FocusedItemVisible() ) |
1588 { |
1687 { |
1611 void CAknTreeListView::HandleSelectionKeyEvent() |
1710 void CAknTreeListView::HandleSelectionKeyEvent() |
1612 { |
1711 { |
1613 CAknTreeItem* item = FocusedItem(); |
1712 CAknTreeItem* item = FocusedItem(); |
1614 if ( item ) |
1713 if ( item ) |
1615 { |
1714 { |
1616 if ( MarkingOngoing() ) |
1715 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
1617 { |
1716 { |
1618 MarkItem( item, !item->IsMarked(), ETrue ); |
1717 if ( item->IsMarkable() ) |
1718 { |
|
1719 MarkItem( item, !item->IsMarked(), ETrue ); |
|
1720 } |
|
1619 } |
1721 } |
1620 else |
1722 else |
1621 { |
1723 { |
1622 SelectItem( item, true ); |
1724 SelectItem( item, EFalse ); |
1623 } |
1725 } |
1624 } |
1726 } |
1625 } |
1727 } |
1626 |
1728 |
1627 |
1729 |
1629 // Handles right arrow key event. |
1731 // Handles right arrow key event. |
1630 // --------------------------------------------------------------------------- |
1732 // --------------------------------------------------------------------------- |
1631 // |
1733 // |
1632 void CAknTreeListView::HandleRightArrowKeyEvent() |
1734 void CAknTreeListView::HandleRightArrowKeyEvent() |
1633 { |
1735 { |
1634 if ( AknLayoutUtils::LayoutMirrored() ) |
1736 if ( iFlags.IsSet( EFlagMirroredLayoutInUse ) ) |
1635 { |
1737 { |
1636 AscendFocus(); |
1738 AscendFocus(); |
1637 } |
1739 } |
1638 else |
1740 else |
1639 { |
1741 { |
1646 // Handles left arrow key event. |
1748 // Handles left arrow key event. |
1647 // --------------------------------------------------------------------------- |
1749 // --------------------------------------------------------------------------- |
1648 // |
1750 // |
1649 void CAknTreeListView::HandleLeftArrowKeyEvent() |
1751 void CAknTreeListView::HandleLeftArrowKeyEvent() |
1650 { |
1752 { |
1651 if ( AknLayoutUtils::LayoutMirrored() ) |
1753 if ( iFlags.IsSet( EFlagMirroredLayoutInUse ) ) |
1652 { |
1754 { |
1653 DescendFocus(); |
1755 DescendFocus(); |
1654 } |
1756 } |
1655 else |
1757 else |
1656 { |
1758 { |
1947 for ( TInt ii = iItems.Count(); ii < itemCountLimit; ++ii ) |
2049 for ( TInt ii = iItems.Count(); ii < itemCountLimit; ++ii ) |
1948 { |
2050 { |
1949 // This should not fail, if enough space was reserved for the |
2051 // This should not fail, if enough space was reserved for the |
1950 // array, and if it fails, it results only fewer items being |
2052 // array, and if it fails, it results only fewer items being |
1951 // shown in the list. |
2053 // shown in the list. |
1952 iItems.Append( TAknTreeListViewItem() ); |
2054 if ( KErrNone != iItems.Append( TAknTreeListViewItem() ) ) |
2055 { |
|
2056 return; |
|
2057 } |
|
1953 } |
2058 } |
1954 } |
2059 } |
1955 |
2060 |
1956 // Get iterator and set it to point at the first item in the view, or at |
2061 // Get iterator and set it to point at the first item in the view, or at |
1957 // the first item in the list, if the view does not contain any items. |
2062 // the first item in the list, if the view does not contain any items. |
1960 if ( first ) |
2065 if ( first ) |
1961 { |
2066 { |
1962 iterator.SetCurrent( first ); |
2067 iterator.SetCurrent( first ); |
1963 iterator.Previous(); |
2068 iterator.Previous(); |
1964 } |
2069 } |
2070 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
|
2071 { |
|
2072 if ( iFlags.IsSet( EFlagMirroredLayoutInUse )) |
|
2073 { |
|
2074 itemRect.iBr.iX -= |
|
2075 AknLayoutScalable_Avkon::list_double_graphic_pane_t1( |
|
2076 0 ).LayoutLine().ir; |
|
2077 } |
|
2078 else |
|
2079 { |
|
2080 itemRect.iBr.iX -= |
|
2081 AknLayoutScalable_Avkon::list_double_graphic_pane_t1( |
|
2082 0 ).LayoutLine().il; |
|
2083 } |
|
2084 } |
|
1965 |
2085 |
1966 // Update items and their rectangles. |
2086 // Update items and their rectangles. |
1967 for ( TInt ii = 0; ii < iItems.Count(); ++ii ) |
2087 for ( TInt ii = 0; ii < iItems.Count(); ++ii ) |
1968 { |
2088 { |
1969 CAknTreeItem* item = iterator.Next(); |
2089 CAknTreeItem* item = iterator.Next(); |
1984 TRect viewRect( listRect ); |
2104 TRect viewRect( listRect ); |
1985 |
2105 |
1986 // Fill whole control area with list items when physics enabled |
2106 // Fill whole control area with list items when physics enabled |
1987 // and threre is no horizontal scrollbar. |
2107 // and threre is no horizontal scrollbar. |
1988 if ( iScrollbarFrame && |
2108 if ( iScrollbarFrame && |
1989 iScrollbarFrame->ScrollBarVisibility( CEikScrollBar::EHorizontal ) != CEikScrollBarFrame::EOn && |
2109 iScrollbarFrame->ScrollBarVisibility( |
2110 CEikScrollBar::EHorizontal ) != CEikScrollBarFrame::EOn && |
|
1990 viewRect.Height() < Rect().Height() ) |
2111 viewRect.Height() < Rect().Height() ) |
1991 { |
2112 { |
1992 viewRect.iTl.iY = Rect().iTl.iY; |
2113 viewRect.iTl.iY = Rect().iTl.iY; |
1993 viewRect.iBr.iY = Rect().iBr.iY; |
2114 viewRect.iBr.iY = Rect().iBr.iY; |
1994 } |
2115 } |
2002 // Updates the span, thumb size and position for both of the scrollbars. New |
2123 // Updates the span, thumb size and position for both of the scrollbars. New |
2003 // layout for the view is applied, if the visibility of either of the |
2124 // layout for the view is applied, if the visibility of either of the |
2004 // scrollbars changes. |
2125 // scrollbars changes. |
2005 // --------------------------------------------------------------------------- |
2126 // --------------------------------------------------------------------------- |
2006 // |
2127 // |
2007 void CAknTreeListView::UpdateScrollbars() |
2128 void CAknTreeListView::UpdateScrollbars( TBool aDrawNow ) |
2008 { |
2129 { |
2009 if ( iScrollbarFrame ) |
2130 if ( iScrollbarFrame ) |
2010 { |
2131 { |
2011 iPhysicsHandler->UpdateScrollIndex( iScrollPhysicsTop ); |
2132 TBool drawHorizontal; |
2012 iScrollPhysicsTop = ETrue; |
2133 TBool drawVertical; |
2134 if ( !aDrawNow ) |
|
2135 { |
|
2136 // Backup the old values. |
|
2137 iScrollbarFrame->DrawBackgroundState( drawHorizontal, |
|
2138 drawVertical ); |
|
2139 |
|
2140 // Disable the scrollbar background drawing for the duration |
|
2141 // of this call. |
|
2142 iScrollbarFrame->DrawBackground( EFalse, EFalse ); |
|
2143 } |
|
2144 |
|
2145 iPhysicsHandler->UpdateScrollIndex( |
|
2146 iFlags.IsSet( EFlagScrollPhysicsTop ) ); |
|
2147 iFlags.Set( EFlagScrollPhysicsTop ); |
|
2148 |
|
2013 |
2149 |
2014 // Get values for horizontal scrollbar. |
2150 // Get values for horizontal scrollbar. |
2015 TInt hThumbPos = iViewLevel; |
2151 TInt hThumbPos = iViewLevel; |
2016 TInt hThumbSpan = iHorizontalViewSpan; |
2152 TInt hThumbSpan = iHorizontalViewSpan; |
2017 TInt hScrollSpan = Max( hThumbPos + hThumbSpan, iMaxViewLevel ); |
2153 TInt hScrollSpan = Max( hThumbPos + hThumbSpan, iMaxViewLevel ); |
2023 TInt c = iItems[0].ItemRect( iViewLevel, Indention(), |
2159 TInt c = iItems[0].ItemRect( iViewLevel, Indention(), |
2024 IndentionWidth() ).Width(); |
2160 IndentionWidth() ).Width(); |
2025 hThumbSpan = a/b; |
2161 hThumbSpan = a/b; |
2026 hScrollSpan = Max( hThumbPos + hThumbSpan, c/b ); |
2162 hScrollSpan = Max( hThumbPos + hThumbSpan, c/b ); |
2027 } |
2163 } |
2028 |
2164 if ( iFlags.IsSet( EFlagMirroredLayoutInUse ) ) |
2029 if ( AknLayoutUtils::LayoutMirrored() ) |
2165 |
2030 { |
2166 { |
2031 hThumbPos = hScrollSpan - ( hThumbPos + hThumbSpan ); |
2167 hThumbPos = hScrollSpan - ( hThumbPos + hThumbSpan ); |
2032 } |
2168 } |
2033 TEikScrollBarModel hModel( hScrollSpan, hThumbSpan, hThumbPos ); |
2169 TEikScrollBarModel hModel( hScrollSpan, hThumbSpan, hThumbPos ); |
2034 |
2170 |
2071 |
2207 |
2072 // Set new model for scrollbars. |
2208 // Set new model for scrollbars. |
2073 iScrollbarFrame->Tile( &hModel, &vModel ); |
2209 iScrollbarFrame->Tile( &hModel, &vModel ); |
2074 |
2210 |
2075 LayoutView(); |
2211 LayoutView(); |
2076 UpdateScrollbars(); // Recursion |
2212 UpdateScrollbars( aDrawNow ); // Recursion |
2077 |
2213 |
2078 // Update animation in case that scrollbar visibility change |
2214 // Update animation in case that scrollbar visibility change |
2079 // has affected the highlight size of focused item. |
2215 // has affected the highlight size of focused item. |
2080 UpdateAnimation(); |
2216 UpdateAnimation(); |
2081 } |
2217 } |
2082 else |
2218 else |
2083 { |
2219 { |
2084 // Set new model for scrollbars. |
2220 // Set new model for scrollbars. |
2085 iScrollbarFrame->Tile( &hModel, &vModel ); |
2221 iScrollbarFrame->Tile( &hModel, &vModel ); |
2086 } |
2222 } |
2223 |
|
2224 if ( !aDrawNow ) |
|
2225 { |
|
2226 // Restore the previous draw background state values. |
|
2227 iScrollbarFrame->DrawBackground( drawHorizontal, drawVertical ); |
|
2228 } |
|
2087 } |
2229 } |
2088 |
2230 |
2089 } |
2231 } |
2090 |
2232 |
2091 |
2233 |
2532 { |
2674 { |
2533 iLongPressTimer->Cancel(); |
2675 iLongPressTimer->Cancel(); |
2534 } |
2676 } |
2535 |
2677 |
2536 // Exits marking mode. |
2678 // Exits marking mode. |
2537 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
2679 if ( iFlags.IsSet( EFlagMarkingState ) ) |
2538 { |
2680 { |
2539 ExitMarkingMode(); |
2681 ExitMarking(); |
2540 } |
2682 } |
2541 |
2683 |
2542 // Remove MSK observer. |
2684 // Remove MSK observer. |
2543 CEikButtonGroupContainer* cba; |
2685 CEikButtonGroupContainer* cba; |
2544 MopGetObject( cba ); |
2686 MopGetObject( cba ); |
2595 // Handles long press. |
2737 // Handles long press. |
2596 // --------------------------------------------------------------------------- |
2738 // --------------------------------------------------------------------------- |
2597 // |
2739 // |
2598 void CAknTreeListView::DoHandleLongPressL() |
2740 void CAknTreeListView::DoHandleLongPressL() |
2599 { |
2741 { |
2600 if ( iFlags.IsClear( EFlagMarkingMode ) ) |
2742 if ( iFlags.IsClear( EFlagMarkingState ) ) |
2601 { |
2743 { |
2602 EnterMarkingMode(); |
2744 EnterMarking(); |
2603 } |
2745 } |
2604 } |
2746 } |
2605 |
2747 |
2606 |
2748 |
2607 // --------------------------------------------------------------------------- |
2749 // --------------------------------------------------------------------------- |
2608 // Enters marking mode. |
2750 // Enters marking state. |
2609 // --------------------------------------------------------------------------- |
2751 // --------------------------------------------------------------------------- |
2610 // |
2752 // |
2611 void CAknTreeListView::EnterMarkingMode() |
2753 void CAknTreeListView::EnterMarking() |
2612 { |
2754 { |
2613 CEikButtonGroupContainer* bgc; |
2755 CEikButtonGroupContainer* bgc; |
2614 CCoeControl* MSK = NULL; |
2756 CCoeControl* MSK = NULL; |
2615 MopGetObject( bgc ); |
2757 MopGetObject( bgc ); |
2616 if ( bgc ) |
2758 if ( bgc ) |
2640 TRAPD( err, bgc->AddCommandToStackL( 3, newResourceId ) ); |
2782 TRAPD( err, bgc->AddCommandToStackL( 3, newResourceId ) ); |
2641 if ( !err ) |
2783 if ( !err ) |
2642 { |
2784 { |
2643 ReportTreeListEvent( MAknTreeListObserver::EMarkingModeEnabled, |
2785 ReportTreeListEvent( MAknTreeListObserver::EMarkingModeEnabled, |
2644 iTree.Id( FocusedItem() ) ); |
2786 iTree.Id( FocusedItem() ) ); |
2645 iFlags.Set( EFlagMarkingMode ); |
2787 iFlags.Set( EFlagMarkingState ); |
2646 bgc->DrawNow(); |
2788 bgc->DrawNow(); |
2647 } |
2789 } |
2648 } |
2790 } |
2649 } |
2791 } |
2650 |
2792 |
2651 |
2793 |
2652 // --------------------------------------------------------------------------- |
2794 // --------------------------------------------------------------------------- |
2653 // Exits marking mode. |
2795 // Exits marking state. |
2654 // --------------------------------------------------------------------------- |
2796 // --------------------------------------------------------------------------- |
2655 // |
2797 // |
2656 void CAknTreeListView::ExitMarkingMode() |
2798 void CAknTreeListView::ExitMarking() |
2657 { |
2799 { |
2658 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
2800 if ( iFlags.IsSet( EFlagMarkingState ) ) |
2659 { |
2801 { |
2660 CEikButtonGroupContainer* bgc = NULL; |
2802 CEikButtonGroupContainer* bgc = NULL; |
2661 CCoeControl* MSK = NULL; |
2803 CCoeControl* MSK = NULL; |
2662 MopGetObject( bgc ); |
2804 MopGetObject( bgc ); |
2663 if ( bgc ) |
2805 if ( bgc ) |
2673 } |
2815 } |
2674 } |
2816 } |
2675 } |
2817 } |
2676 ReportTreeListEvent( MAknTreeListObserver::EMarkingModeDisabled, |
2818 ReportTreeListEvent( MAknTreeListObserver::EMarkingModeDisabled, |
2677 iTree.Id( FocusedItem() ) ); |
2819 iTree.Id( FocusedItem() ) ); |
2678 iFlags.Clear( EFlagMarkingMode ); |
2820 iFlags.Clear( EFlagMarkingState ); |
2679 } |
2821 } |
2680 } |
2822 } |
2681 |
2823 |
2682 |
2824 |
2683 // --------------------------------------------------------------------------- |
2825 // --------------------------------------------------------------------------- |
2719 // --------------------------------------------------------------------------- |
2861 // --------------------------------------------------------------------------- |
2720 // |
2862 // |
2721 void CAknTreeListView::DrawItemsWithPhysics( const TRect& aRect ) const |
2863 void CAknTreeListView::DrawItemsWithPhysics( const TRect& aRect ) const |
2722 { |
2864 { |
2723 TBool empty = IsEmpty(); |
2865 TBool empty = IsEmpty(); |
2724 |
2866 TInt offset = Offset(); |
2725 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2867 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2726 CWindowGc& gc = iGc && !empty ? *iGc : SystemGc(); |
2868 CWindowGc& gc = iGc && !empty ? *iGc : SystemGc(); |
2727 TInt offset = Offset(); |
|
2728 #else |
2869 #else |
2729 CWindowGc& gc = SystemGc(); |
2870 CWindowGc& gc = SystemGc(); |
2730 #endif |
2871 #endif |
2731 |
2872 |
2873 TInt checkBoxOffset ( 0 ); |
|
2874 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
|
2875 { |
|
2876 if ( iFlags.IsSet( EFlagMirroredLayoutInUse ) ) |
|
2877 { |
|
2878 checkBoxOffset = |
|
2879 AknLayoutScalable_Avkon::list_double_graphic_pane_t1( |
|
2880 0 ).LayoutLine().ir; |
|
2881 } |
|
2882 else |
|
2883 { |
|
2884 checkBoxOffset = |
|
2885 AknLayoutScalable_Avkon::list_double_graphic_pane_t1( |
|
2886 0 ).LayoutLine().il; |
|
2887 } |
|
2888 } |
|
2732 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2889 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2733 MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( &gc ); |
2890 MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( &gc ); |
2734 if ( !empty && transApi ) |
2891 if ( !empty && transApi ) |
2735 { |
2892 { |
2736 |
2893 |
2771 { |
2928 { |
2772 transApi->StopDrawing(); |
2929 transApi->StopDrawing(); |
2773 } |
2930 } |
2774 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
2931 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
2775 |
2932 |
2933 // text color, used to draw the separator line between list items |
|
2934 TRgb textColor( KRgbBlack ); |
|
2935 AknsUtils::GetCachedColor( skin, |
|
2936 textColor, |
|
2937 KAknsIIDQsnTextColors, |
|
2938 EAknsCIQsnTextColorsCG6 ); |
|
2939 if ( iFlags.IsSet( EFlagMarkingMode ) |
|
2940 && iMarkingIconArray |
|
2941 && iMarkingIconArray->Count() == KMarkingModeIconArraySize ) |
|
2942 |
|
2943 { |
|
2944 // Set sizes for marking icon bitmaps |
|
2945 TRect drawRect; |
|
2946 drawRect = iItems[0].Rect(); |
|
2947 |
|
2948 // Rect for the marking icon |
|
2949 TRect iconRect = RectFromLayout( drawRect, |
|
2950 AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) ); |
|
2951 |
|
2952 for ( TInt ii = 0; ii < iMarkingIconArray->Count(); ++ii ) |
|
2953 { |
|
2954 CGulIcon* icon = ( *iMarkingIconArray )[ii]; |
|
2955 CFbsBitmap* bitmap = icon->Bitmap(); |
|
2956 |
|
2957 if ( bitmap ) |
|
2958 { |
|
2959 TSize size( bitmap->SizeInPixels() ); // set size if not already |
|
2960 TSize targetSize( iconRect.Size() ); |
|
2961 |
|
2962 if ( size.iWidth != targetSize.iWidth && size.iHeight |
|
2963 != targetSize.iHeight ) |
|
2964 { |
|
2965 AknIconUtils::SetSize( bitmap, targetSize, |
|
2966 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
2967 } |
|
2968 } |
|
2969 } |
|
2970 } |
|
2776 const TInt itemCount = iItems.Count(); |
2971 const TInt itemCount = iItems.Count(); |
2777 for ( TInt ii = 0; ii < itemCount; ++ii ) |
2972 for ( TInt ii = 0; ii < itemCount; ++ii ) |
2778 { |
2973 { |
2779 TRect drawRect( iItems[ii].Rect() ); |
2974 TRect drawRect( iItems[ii].Rect() ); |
2780 |
2975 |
2976 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
|
2977 { |
|
2978 drawRect.iBr.iX += checkBoxOffset; |
|
2979 } |
|
2980 |
|
2781 if ( iItems[ii].Item() ) |
2981 if ( iItems[ii].Item() ) |
2782 { |
2982 { |
2983 |
|
2783 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2984 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2784 TRect tfxDrawRect( drawRect ); |
2985 TRect tfxDrawRect( drawRect ); |
2785 tfxDrawRect.Move( 0, -offset ); |
2986 tfxDrawRect.Move( 0, -offset ); |
2786 |
2987 |
2787 if ( transApi ) |
2988 if ( transApi ) |
2788 { |
2989 { |
2789 transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified ); |
2990 transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified ); |
2790 } |
2991 } |
2791 |
2992 |
2792 |
|
2793 TRect clippingRect( tfxDrawRect ); |
2993 TRect clippingRect( tfxDrawRect ); |
2794 |
2994 |
2795 // If horizontal scrollbar on, reduce clipping rect |
2995 // If horizontal scrollbar on, reduce clipping rect |
2796 // based on view rect from layout data |
2996 // based on view rect from layout data |
2797 if ( iScrollbarFrame->ScrollBarVisibility( CEikScrollBar::EHorizontal ) |
2997 if ( iScrollbarFrame->ScrollBarVisibility( CEikScrollBar::EHorizontal ) |
2801 if ( clippingRect.iBr.iY > viewRect.iBr.iY ) |
3001 if ( clippingRect.iBr.iY > viewRect.iBr.iY ) |
2802 { |
3002 { |
2803 clippingRect.iBr.iY = viewRect.iBr.iY; |
3003 clippingRect.iBr.iY = viewRect.iBr.iY; |
2804 } |
3004 } |
2805 } |
3005 } |
3006 // Set clipping rect. |
|
3007 if ( clippingRect.Intersects( aRect ) ) |
|
3008 { |
|
3009 clippingRect.Intersection( aRect ); |
|
3010 gc.SetClippingRect( clippingRect ); |
|
3011 } |
|
3012 else |
|
3013 { |
|
3014 //Draw nothing if no overlap between item rectangel and given rect. |
|
3015 continue; |
|
3016 } |
|
2806 |
3017 |
2807 // Set clipping rect. |
|
2808 gc.SetClippingRect( clippingRect ); |
|
2809 |
|
2810 |
|
2811 if ( transApi ) |
3018 if ( transApi ) |
2812 { |
3019 { |
2813 transApi->StopDrawing(); |
3020 transApi->StopDrawing(); |
2814 } |
3021 } |
2815 #endif |
3022 #endif |
2816 TBool focused = ( IsFocused() && FocusedItem() && |
3023 |
3024 if ( iItems[ii].Item() != iBottomItem ) |
|
3025 { |
|
3026 TRect offsetRect( drawRect ); |
|
3027 offsetRect.Move( 0, -offset ); |
|
3028 AknListUtils::DrawSeparator( gc, offsetRect, textColor, skin ); |
|
3029 } |
|
3030 |
|
3031 TBool focused = ( FocusedItem() && |
|
2817 iItems[ii].Item() == FocusedItem() ); |
3032 iItems[ii].Item() == FocusedItem() ); |
2818 |
3033 |
2819 if ( SingleClickEnabled() && !HighlightEnabled() ) |
3034 if ( SingleClickEnabled() && !HighlightEnabled() ) |
2820 { |
3035 { |
2821 focused = EFalse; |
3036 focused = EFalse; |
2824 if ( focused ) |
3039 if ( focused ) |
2825 { |
3040 { |
2826 // Draw highlight for focused item. |
3041 // Draw highlight for focused item. |
2827 TRect highlightRect( iItems[ii].HighlightRect( |
3042 TRect highlightRect( iItems[ii].HighlightRect( |
2828 iViewLevel, Indention(), IndentionWidth() ) ); |
3043 iViewLevel, Indention(), IndentionWidth() ) ); |
3044 |
|
3045 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
|
3046 { |
|
3047 highlightRect.iBr.iX = drawRect.iBr.iX; |
|
3048 highlightRect.iTl.iX = drawRect.iTl.iX; |
|
3049 } |
|
2829 |
3050 |
2830 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
3051 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2831 TRect tfxHighlightRect( highlightRect ); |
3052 TRect tfxHighlightRect( highlightRect ); |
2832 tfxHighlightRect.Move( 0, -offset ); |
3053 tfxHighlightRect.Move( 0, -offset ); |
2833 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
3054 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
2834 |
3055 |
2835 if ( iIsPressedDownState || !DrawAnimation( gc, highlightRect ) ) |
3056 if ( iFlags.IsSet( EFlagIsPressedDownState ) |
3057 || !DrawAnimation( gc, highlightRect ) ) |
|
2836 { |
3058 { |
2837 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
3059 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2838 if ( transApi ) |
3060 if ( transApi ) |
2839 { |
3061 { |
2840 transApi->Invalidate(MAknListBoxTfxInternal::EListHighlight ); |
3062 transApi->Invalidate(MAknListBoxTfxInternal::EListHighlight ); |
2841 transApi->BeginRedraw( MAknListBoxTfxInternal::EListHighlight, tfxHighlightRect ); |
3063 transApi->BeginRedraw( MAknListBoxTfxInternal::EListHighlight, |
3064 tfxHighlightRect ); |
|
2842 transApi->StartDrawing( MAknListBoxTfxInternal::EListHighlight ); |
3065 transApi->StartDrawing( MAknListBoxTfxInternal::EListHighlight ); |
2843 } |
3066 } |
2844 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
3067 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
2845 |
3068 DrawHighlight( gc, highlightRect, |
2846 DrawHighlight( gc, highlightRect, iIsPressedDownState ); |
3069 iFlags.IsSet( EFlagIsPressedDownState ) ); |
3070 |
|
2847 |
3071 |
2848 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
3072 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2849 if ( transApi ) |
3073 if ( transApi ) |
2850 { |
3074 { |
2851 transApi->StopDrawing(); |
3075 transApi->StopDrawing(); |
2859 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
3083 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2860 tfxDrawRect.BoundingRect( tfxHighlightRect ); |
3084 tfxDrawRect.BoundingRect( tfxHighlightRect ); |
2861 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
3085 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
2862 } |
3086 } |
2863 |
3087 |
3088 if ( iFlags.IsSet( EFlagMarkingMode ) && iMarkingIconArray |
|
3089 && iMarkingIconArray->Count() == |
|
3090 KMarkingModeIconArraySize ) |
|
3091 { |
|
3092 // Rect for the marking icon |
|
3093 TRect iconRect = RectFromLayout( drawRect, |
|
3094 AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) ); |
|
3095 |
|
3096 iconRect.Move( 0, -offset ); |
|
3097 // unchecked icon |
|
3098 CGulIcon* icon = ( *iMarkingIconArray )[1]; |
|
3099 |
|
3100 TBool marked = ( iItems[ii].Item()->IsMarked() ); |
|
3101 if ( marked ) |
|
3102 { |
|
3103 icon = (*iMarkingIconArray)[0]; |
|
3104 } |
|
3105 |
|
3106 CFbsBitmap* bitmap = icon->Bitmap(); |
|
3107 |
|
3108 if ( bitmap ) |
|
3109 { |
|
3110 gc.BitBltMasked( iconRect.iTl, bitmap, |
|
3111 iconRect.Size(), icon->Mask(), EFalse ); |
|
3112 } |
|
3113 } |
|
3114 |
|
3115 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
|
3116 { |
|
3117 drawRect.iBr.iX -= checkBoxOffset; |
|
3118 if ( iFlags.IsClear( EFlagMirroredLayoutInUse ) ) |
|
3119 { |
|
3120 gc.SetOrigin( TPoint( checkBoxOffset, 0 ) ); |
|
3121 } |
|
3122 } |
|
3123 |
|
2864 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
3124 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2865 if (iItems[ii].Item()) |
3125 if (iItems[ii].Item()) |
2866 { |
3126 { |
2867 if ( transApi ) |
3127 if ( transApi ) |
2868 { |
3128 { |
2869 transApi->BeginRedraw(MAknListBoxTfxInternal::EListItem, tfxDrawRect, iTree.VisibleItemIndex(iItems[ii].Item())); |
3129 transApi->BeginRedraw( |
3130 MAknListBoxTfxInternal::EListItem, |
|
3131 tfxDrawRect, |
|
3132 iTree.VisibleItemIndex( iItems[ii].Item() ) ); |
|
2870 transApi->StartDrawing( MAknListBoxTfxInternal::EListItem ); |
3133 transApi->StartDrawing( MAknListBoxTfxInternal::EListItem ); |
2871 } |
3134 } |
2872 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
3135 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
2873 |
3136 |
2874 // Draw item. |
3137 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
2875 iItems[ii].Draw( gc, iTree, drawRect, focused, iViewLevel, |
3138 { |
2876 StructureLines(), Indention(), IndentionWidth() ); |
3139 TBool marked = iItems[ii].Item()->IsMarked(); |
3140 if ( marked ) |
|
3141 { |
|
3142 iItems[ii].Item()->SetMarked( EFalse ); |
|
3143 } |
|
3144 iItems[ii].Draw( gc, iTree, drawRect, focused, iViewLevel, |
|
3145 StructureLines(), Indention(), IndentionWidth() ); |
|
3146 |
|
3147 if ( marked ) |
|
3148 { |
|
3149 iItems[ii].Item()->SetMarked( ETrue ); |
|
3150 } |
|
3151 } |
|
3152 else |
|
3153 { |
|
3154 iItems[ii].Draw( gc, iTree, drawRect, focused, iViewLevel, |
|
3155 StructureLines(), Indention(), IndentionWidth() ); |
|
3156 } |
|
2877 |
3157 |
2878 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
3158 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2879 if ( transApi ) |
3159 if ( transApi ) |
2880 { |
3160 { |
2881 transApi->StopDrawing(); |
3161 transApi->StopDrawing(); |
2882 transApi->EndRedraw(MAknListBoxTfxInternal::EListItem, iTree.VisibleItemIndex(iItems[ii].Item())); |
3162 transApi->EndRedraw( |
3163 MAknListBoxTfxInternal::EListItem, |
|
3164 iTree.VisibleItemIndex( iItems[ii].Item() ) ); |
|
2883 } |
3165 } |
2884 } |
3166 } |
2885 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
3167 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
2886 |
3168 |
3169 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
|
3170 { |
|
3171 gc.SetOrigin( TPoint( 0, 0 ) ); |
|
3172 } |
|
2887 } |
3173 } |
2888 } |
3174 } |
2889 } |
3175 } |
2890 |
3176 |
2891 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
3177 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
2972 SetFocusIndex( ii ); |
3258 SetFocusIndex( ii ); |
2973 } |
3259 } |
2974 item = iterator.Previous(); |
3260 item = iterator.Previous(); |
2975 } |
3261 } |
2976 } |
3262 } |
2977 iScrollPhysicsTop = EFalse; |
3263 iFlags.Clear( EFlagScrollPhysicsTop ); |
2978 } |
3264 } |
2979 |
3265 |
2980 } |
3266 } |
2981 |
3267 |
2982 |
3268 |
2993 |
3279 |
2994 // --------------------------------------------------------------------------- |
3280 // --------------------------------------------------------------------------- |
2995 // Enables or disables the highlight drawing |
3281 // Enables or disables the highlight drawing |
2996 // --------------------------------------------------------------------------- |
3282 // --------------------------------------------------------------------------- |
2997 // |
3283 // |
2998 void CAknTreeListView::EnableHighlight( TBool aEnabled ) |
3284 void CAknTreeListView::EnableHighlight( TBool aEnabled, |
2999 { |
3285 TBool aPointerEnabled ) |
3286 { |
|
3287 TBool wasEnabled = iFlags.IsSet( EFlagHighlightEnabled ); |
|
3288 |
|
3000 if ( aEnabled ) |
3289 if ( aEnabled ) |
3001 { |
3290 { |
3002 iFlags.Set( EFlagHighlightEnabled ); |
3291 iFlags.Set( EFlagHighlightEnabled ); |
3003 } |
3292 } |
3004 else |
3293 else |
3005 { |
3294 { |
3006 iFlags.Clear( EFlagHighlightEnabled ); |
3295 iFlags.Clear( EFlagHighlightEnabled ); |
3296 } |
|
3297 |
|
3298 if ( !aPointerEnabled |
|
3299 && ( ( wasEnabled && !aEnabled ) |
|
3300 || ( !wasEnabled && aEnabled ) ) ) |
|
3301 { |
|
3302 ReportCollectionChangedEvent(); |
|
3007 } |
3303 } |
3008 } |
3304 } |
3009 |
3305 |
3010 // --------------------------------------------------------------------------- |
3306 // --------------------------------------------------------------------------- |
3011 // Returns ETrue if highlight is enabled |
3307 // Returns ETrue if highlight is enabled |
3034 // ----------------------------------------------------------------------------- |
3330 // ----------------------------------------------------------------------------- |
3035 // |
3331 // |
3036 TUint CAknTreeListView::CollectionState() const |
3332 TUint CAknTreeListView::CollectionState() const |
3037 { |
3333 { |
3038 TUint state( 0 ); |
3334 TUint state( 0 ); |
3039 if ( IsVisible() ) |
3335 if ( IsVisible() && ( !DrawableWindow() || !DrawableWindow()->IsFaded() ) ) |
3040 { |
3336 { |
3041 state |= MAknCollection::EStateCollectionVisible; |
3337 state |= MAknCollection::EStateCollectionVisible; |
3042 } |
3338 } |
3043 if ( HighlightEnabled() ) |
3339 if ( HighlightEnabled() ) |
3044 { |
3340 { |
3045 state |= MAknCollection::EStateHighlightVisible; |
3341 state |= MAknCollection::EStateHighlightVisible; |
3342 } |
|
3343 |
|
3344 if ( iList.Flags() & KAknTreeListMarkable ) |
|
3345 { |
|
3346 state |= MAknCollection::EStateMultipleSelection; |
|
3347 } |
|
3348 TBool markedItems( EFalse ); |
|
3349 TRAP_IGNORE( markedItems = HasMarkedItemsL() ); |
|
3350 if ( markedItems ) |
|
3351 { |
|
3352 state |= MAknCollection::EStateMarkedItems; |
|
3046 } |
3353 } |
3047 return state; |
3354 return state; |
3048 } |
3355 } |
3049 |
3356 |
3050 // ----------------------------------------------------------------------------- |
3357 // ----------------------------------------------------------------------------- |
3051 // CAknTreeListView::ItemActionMenuClosed |
3358 // CAknTreeListView::ItemActionMenuClosed |
3052 // ----------------------------------------------------------------------------- |
3359 // ----------------------------------------------------------------------------- |
3053 // |
3360 // |
3054 void CAknTreeListView::ItemActionMenuClosed() |
3361 void CAknTreeListView::ItemActionMenuClosed() |
3055 { |
3362 { |
3056 iFlags.Clear( EFlagIgnoreButtonUpEvent ); |
3363 iOldWinPos = KErrNotFound; |
3057 EnableHighlight( EFalse ); |
3364 EnableHighlight( EFalse ); |
3058 DrawDeferred(); |
3365 DrawDeferred(); |
3059 } |
3366 } |
3060 |
3367 |
3061 // ----------------------------------------------------------------------------- |
3368 // ----------------------------------------------------------------------------- |
3062 // CAknTreeListView::CollectionExtension |
3369 // CAknTreeListView::CollectionExtension |
3063 // ----------------------------------------------------------------------------- |
3370 // ----------------------------------------------------------------------------- |
3064 // |
3371 // |
3065 TInt CAknTreeListView::CollectionExtension( TUint /*aExtensionId*/, |
3372 TInt CAknTreeListView::CollectionExtension( |
3066 TAny*& /*a0*/, TAny* /*a1*/ ) |
3373 TUint aExtensionId, TAny*& a0, TAny* /*a1*/ ) |
3067 { |
3374 { |
3375 if ( aExtensionId == MAknMarkingCollection::TYPE ) |
|
3376 { |
|
3377 a0 = static_cast<MAknMarkingCollection*>( this ); |
|
3378 } |
|
3379 |
|
3068 return KErrNone; |
3380 return KErrNone; |
3069 } |
3381 } |
3382 |
|
3383 |
|
3384 // ----------------------------------------------------------------------------- |
|
3385 // CAknTreeListView::SetMultipleMarkingState |
|
3386 // ----------------------------------------------------------------------------- |
|
3387 // |
|
3388 void CAknTreeListView::SetMultipleMarkingState( TBool aActive ) |
|
3389 { |
|
3390 if ( iFlags.IsSet( EFlagMarkingMode ) != aActive ) |
|
3391 { |
|
3392 if ( !aActive ) |
|
3393 { |
|
3394 TBool markedItems( EFalse ); |
|
3395 TRAP_IGNORE( markedItems = HasMarkedItemsL() ); |
|
3396 if ( markedItems ) |
|
3397 { |
|
3398 UnmarkAll(); |
|
3399 } |
|
3400 } |
|
3401 |
|
3402 EnableMarking( aActive ); |
|
3403 if ( aActive ) |
|
3404 { |
|
3405 iFlags.Set( EFlagMarkingMode ); |
|
3406 } |
|
3407 else |
|
3408 { |
|
3409 iFlags.Clear( EFlagMarkingMode ); |
|
3410 } |
|
3411 if ( aActive ) |
|
3412 { |
|
3413 // Expand all items when entering marking mode |
|
3414 iTree.Expand(); |
|
3415 } |
|
3416 LayoutView(); |
|
3417 DrawDeferred(); |
|
3418 |
|
3419 if ( iList.MarkingModeObserver() ) |
|
3420 { |
|
3421 iList.MarkingModeObserver()->MarkingModeStatusChanged( aActive ); |
|
3422 } |
|
3423 } |
|
3424 } |
|
3425 |
|
3426 |
|
3427 // ----------------------------------------------------------------------------- |
|
3428 // CAknTreeListView::MarkingState |
|
3429 // ----------------------------------------------------------------------------- |
|
3430 // |
|
3431 TUint CAknTreeListView::MarkingState() const |
|
3432 { |
|
3433 TUint state( 0 ); |
|
3434 |
|
3435 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
|
3436 { |
|
3437 state |= MAknMarkingCollection::EStateMarkingMode; |
|
3438 |
|
3439 TBool markedItems ( EFalse ); |
|
3440 TRAP_IGNORE( markedItems = HasMarkedItemsL() ); |
|
3441 if ( markedItems ) |
|
3442 { |
|
3443 state |= MAknMarkingCollection::EStateMarkedItems; |
|
3444 } |
|
3445 if ( iItems.Count() == 0 ) |
|
3446 { |
|
3447 state |= MAknMarkingCollection::EStateCollectionEmpty; |
|
3448 } |
|
3449 } |
|
3450 return state; |
|
3451 } |
|
3452 |
|
3453 |
|
3454 // ----------------------------------------------------------------------------- |
|
3455 // CAknTreeListView::MarkCurrentItemL |
|
3456 // ----------------------------------------------------------------------------- |
|
3457 // |
|
3458 void CAknTreeListView::MarkCurrentItemL() |
|
3459 { |
|
3460 if ( iFlags.IsSet( EFlagMarkingMode ) && FocusedItem() && |
|
3461 FocusedItem()->IsMarkable() ) |
|
3462 { |
|
3463 MarkItem( FocusedItem(), ETrue, ETrue ); |
|
3464 } |
|
3465 } |
|
3466 |
|
3467 |
|
3468 // ----------------------------------------------------------------------------- |
|
3469 // CAknTreeListView::MarkAllL |
|
3470 // ----------------------------------------------------------------------------- |
|
3471 // |
|
3472 void CAknTreeListView::MarkAllL() |
|
3473 { |
|
3474 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
|
3475 { |
|
3476 TAknTreeIterator iterator = iTree.Iterator(); |
|
3477 CAknTreeItem* item = NULL; |
|
3478 item = iterator.First(); |
|
3479 while ( item && iterator.HasNext() ) |
|
3480 { |
|
3481 if ( item->IsMarkable() ) |
|
3482 { |
|
3483 MarkItem( item, ETrue, EFalse ); |
|
3484 } |
|
3485 item = iterator.Next(); |
|
3486 } |
|
3487 DrawDeferred(); |
|
3488 } |
|
3489 } |
|
3490 |
|
3491 |
|
3492 // ----------------------------------------------------------------------------- |
|
3493 // CAknTreeListView::UnmarkAll |
|
3494 // ----------------------------------------------------------------------------- |
|
3495 // |
|
3496 void CAknTreeListView::UnmarkAll() |
|
3497 { |
|
3498 if ( iFlags.IsSet( EFlagMarkingMode ) ) |
|
3499 { |
|
3500 TAknTreeIterator iterator = iTree.Iterator(); |
|
3501 CAknTreeItem* item = NULL; |
|
3502 item = iterator.First(); |
|
3503 while ( item && iterator.HasNext() ) |
|
3504 { |
|
3505 MarkItem( item, EFalse, EFalse ); |
|
3506 item = iterator.Next(); |
|
3507 } |
|
3508 DrawDeferred(); |
|
3509 } |
|
3510 } |
|
3511 |
|
3512 |
|
3513 // ----------------------------------------------------------------------------- |
|
3514 // CAknTreeListView::CurrentItemMarkable |
|
3515 // ----------------------------------------------------------------------------- |
|
3516 // |
|
3517 TBool CAknTreeListView::CurrentItemMarkable() |
|
3518 { |
|
3519 if ( FocusedItem() && !FocusedItem()->IsMarkable() ) |
|
3520 { |
|
3521 return EFalse; |
|
3522 } |
|
3523 return ETrue; |
|
3524 } |
|
3525 |
|
3526 // ----------------------------------------------------------------------------- |
|
3527 // CAknTreeListView::ExitMarkingMode |
|
3528 // ----------------------------------------------------------------------------- |
|
3529 // |
|
3530 TBool CAknTreeListView::ExitMarkingMode() |
|
3531 { |
|
3532 if ( iList.MarkingModeObserver() ) |
|
3533 { |
|
3534 return iList.MarkingModeObserver()->ExitMarkingMode(); |
|
3535 } |
|
3536 return ETrue; |
|
3537 } |
|
3538 |
|
3539 |
|
3540 // ----------------------------------------------------------------------------- |
|
3541 // CAknTreeListView::ReportCollectionChangedEvent |
|
3542 // ----------------------------------------------------------------------------- |
|
3543 // |
|
3544 void CAknTreeListView::ReportCollectionChangedEvent() |
|
3545 { |
|
3546 if ( iItemActionMenu ) |
|
3547 { |
|
3548 iItemActionMenu->CollectionChanged( *this ); |
|
3549 } |
|
3550 } |
|
3551 |
|
3070 |
3552 |
3071 // --------------------------------------------------------------------------- |
3553 // --------------------------------------------------------------------------- |
3072 // CAknTreeListView::HandleLongTapEventL |
3554 // CAknTreeListView::HandleLongTapEventL |
3073 // --------------------------------------------------------------------------- |
3555 // --------------------------------------------------------------------------- |
3074 // |
3556 // |
3075 void CAknTreeListView::HandleLongTapEventL( |
3557 void CAknTreeListView::HandleLongTapEventL( |
3076 const TPoint& /*aPenEventLocation*/, |
3558 const TPoint& /*aPenEventLocation*/, |
3077 const TPoint& aPenEventScreenLocation) |
3559 const TPoint& aPenEventScreenLocation) |
3078 { |
3560 { |
3079 iFlags.Set( EFlagIgnoreButtonUpEvent ); |
|
3080 iItemActionMenu->ShowMenuL( aPenEventScreenLocation, 0 ); |
3561 iItemActionMenu->ShowMenuL( aPenEventScreenLocation, 0 ); |
3562 iOldWinPos = DrawableWindow()->OrdinalPosition(); |
|
3563 IgnoreEventsUntilNextPointerUp(); |
|
3081 } |
3564 } |
3082 |
3565 |
3083 // --------------------------------------------------------------------------- |
3566 // --------------------------------------------------------------------------- |
3084 // CAknTreeListView::LongTapPointerEventL |
3567 // CAknTreeListView::LongTapPointerEventL |
3085 // --------------------------------------------------------------------------- |
3568 // --------------------------------------------------------------------------- |
3086 // |
3569 // |
3087 void CAknTreeListView::LongTapPointerEventL( |
3570 void CAknTreeListView::LongTapPointerEventL( |
3088 const TPointerEvent& aPointerEvent) |
3571 const TPointerEvent& aPointerEvent) |
3089 { |
3572 { |
3090 if ( iLongTapDetector && iItemActionMenu && iItemActionMenu->InitMenuL() ) |
3573 if ( iLongTapDetector && iItemActionMenu |
3574 && !( HasMarkedItemsL() && FocusedItem() |
|
3575 && !FocusedItem()->IsMarked() ) && iItemActionMenu->InitMenuL() ) |
|
3091 { |
3576 { |
3092 iLongTapDetector->PointerEventL( aPointerEvent ); |
3577 iLongTapDetector->PointerEventL( aPointerEvent ); |
3093 } |
3578 } |
3094 } |
3579 } |
3095 |
3580 |
3107 |
3592 |
3108 // --------------------------------------------------------------------------- |
3593 // --------------------------------------------------------------------------- |
3109 // CAknTreeListView::HasMarkedItemsL |
3594 // CAknTreeListView::HasMarkedItemsL |
3110 // --------------------------------------------------------------------------- |
3595 // --------------------------------------------------------------------------- |
3111 // |
3596 // |
3112 TBool CAknTreeListView::HasMarkedItemsL() |
3597 TBool CAknTreeListView::HasMarkedItemsL() const |
3113 { |
3598 { |
3114 RArray<TInt> selection; |
3599 RArray<TInt> selection; |
3115 CleanupClosePushL( selection ); |
3600 CleanupClosePushL( selection ); |
3116 iList.GetMarkedItemsL( selection ); |
3601 iList.GetMarkedItemsL( selection ); |
3117 TInt count( selection.Count() ); |
3602 TInt count( selection.Count() ); |
3118 CleanupStack::PopAndDestroy( &selection ); |
3603 CleanupStack::PopAndDestroy( &selection ); |
3119 if ( count > 0 ) |
3604 return ( count > 0 ); |
3120 { |
|
3121 return ETrue; |
|
3122 } |
|
3123 return EFalse; |
|
3124 } |
3605 } |
3125 |
3606 |
3126 |
3607 |
3127 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
3608 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
3128 // --------------------------------------------------------------------------- |
3609 // --------------------------------------------------------------------------- |
3153 |
3634 |
3154 TInt& CAknTreeListView::BottomIndex() |
3635 TInt& CAknTreeListView::BottomIndex() |
3155 { |
3636 { |
3156 return iBottomIndex; |
3637 return iBottomIndex; |
3157 } |
3638 } |
3158 |
3639 |
3640 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
3641 // --------------------------------------------------------------------------- |
|
3642 // CAknTreeListView::UpdateIndexes |
|
3643 // --------------------------------------------------------------------------- |
|
3644 // |
|
3159 void CAknTreeListView::UpdateIndexes() |
3645 void CAknTreeListView::UpdateIndexes() |
3160 { |
3646 { |
3647 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
3161 iTopIndex = iBottomIndex = iHighlightIndex = 0; |
3648 iTopIndex = iBottomIndex = iHighlightIndex = 0; |
3649 #else |
|
3650 iBottomIndex = 0; |
|
3651 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
3162 |
3652 |
3163 if ( iItems.Count() ) |
3653 if ( iItems.Count() ) |
3164 { |
3654 { |
3165 for (TInt i=iItems.Count()-1; i>=0; i--) |
3655 for (TInt i=iItems.Count()-1; i>=0; i--) |
3166 { |
3656 { |
3167 if (iItems[i].Item()) |
3657 if (iItems[i].Item()) |
3168 { |
3658 { |
3169 iBottomIndex = iTree.VisibleItemIndex(iItems[i].Item()); |
3659 iBottomItem = iItems[i].Item(); |
3660 iBottomIndex = iTree.VisibleItemIndex( iBottomItem ); |
|
3170 break; |
3661 break; |
3171 } |
3662 } |
3172 } |
3663 } |
3173 |
3664 |
3665 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
3174 iTopIndex = iTree.VisibleItemIndex(iItems[0].Item()); |
3666 iTopIndex = iTree.VisibleItemIndex(iItems[0].Item()); |
3175 iHighlightIndex = iTree.VisibleItemIndex(FocusedItem()); |
3667 iHighlightIndex = iTree.VisibleItemIndex(FocusedItem()); |
3668 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
3176 } |
3669 } |
3177 } |
3670 } |
3178 |
3671 |
3179 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
3672 |
3673 // ----------------------------------------------------------------------------- |
|
3674 // CAknTreeListView::LoadMarkingIconsL |
|
3675 // ----------------------------------------------------------------------------- |
|
3676 // |
|
3677 void CAknTreeListView::LoadMarkingIconsL() |
|
3678 { |
|
3679 if ( !iMarkingIconArray ) |
|
3680 { |
|
3681 iMarkingIconArray = new ( ELeave ) |
|
3682 CAknIconArray( KMarkingModeIconArraySize ); |
|
3683 } |
|
3684 else |
|
3685 { |
|
3686 iMarkingIconArray->ResetAndDestroy(); |
|
3687 } |
|
3688 |
|
3689 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
3690 const TDesC& avkonIconFile = AknIconUtils::AvkonIconFileName(); |
|
3691 |
|
3692 CGulIcon* icon = AknsUtils::CreateGulIconL( skin, |
|
3693 KAknsIIDQgnPropCheckboxOn, |
|
3694 avkonIconFile, |
|
3695 EMbmAvkonQgn_prop_checkbox_on, |
|
3696 EMbmAvkonQgn_prop_checkbox_on_mask ); |
|
3697 |
|
3698 CleanupStack::PushL( icon ); |
|
3699 iMarkingIconArray->AppendL( icon ); |
|
3700 CleanupStack::Pop( icon ); |
|
3701 |
|
3702 icon = AknsUtils::CreateGulIconL( skin, |
|
3703 KAknsIIDQgnPropCheckboxOff, |
|
3704 avkonIconFile, |
|
3705 EMbmAvkonQgn_prop_checkbox_off, |
|
3706 EMbmAvkonQgn_prop_checkbox_off_mask ); |
|
3707 |
|
3708 CleanupStack::PushL( icon ); |
|
3709 iMarkingIconArray->AppendL( icon ); |
|
3710 CleanupStack::Pop( icon ); |
|
3711 } |
|
3712 |