72 #include <touchfeedback.h> |
72 #include <touchfeedback.h> |
73 #include <akncollection.h> |
73 #include <akncollection.h> |
74 #include <aknitemactionmenu.h> |
74 #include <aknitemactionmenu.h> |
75 #include <aknlongtapdetector.h> |
75 #include <aknlongtapdetector.h> |
76 #include <AknPriv.hrh> |
76 #include <AknPriv.hrh> |
|
77 #include <aknmarkingmodeobserver.h> |
77 #include "akntrace.h" |
78 #include "akntrace.h" |
78 |
79 |
79 // timeout for long keypress used in markable lists |
80 // timeout for long keypress used in markable lists |
80 const TInt KLongPressInterval = 600000; // 0,6 seconds |
81 const TInt KLongPressInterval = 600000; // 0,6 seconds |
81 const TInt KEikListBoxPointerRepeatInterval = 100000; // in micro conds (= 0.1 secod) |
82 const TInt KEikListBoxPointerRepeatInterval = 100000; // in micro conds (= 0.1 secod) |
83 // Maximum scroll speed ( max amount of items moved one time ) |
84 // Maximum scroll speed ( max amount of items moved one time ) |
84 const TInt KDefaultMaxSpeed = 30; |
85 const TInt KDefaultMaxSpeed = 30; |
85 const TInt KDefaultStepSpeed = 5; |
86 const TInt KDefaultStepSpeed = 5; |
86 const TInt KEikListBoxInvalidIndex=-1; |
87 const TInt KEikListBoxInvalidIndex=-1; |
87 //interval time for disable second point event |
88 //interval time for disable second point event |
88 const TInt KTwoPointerUpEventInterval = 120; // 120 millisecond ( = 0.12 second ) |
89 const TInt KTwoPointerUpEventInterval = 120; // 120 millisecond ( = 0.12 second ) |
|
90 const TInt KPointerDownAndUpThreshold = 5; |
89 // ----------------------------------------------------------------------------- |
91 // ----------------------------------------------------------------------------- |
90 // If a parent to the supplied control has its Gc set, this function will find |
92 // If a parent to the supplied control has its Gc set, this function will find |
91 // it and return it. |
93 // it and return it. |
92 // ----------------------------------------------------------------------------- |
94 // ----------------------------------------------------------------------------- |
93 // |
95 // |
446 * @param a0 First extension method parameter. |
449 * @param a0 First extension method parameter. |
447 * @param a1 Second extension method parameter. |
450 * @param a1 Second extension method parameter. |
448 */ |
451 */ |
449 TInt CollectionExtension( TUint aExtensionId, TAny*& a0, TAny* a1 ); |
452 TInt CollectionExtension( TUint aExtensionId, TAny*& a0, TAny* a1 ); |
450 |
453 |
|
454 // From MAknMarkingCollection |
|
455 /** |
|
456 * Sets multiple marking state. |
|
457 * |
|
458 * @param aActive ETrue if multiple marking should be active. |
|
459 */ |
|
460 void SetMultipleMarkingState( TBool aActive ); |
|
461 |
|
462 /** |
|
463 * Returns whether the observer accepts ending of marking mode |
|
464 * |
|
465 * @return ETrue if observer accepts exiting marking mode |
|
466 */ |
|
467 TBool ExitMarkingMode(); |
|
468 |
|
469 /** |
|
470 * Returns the collection marking state. The state is combination of |
|
471 * flags defined in @c TStateFlag. |
|
472 * |
|
473 * @return Collection state. |
|
474 */ |
|
475 TUint MarkingState() const; |
|
476 |
|
477 /** |
|
478 * Marks the currently selected item. |
|
479 */ |
|
480 void MarkCurrentItemL(); |
|
481 |
|
482 /** |
|
483 * Marks all items in the collection. |
|
484 */ |
|
485 void MarkAllL(); |
|
486 |
|
487 /** |
|
488 * Unmarks all items in the collection. |
|
489 */ |
|
490 void UnmarkAll(); |
|
491 |
|
492 /* |
|
493 * Can current item be marked |
|
494 * |
|
495 * @return ETrue if item can be marked |
|
496 */ |
|
497 TBool CurrentItemMarkable(); |
|
498 |
451 // From MAknLongTapDetectorCallBack |
499 // From MAknLongTapDetectorCallBack |
452 /** |
500 /** |
453 * Long tap detector callback |
501 * Long tap detector callback |
454 * |
502 * |
455 * @param aPenEventLocation Long tap event location relative to parent control. |
503 * @param aPenEventLocation Long tap event location relative to parent control. |
680 |
739 |
681 /** |
740 /** |
682 * Item that opened the item action menu |
741 * Item that opened the item action menu |
683 */ |
742 */ |
684 TInt iLongTappedItem; |
743 TInt iLongTappedItem; |
|
744 |
|
745 /** |
|
746 * Marking mode on / off. |
|
747 */ |
|
748 TBool iMarkingModeInUse; |
|
749 |
|
750 /** |
|
751 * Marking mode observer. |
|
752 */ |
|
753 MAknMarkingModeObserver* iMarkingModeObserver; |
|
754 |
685 /** |
755 /** |
686 * Pointer event to be forwarded to the long tap detector upon |
756 * Pointer event to be forwarded to the long tap detector upon |
687 * highlight timer completion. |
757 * highlight timer completion. |
688 */ |
758 */ |
689 TPointerEvent iDelayedPointerDownEvent; |
759 TPointerEvent iDelayedPointerDownEvent; |
|
760 |
|
761 /** |
|
762 * Ordinal position of listbox window, before stylus menu is opened. |
|
763 */ |
|
764 TInt iOldWinPos; |
|
765 |
|
766 /** |
|
767 * If double click modifier is set on PointerEvent, the event may be ignored |
|
768 * in some situation(To prevent extra dialog launched by AO). |
|
769 */ |
|
770 TBool iDoubleClickEventIgnored; |
690 |
771 |
691 private: |
772 private: |
692 CMatchBuffer* iBuffer; |
773 CMatchBuffer* iBuffer; |
693 CEikListBox& iListBox; |
774 CEikListBox& iListBox; |
694 CEikListBox::TReasonForFocusLost iReasonForFocusLost; |
775 CEikListBox::TReasonForFocusLost iReasonForFocusLost; |
943 if ( iLongTappedItem != KErrNotFound ) |
1029 if ( iLongTappedItem != KErrNotFound ) |
944 { |
1030 { |
945 EnableHighlight( EFalse ); |
1031 EnableHighlight( EFalse ); |
946 iListBox.iView->DrawItem( iLongTappedItem ); |
1032 iListBox.iView->DrawItem( iLongTappedItem ); |
947 iLongTappedItem = KErrNotFound; |
1033 iLongTappedItem = KErrNotFound; |
|
1034 iOldWinPos = KErrNotFound; |
948 } |
1035 } |
949 } |
1036 } |
950 |
1037 |
951 |
1038 |
952 // ----------------------------------------------------------------------------- |
1039 // ----------------------------------------------------------------------------- |
953 // CListBoxExt::CollectionExtension |
1040 // CListBoxExt::CollectionExtension |
954 // ----------------------------------------------------------------------------- |
1041 // ----------------------------------------------------------------------------- |
955 // |
1042 // |
956 TInt CListBoxExt::CollectionExtension( |
1043 TInt CListBoxExt::CollectionExtension( |
957 TUint /*aExtensionId*/, TAny*& /*a0*/, TAny* /*a1*/ ) |
1044 TUint aExtensionId, TAny*& a0, TAny* /*a1*/ ) |
958 { |
1045 { |
959 return KErrNone; |
1046 if ( aExtensionId == MAknMarkingCollection::TYPE ) |
|
1047 { |
|
1048 a0 = static_cast<MAknMarkingCollection*>( this ); |
|
1049 return KErrNone; |
|
1050 } |
|
1051 |
|
1052 return KErrNotFound; |
|
1053 } |
|
1054 |
|
1055 |
|
1056 // ----------------------------------------------------------------------------- |
|
1057 // CListBoxExt::SetMultipleMarkingState |
|
1058 // ----------------------------------------------------------------------------- |
|
1059 // |
|
1060 void CListBoxExt::SetMultipleMarkingState( TBool aActive ) |
|
1061 { |
|
1062 _AKNTRACE_FUNC_ENTER; |
|
1063 iListBox.SetMarkingMode( aActive ); |
|
1064 _AKNTRACE_FUNC_EXIT; |
|
1065 } |
|
1066 |
|
1067 // ----------------------------------------------------------------------------- |
|
1068 // CListBoxExt::ExitMarkingMode |
|
1069 // ----------------------------------------------------------------------------- |
|
1070 // |
|
1071 TBool CListBoxExt::ExitMarkingMode() |
|
1072 { |
|
1073 if ( iListBox.MarkingModeObserver() ) |
|
1074 { |
|
1075 return iListBox.MarkingModeObserver()->ExitMarkingMode(); |
|
1076 } |
|
1077 return ETrue; |
|
1078 } |
|
1079 |
|
1080 // ----------------------------------------------------------------------------- |
|
1081 // CListBoxExt::MarkingState |
|
1082 // ----------------------------------------------------------------------------- |
|
1083 // |
|
1084 TUint CListBoxExt::MarkingState() const |
|
1085 { |
|
1086 _AKNTRACE_FUNC_ENTER; |
|
1087 TUint state( 0 ); |
|
1088 if ( iListBox.MarkingMode() ) |
|
1089 { |
|
1090 state |= MAknMarkingCollection::EStateMarkingMode; |
|
1091 if ( MarkedItems() ) |
|
1092 { |
|
1093 state |= MAknMarkingCollection::EStateMarkedItems; |
|
1094 } |
|
1095 if ( iListBox.Model()->NumberOfItems() == 0 ) |
|
1096 { |
|
1097 state |= MAknMarkingCollection::EStateCollectionEmpty; |
|
1098 } |
|
1099 } |
|
1100 _AKNTRACE_FUNC_EXIT; |
|
1101 return state; |
|
1102 } |
|
1103 |
|
1104 |
|
1105 // ----------------------------------------------------------------------------- |
|
1106 // CListBoxExt::MarkCurrentItemL |
|
1107 // ----------------------------------------------------------------------------- |
|
1108 // |
|
1109 void CListBoxExt::MarkCurrentItemL() |
|
1110 { |
|
1111 _AKNTRACE_FUNC_ENTER; |
|
1112 |
|
1113 if ( iListBox.MarkingMode() ) |
|
1114 { |
|
1115 TInt index = iListBox.CurrentItemIndex(); |
|
1116 if ( index >= 0 && |
|
1117 !iListBox.iItemDrawer->Properties( index ).IsSelectionHidden() ) |
|
1118 { |
|
1119 iListBox.View()->SelectItemL( index ); |
|
1120 } |
|
1121 } |
|
1122 _AKNTRACE_FUNC_EXIT; |
|
1123 } |
|
1124 |
|
1125 |
|
1126 // ----------------------------------------------------------------------------- |
|
1127 // CListBoxExt::MarkAllL |
|
1128 // ----------------------------------------------------------------------------- |
|
1129 // |
|
1130 void CListBoxExt::MarkAllL() |
|
1131 { |
|
1132 _AKNTRACE_FUNC_ENTER; |
|
1133 |
|
1134 if ( iListBox.MarkingMode() && |
|
1135 iListBox.Model()->NumberOfItems() > 0 ) |
|
1136 { |
|
1137 iListBox.View()->SelectAllL( ETrue ); |
|
1138 } |
|
1139 _AKNTRACE_FUNC_EXIT; |
|
1140 } |
|
1141 |
|
1142 |
|
1143 // ----------------------------------------------------------------------------- |
|
1144 // CListBoxExt::UnmarkAll |
|
1145 // ----------------------------------------------------------------------------- |
|
1146 // |
|
1147 void CListBoxExt::UnmarkAll() |
|
1148 { |
|
1149 _AKNTRACE_FUNC_ENTER; |
|
1150 |
|
1151 if ( iListBox.MarkingMode() ) |
|
1152 { |
|
1153 iListBox.View()->ClearSelection(); |
|
1154 } |
|
1155 |
|
1156 _AKNTRACE_FUNC_EXIT; |
|
1157 } |
|
1158 |
|
1159 // ----------------------------------------------------------------------------- |
|
1160 // CListBoxExt::CurrentItemMarkable |
|
1161 // ----------------------------------------------------------------------------- |
|
1162 // |
|
1163 TBool CListBoxExt::CurrentItemMarkable() |
|
1164 { |
|
1165 _AKNTRACE_FUNC_ENTER; |
|
1166 TBool itemCanBeMarked = ETrue; |
|
1167 TInt index = iListBox.CurrentItemIndex(); |
|
1168 if ( index >= 0 && |
|
1169 iListBox.iItemDrawer->Properties( index ).IsSelectionHidden() ) |
|
1170 { |
|
1171 itemCanBeMarked = EFalse; |
|
1172 } |
|
1173 _AKNTRACE_FUNC_EXIT; |
|
1174 return itemCanBeMarked; |
960 } |
1175 } |
961 |
1176 |
962 |
1177 |
963 // --------------------------------------------------------------------------- |
1178 // --------------------------------------------------------------------------- |
964 // CListBoxExt::HandleLongTapEventL |
1179 // CListBoxExt::HandleLongTapEventL |
1033 _AKNTRACE_FUNC_ENTER; |
1249 _AKNTRACE_FUNC_ENTER; |
1034 EnableHighlight( ETrue ); |
1250 EnableHighlight( ETrue ); |
1035 |
1251 |
1036 if ( iListBox.iView->ViewRect() != TRect() ) |
1252 if ( iListBox.iView->ViewRect() != TRect() ) |
1037 { |
1253 { |
1038 TInt topItemIndex = iListBox.iView->TopItemIndex(); |
1254 // Set current item index highlighted if it is visible, otherwise |
1039 if ( iListBox.iView->ItemIsPartiallyVisible( topItemIndex) ) |
1255 // the first visible index |
1040 { |
1256 TInt index = iListBox.iView->CurrentItemIndex(); |
1041 topItemIndex++; |
1257 if ( !iListBox.iView->ItemIsVisible( index ) ) |
1042 } |
1258 { |
1043 TRAP_IGNORE( iListBox.UpdateHighlightL( topItemIndex ) ); |
1259 index = iListBox.iView->TopItemIndex(); |
|
1260 if ( iListBox.iView->ItemIsPartiallyVisible( index ) ) |
|
1261 { |
|
1262 index++; |
|
1263 } |
|
1264 } |
|
1265 TRAP_IGNORE( iListBox.UpdateHighlightL( index ) ); |
1044 } |
1266 } |
1045 |
1267 |
1046 DisableItemSpecificMenu(); |
1268 DisableItemSpecificMenu(); |
1047 if ( iItemActionMenu ) |
1269 if ( iItemActionMenu ) |
1048 { |
1270 { |
1052 iSingleClickEnabled = EFalse; |
1274 iSingleClickEnabled = EFalse; |
1053 |
1275 |
1054 _AKNTRACE_FUNC_EXIT; |
1276 _AKNTRACE_FUNC_EXIT; |
1055 } |
1277 } |
1056 |
1278 |
|
1279 // ----------------------------------------------------------------------------- |
|
1280 // CListBoxExt::EnableSingleClickL |
|
1281 // ----------------------------------------------------------------------------- |
|
1282 // |
|
1283 void CListBoxExt::EnableSingleClickL() |
|
1284 { |
|
1285 _AKNTRACE_FUNC_ENTER; |
|
1286 if ( !iLongTapDetector ) |
|
1287 { |
|
1288 iLongTapDetector = CAknLongTapDetector::NewL( this ); |
|
1289 } |
|
1290 if ( !iItemActionMenu ) |
|
1291 { |
|
1292 iItemActionMenu = CAknItemActionMenu::RegisterCollectionL( |
|
1293 *this, &iListBox ); |
|
1294 iListBox.iListBoxFlags &= ( ~CEikListBox::EDisableItemSpecificMenu ); |
|
1295 } |
|
1296 iSingleClickEnabled = ETrue; |
|
1297 EnableHighlight( EFalse ); |
|
1298 // iListBox.UpdateHighlightL( iListBox.iView->CurrentItemIndex() ); |
|
1299 _AKNTRACE_FUNC_EXIT; |
|
1300 } |
1057 |
1301 |
1058 // ----------------------------------------------------------------------------- |
1302 // ----------------------------------------------------------------------------- |
1059 // CListBoxExt::DisableItemSpecificMenu |
1303 // CListBoxExt::DisableItemSpecificMenu |
1060 // ----------------------------------------------------------------------------- |
1304 // ----------------------------------------------------------------------------- |
1061 // |
1305 // |
1069 iListBox.iListBoxFlags |= CEikListBox::EDisableItemSpecificMenu; |
1313 iListBox.iListBoxFlags |= CEikListBox::EDisableItemSpecificMenu; |
1070 |
1314 |
1071 _AKNTRACE_FUNC_EXIT; |
1315 _AKNTRACE_FUNC_EXIT; |
1072 } |
1316 } |
1073 |
1317 |
|
1318 |
1074 // ----------------------------------------------------------------------------- |
1319 // ----------------------------------------------------------------------------- |
1075 // CListBoxExt::LongTapPointerEventL |
1320 // CListBoxExt::LongTapPointerEventL |
1076 // ----------------------------------------------------------------------------- |
1321 // ----------------------------------------------------------------------------- |
1077 // |
1322 // |
1078 void CListBoxExt::LongTapPointerEventL( const TPointerEvent& aPointerEvent ) |
1323 void CListBoxExt::LongTapPointerEventL( const TPointerEvent& aPointerEvent ) |
1079 { |
1324 { |
1080 if ( iSingleClickEnabled && iLongTapDetector && iItemActionMenu ) |
1325 if ( iSingleClickEnabled && iLongTapDetector && iItemActionMenu ) |
1081 { |
1326 { |
1082 // Send event on down only if no marked items and item specific items |
1327 // Send event on down only if item specific items were found. |
1083 // were found |
1328 // Long tap is also disabled if current item is not marked while |
1084 if ( aPointerEvent.iType != TPointerEvent::EButton1Down |
1329 // there are some marked items or marking mode is active. |
1085 || ( !MarkedItems() && iItemActionMenu->InitMenuL() ) ) |
1330 if ( ( !( ( iListBox.MarkingMode() || MarkedItems() ) |
|
1331 && !iListBox.View()->ItemIsSelected( iListBox.CurrentItemIndex() ) ) |
|
1332 || ( iListBox.iListBoxFlags & CEikListBox::EItemSpecificMenuAlwaysShown ) ) |
|
1333 && ( aPointerEvent.iType != TPointerEvent::EButton1Down |
|
1334 || iItemActionMenu->InitMenuL() ) ) |
1086 { |
1335 { |
1087 iLongTapDetector->PointerEventL ( aPointerEvent ); |
1336 iLongTapDetector->PointerEventL ( aPointerEvent ); |
1088 } |
1337 } |
1089 } |
1338 } |
1090 } |
1339 } |
1181 // |
1430 // |
1182 TBool CListBoxExt::MarkedItems() const |
1431 TBool CListBoxExt::MarkedItems() const |
1183 { |
1432 { |
1184 return ( iListBox.iListBoxFlags & CEikListBox::ES60StyleMarkable |
1433 return ( iListBox.iListBoxFlags & CEikListBox::ES60StyleMarkable |
1185 || iListBox.iListBoxFlags & CEikListBox::EMultipleSelection ) |
1434 || iListBox.iListBoxFlags & CEikListBox::EMultipleSelection ) |
1186 && iListBox.SelectionIndexes()->Count() > 0; |
1435 && iListBox.iView && iListBox.SelectionIndexes()->Count() > 0; |
|
1436 } |
|
1437 |
|
1438 |
|
1439 // ----------------------------------------------------------------------------- |
|
1440 // CListBoxExt::IgnorePointerEventsUntilUp |
|
1441 // ----------------------------------------------------------------------------- |
|
1442 // |
|
1443 TBool CListBoxExt::IgnorePointerEventsUntilUp() |
|
1444 { |
|
1445 _AKNTRACE_FUNC_ENTER; |
|
1446 |
|
1447 // Pointer event ignore must be done for the window-owning |
|
1448 // control or it doesn't have any effect! |
|
1449 CCoeControl* windowOwningControl = &iListBox; |
|
1450 |
|
1451 while ( windowOwningControl && !windowOwningControl->OwnsWindow() ) |
|
1452 { |
|
1453 windowOwningControl = windowOwningControl->Parent(); |
|
1454 } |
|
1455 |
|
1456 if ( windowOwningControl ) |
|
1457 { |
|
1458 windowOwningControl->IgnoreEventsUntilNextPointerUp(); |
|
1459 } |
|
1460 _AKNTRACE_FUNC_EXIT; |
|
1461 return ( windowOwningControl != NULL ); |
1187 } |
1462 } |
1188 |
1463 |
1189 |
1464 |
1190 // ----------------------------------------------------------------------------- |
1465 // ----------------------------------------------------------------------------- |
1191 // CListBoxExt::StartLongPressTimerL |
1466 // CListBoxExt::StartLongPressTimerL |
1557 void CListBoxExt::PhysicEmulationEnded() |
1832 void CListBoxExt::PhysicEmulationEnded() |
1558 { |
1833 { |
1559 _AKNTRACE_FUNC_ENTER; |
1834 _AKNTRACE_FUNC_ENTER; |
1560 if ( iScrolling ) |
1835 if ( iScrolling ) |
1561 { |
1836 { |
|
1837 // currently, this is the only way to fix ou1cimx1#375869 |
|
1838 // iViewPosision is changed but we can't provent that |
|
1839 if ( iListBox.iView->TopItemIndex() == 0 |
|
1840 && iListBox.iView->ItemOffsetInPixels() > 0 ) |
|
1841 { |
|
1842 iListBox.ScrollView( -iListBox.iView->ItemOffsetInPixels(), ETrue ); |
|
1843 } |
1562 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1844 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1563 iListBox.SuspendEffects( EFalse ); |
1845 iListBox.SuspendEffects( EFalse ); |
1564 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
1846 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
1565 TRAP_IGNORE( iListBox.ReportListBoxEventL( |
1847 TRAP_IGNORE( iListBox.ReportListBoxEventL( |
1566 MEikListBoxObserver::EEventFlickStopped ) ); |
1848 MEikListBoxObserver::EEventFlickStopped ) ); |
1583 { |
1865 { |
1584 // calculate view center based on CEikListBoxView::iTopItemIndex |
1866 // calculate view center based on CEikListBoxView::iTopItemIndex |
1585 TInt topItemIndex = iListBox.iView->TopItemIndex(); |
1867 TInt topItemIndex = iListBox.iView->TopItemIndex(); |
1586 TInt itemHeight = iListBox.iView->ItemHeight(); |
1868 TInt itemHeight = iListBox.iView->ItemHeight(); |
1587 TInt numberOfItems = iListBox.iModel->NumberOfItems(); |
1869 TInt numberOfItems = iListBox.iModel->NumberOfItems(); |
1588 |
1870 TInt emptySpaceOffset ( 0 ); |
|
1871 |
1589 TSize viewSize( iListBox.iView->ViewRect().Size() ); |
1872 TSize viewSize( iListBox.iView->ViewRect().Size() ); |
1590 TSize worldSize( viewSize.iWidth, itemHeight * numberOfItems ); |
1873 TSize worldSize( viewSize.iWidth, itemHeight * numberOfItems ); |
1591 |
1874 |
1592 // grid has several items in one line |
1875 // grid has several items in one line |
1593 if ( iItemsInSingleLine > 1 ) |
1876 if ( iItemsInSingleLine > 1 ) |
1598 // handle non-full grid row |
1881 // handle non-full grid row |
1599 if ( numberOfItems % iItemsInSingleLine ) |
1882 if ( numberOfItems % iItemsInSingleLine ) |
1600 { |
1883 { |
1601 worldSize.iHeight += itemHeight; |
1884 worldSize.iHeight += itemHeight; |
1602 } |
1885 } |
|
1886 |
|
1887 // Check empty space below the grid |
|
1888 if ( topItemIndex != 0 ) |
|
1889 { |
|
1890 TInt lastItemBottomY = |
|
1891 iListBox.iView->ItemPos( |
|
1892 numberOfItems - 1 ).iY + itemHeight +1; |
|
1893 emptySpaceOffset = Min( 0, lastItemBottomY - viewSize.iHeight ); |
|
1894 } |
1603 } |
1895 } |
1604 |
1896 |
1605 // Reset offset if view's size has changed - this is needed if e.g. |
1897 // Reset offset if view's size has changed - this is needed if e.g. |
1606 // HandleResourceChange is overridden by a derived implementation. |
1898 // HandleResourceChange is overridden by a derived implementation. |
1607 if ( viewSize != iViewSize && iViewSize != TSize( 0, 0 ) ) |
1899 if ( viewSize != iViewSize && iViewSize != TSize( 0, 0 ) ) |
1608 { |
1900 { |
1609 iListBox.iView->SetItemOffsetInPixels( 0 ); |
1901 iListBox.iView->SetItemOffsetInPixels( 0 ); |
1610 } |
1902 } |
1611 |
1903 |
1612 TPoint viewCenter( viewSize.iWidth / 2, ( topItemIndex / iItemsInSingleLine ) * itemHeight - iListBox.iView->ItemOffsetInPixels() + ( viewSize.iHeight / 2 ) ); |
1904 TPoint viewCenter( viewSize.iWidth / 2, ( topItemIndex / iItemsInSingleLine ) * itemHeight - iListBox.iView->ItemOffsetInPixels() + ( viewSize.iHeight / 2 ) ); |
|
1905 viewCenter.iY += emptySpaceOffset; |
1613 |
1906 |
1614 // Make sure that world's size is always at least view size. |
1907 // Make sure that world's size is always at least view size. |
1615 worldSize.iHeight = Max( worldSize.iHeight, viewSize.iHeight ); |
1908 worldSize.iHeight = Max( worldSize.iHeight, viewSize.iHeight ); |
1616 |
1909 |
1617 iPhysics->InitPhysicsL( worldSize, viewSize, EFalse ); |
1910 iPhysics->InitPhysicsL( worldSize, viewSize, EFalse ); |
1713 } |
2006 } |
1714 _AKNTRACE_FUNC_EXIT; |
2007 _AKNTRACE_FUNC_EXIT; |
1715 } |
2008 } |
1716 |
2009 |
1717 // --------------------------------------------------------------------------- |
2010 // --------------------------------------------------------------------------- |
1718 // CListBoxExt::FeedbackEnabledOnUpEvent |
2011 // Checks whether or not tactile feedback should be given on a pointer |
|
2012 // up event. |
1719 // --------------------------------------------------------------------------- |
2013 // --------------------------------------------------------------------------- |
1720 // |
2014 // |
1721 TBool CListBoxExt::FeedbackEnabledOnUpEvent() |
2015 TBool CListBoxExt::FeedbackEnabledOnUpEvent() |
1722 { |
2016 { |
1723 _AKNTRACE_FUNC_ENTER; |
2017 _AKNTRACE_FUNC_ENTER; |
1724 TBool enabled( EFalse ); |
2018 TBool enabled( EFalse ); |
1725 if ( ( iListBox.iItemDrawer->Flags() & CListItemDrawer::EPressedDownState ) && |
2019 |
1726 !iFlickStopped ) |
2020 // As there's no pressed down highlight in single click enabled lists, |
|
2021 // the iLastDownTappedItem is used to track whether or not the pointer |
|
2022 // up event happened inside the same list item as the pointer down event. |
|
2023 // Feedback should not be given if the pointer up is received outside of |
|
2024 // the item that received the pointer down event, or in cases when the |
|
2025 // list has been dragged or flicked between the pointer down and pointer |
|
2026 // up events. |
|
2027 if ( ( iListBox.iItemDrawer->Flags() & CListItemDrawer::EPressedDownState |
|
2028 || ( iSingleClickEnabled && iLastDownTappedItem != KErrNotFound ) ) && |
|
2029 !iFlickStopped ) |
1727 { |
2030 { |
1728 enabled = ETrue; |
2031 enabled = ETrue; |
1729 } |
2032 } |
|
2033 |
1730 _AKNTRACE_FUNC_EXIT; |
2034 _AKNTRACE_FUNC_EXIT; |
1731 return enabled; |
2035 return enabled; |
1732 } |
2036 } |
1733 |
2037 |
1734 // --------------------------------------------------------------------------- |
2038 // --------------------------------------------------------------------------- |
2081 // Current item not visible or current item is the last item (not fully visible) |
2402 // Current item not visible or current item is the last item (not fully visible) |
2082 if ( !iView->ItemIsVisible(currentItemIndex) |
2403 if ( !iView->ItemIsVisible(currentItemIndex) |
2083 || iListBoxExt && iListBoxExt->iPhysics |
2404 || iListBoxExt && iListBoxExt->iPhysics |
2084 && currentItemIndex == ( topItemIndex + numberOfItems - 1 ) ) |
2405 && currentItemIndex == ( topItemIndex + numberOfItems - 1 ) ) |
2085 { |
2406 { |
2086 newTopItemIndex = iView->CalcNewTopItemIndexSoItemIsVisible( currentItemIndex ); |
2407 if ( iListBoxExt && iListBoxExt->iSingleClickEnabled ) |
|
2408 { |
|
2409 TInt offset = (iListBoxExt->iWorldSize.iHeight / 2) |
|
2410 - iListBoxExt->iViewPosition.iY; |
|
2411 TInt itemsInRect = |
|
2412 iView->NumberOfItemsThatFitInRect( iView->ViewRect() ); |
|
2413 |
|
2414 if ( ( iListBoxExt->CollectionState() |
|
2415 & MAknCollection::EStateHighlightVisible ) |
|
2416 || ( ItemsInSingleLine() |
|
2417 && ( totalItems <= itemsInRect ) |
|
2418 && ( offset != 0 ) ) ) |
|
2419 { |
|
2420 newTopItemIndex = iView->CalcNewTopItemIndexSoItemIsVisible( currentItemIndex ); |
|
2421 } |
|
2422 else |
|
2423 { |
|
2424 newTopItemIndex = iView->CalcNewTopItemIndexSoItemIsVisible( topItemIndex ); |
|
2425 } |
|
2426 } |
|
2427 else |
|
2428 { |
|
2429 newTopItemIndex = iView->CalcNewTopItemIndexSoItemIsVisible( currentItemIndex ); |
|
2430 } |
2087 } |
2431 } |
2088 else |
2432 else |
2089 { |
2433 { |
2090 // recalculates top index of list when mode be changed |
2434 // recalculates top index of list when mode be changed |
2091 TInt totalItems = iModel->NumberOfItems(); |
|
2092 if ( (totalItems - topItemIndex) < numberOfItems ) |
2435 if ( (totalItems - topItemIndex) < numberOfItems ) |
2093 { |
2436 { |
2094 newTopItemIndex = Max( 0, totalItems - numberOfItems ); |
2437 newTopItemIndex = Max( 0, totalItems - numberOfItems ); |
2095 } |
2438 } |
2096 } |
2439 } |
2097 |
2440 |
2098 if ( newTopItemIndex != KEikListBoxInvalidIndex ) |
2441 if ( newTopItemIndex > KEikListBoxInvalidIndex |
|
2442 && newTopItemIndex < totalItems ) |
2099 { |
2443 { |
2100 iView->SetTopItemIndex( newTopItemIndex ); |
2444 iView->SetTopItemIndex( newTopItemIndex ); |
2101 if ( iListBoxExt && iListBoxExt->iPhysics ) |
2445 } |
2102 { |
2446 if ( iListBoxExt && iListBoxExt->iPhysics ) |
2103 iListBoxExt->InitPhysicsL(); |
2447 { |
2104 } |
2448 iListBoxExt->InitPhysicsL(); |
2105 } |
2449 } |
2106 } |
2450 } |
2107 UpdateScrollBarsL(); |
2451 UpdateScrollBarsL(); |
2108 _AKNTRACE_FUNC_EXIT; |
2452 _AKNTRACE_FUNC_EXIT; |
2109 } |
2453 } |
2852 RestoreClientRectFromViewRect(clientRect); |
3199 RestoreClientRectFromViewRect(clientRect); |
2853 TRect inclusiveRect=Rect(); |
3200 TRect inclusiveRect=Rect(); |
2854 TEikScrollBarFrameLayout layout; |
3201 TEikScrollBarFrameLayout layout; |
2855 CreateScrollBarFrameLayout(layout); |
3202 CreateScrollBarFrameLayout(layout); |
2856 TBool sizeChanged=iSBFrame->TileL(&hSbarModel, &vSbarModel, clientRect, inclusiveRect, layout); |
3203 TBool sizeChanged=iSBFrame->TileL(&hSbarModel, &vSbarModel, clientRect, inclusiveRect, layout); |
2857 if (iListBoxExt->UpdateScrollBarsColors()) |
3204 if ( iListBoxExt && iListBoxExt->UpdateScrollBarsColors() ) |
2858 UpdateScrollBarsColors(); |
3205 UpdateScrollBarsColors(); |
2859 if (!sizeChanged) |
3206 if (!sizeChanged) |
2860 return; |
3207 return; |
2861 // else size of client/inclusive rect has changed |
3208 // else size of client/inclusive rect has changed |
2862 if (layout.iTilingMode==TEikScrollBarFrameLayout::EClientRectConstant) |
3209 if (layout.iTilingMode==TEikScrollBarFrameLayout::EClientRectConstant) |
3021 TRAPD( err, bgc->AddCommandToStackL( 3, newResourceId ) ); |
3364 TRAPD( err, bgc->AddCommandToStackL( 3, newResourceId ) ); |
3022 // in case of error, don't inform observers |
3365 // in case of error, don't inform observers |
3023 // marking still works even MSK isn't changed |
3366 // marking still works even MSK isn't changed |
3024 if ( err ) |
3367 if ( err ) |
3025 { |
3368 { |
3026 iListBoxExt->iSelectionModeEnabled = EFalse; |
3369 if ( iListBoxExt ) |
|
3370 { |
|
3371 iListBoxExt->iSelectionModeEnabled = EFalse; |
|
3372 } |
3027 _AKNTRACE_FUNC_EXIT; |
3373 _AKNTRACE_FUNC_EXIT; |
3028 return; |
3374 return; |
3029 } |
3375 } |
3030 cba->DrawNow(); |
3376 cba->DrawNow(); |
3031 iListBoxExt->iSelectionModeEnabled = ETrue; |
3377 if ( iListBoxExt ) |
|
3378 { |
|
3379 iListBoxExt->iSelectionModeEnabled = ETrue; |
|
3380 } |
3032 } |
3381 } |
3033 |
3382 |
3034 // remove stacked MSK |
3383 // remove stacked MSK |
3035 if( !aEnable && iListBoxExt->iSelectionModeEnabled ) |
3384 if( !aEnable && iListBoxExt && iListBoxExt->iSelectionModeEnabled ) |
3036 { |
3385 { |
3037 if( ( MSK && cba->ControlId( MSK ) == EAknSoftkeyMark ) || |
3386 if( ( MSK && cba->ControlId( MSK ) == EAknSoftkeyMark ) || |
3038 ( MSK && cba->ControlId( MSK ) == EAknSoftkeyUnmark ) ) |
3387 ( MSK && cba->ControlId( MSK ) == EAknSoftkeyUnmark ) ) |
3039 { |
3388 { |
3040 bgc->RemoveCommandFromStack( 3, cba->ControlId( MSK ) ); |
3389 bgc->RemoveCommandFromStack( 3, cba->ControlId( MSK ) ); |
3041 } |
3390 } |
3042 iListBoxExt->iSelectionModeEnabled = EFalse; // just in case |
3391 iListBoxExt->iSelectionModeEnabled = EFalse; // just in case |
3043 } |
3392 } |
3044 |
3393 if ( iListBoxExt ) |
3045 TInt count = iListBoxExt->iSelectionObservers.Count(); |
3394 { |
3046 for ( int i=0; i < count; i++ ) |
3395 TInt count = iListBoxExt->iSelectionObservers.Count(); |
3047 { |
3396 for ( int i=0; i < count; i++ ) |
3048 iListBoxExt->iSelectionObservers[i]->SelectionModeChanged( this, aEnable ); |
3397 { |
|
3398 iListBoxExt->iSelectionObservers[i]->SelectionModeChanged( this, aEnable ); |
|
3399 } |
3049 } |
3400 } |
3050 _AKNTRACE_FUNC_EXIT; |
3401 _AKNTRACE_FUNC_EXIT; |
3051 } |
3402 } |
3052 |
3403 |
3053 |
3404 |
3143 } |
3504 } |
3144 |
3505 |
3145 EXPORT_C void CEikListBox::HandleItemAdditionL() |
3506 EXPORT_C void CEikListBox::HandleItemAdditionL() |
3146 { |
3507 { |
3147 _AKNTRACE_FUNC_ENTER; |
3508 _AKNTRACE_FUNC_ENTER; |
3148 //fix the bug EGGO-7SQA4S and EVSG-7TD9WZ |
3509 __ASSERT_DEBUG( iView, Panic( EEikPanicListBoxNoView ) ); |
|
3510 |
3149 TInt curItemIndex = iView->CurrentItemIndex(); |
3511 TInt curItemIndex = iView->CurrentItemIndex(); |
3150 if(curItemIndex >= 0 && curItemIndex < iModel->NumberOfItems() ) |
3512 if(curItemIndex >= 0 && curItemIndex < iModel->NumberOfItems() ) |
3151 { |
3513 { |
3152 TInt newTopItemIndex = iView->CalcNewTopItemIndexSoItemIsVisible( curItemIndex ); |
3514 TInt newTopItemIndex = iView->CalcNewTopItemIndexSoItemIsVisible( curItemIndex ); |
3153 iView->SetTopItemIndex( newTopItemIndex ); |
3515 iView->SetTopItemIndex( newTopItemIndex ); |
3154 } |
3516 } |
3155 iView->SetFlags(CListBoxView::EItemCountModified); |
3517 iView->SetFlags(CListBoxView::EItemCountModified); |
3156 // following breaks lists in square layout, not needed in SERIES60? |
3518 |
3157 //iView->CalcDataWidth(); |
|
3158 iView->CalcBottomItemIndex(); |
3519 iView->CalcBottomItemIndex(); |
3159 UpdateScrollBarsL(); |
3520 UpdateScrollBarsL(); |
3160 UpdateScrollBarThumbs(); |
3521 UpdateScrollBarThumbs(); |
3161 if (IsReadyToDraw()) DrawDeferred(); |
3522 if (IsReadyToDraw()) DrawDeferred(); |
3162 iView->ClearFlags(CListBoxView::EItemCountModified); |
3523 iView->ClearFlags(CListBoxView::EItemCountModified); |
3163 |
3524 |
3164 FireItemChange(); |
3525 FireItemChange(); |
3165 |
3526 |
3166 if ( iListBoxExt ) |
3527 if ( iListBoxExt ) |
3167 { |
3528 { |
3168 iListBoxExt->CheckScrollBarVisibility(); |
3529 iListBoxExt->CheckScrollBarVisibility(); |
3169 // Physics engine world size needs to be updated here, otherwise aknphysics |
3530 // Physics engine world size needs to be updated here, otherwise aknphysics |
3170 // cone observer may block pointer events on new items. this can happen |
3531 // cone observer may block pointer events on new items. this can happen |
3171 // when item addition inserts new row to taskswapper's grid and reuses list in Common Dialog |
3532 // when item addition inserts new row to taskswapper's grid and reuses list in Common Dialog |
3172 if ( iListBoxExt->iPhysics ) |
3533 if ( iListBoxExt->iPhysics ) |
3173 { |
3534 { |
3174 iListBoxExt->InitPhysicsL(); |
3535 iListBoxExt->InitPhysicsL(); |
3175 } |
3536 } |
3176 } |
3537 |
|
3538 if ( iListBoxExt->iItemActionMenu && |
|
3539 iListBoxExt->iLongTappedItem != KErrNotFound ) |
|
3540 { |
|
3541 // Item action menu is being shown and it needs to be closed when |
|
3542 // items are added or removed to the list array, otherwise the |
|
3543 // item specific commands may be targeted to the wrong item. |
|
3544 iListBoxExt->iItemActionMenu->HideMenu(); |
|
3545 } |
|
3546 } |
|
3547 |
3177 _AKNTRACE_FUNC_EXIT; |
3548 _AKNTRACE_FUNC_EXIT; |
3178 } |
3549 } |
3179 |
3550 |
3180 EXPORT_C void CEikListBox::HandleItemRemovalL() |
3551 EXPORT_C void CEikListBox::HandleItemRemovalL() |
3181 { |
3552 { |
3352 } |
3723 } |
3353 else |
3724 else |
3354 { |
3725 { |
3355 selectionMode = CListBoxView::ENoSelection; |
3726 selectionMode = CListBoxView::ENoSelection; |
3356 UpdateMarkUnmarkMSKL(); |
3727 UpdateMarkUnmarkMSKL(); |
3357 if (IsSelectionMarkKeys(code, aKeyEvent.iScanCode, iListBoxExt->iWesternVariant)) |
3728 if ( iListBoxExt |
|
3729 && IsSelectionMarkKeys( code, aKeyEvent.iScanCode, iListBoxExt->iWesternVariant ) ) |
3358 { |
3730 { |
3359 __KeyDebug(ETrue, "SelectionMarkKey") |
3731 __KeyDebug(ETrue, "SelectionMarkKey") |
3360 View()->ClearSelectionAnchorAndActiveIndex(); |
3732 View()->ClearSelectionAnchorAndActiveIndex(); |
3361 } |
3733 } |
3362 } |
3734 } |
3363 } |
3735 } |
3364 |
3736 |
3365 |
3737 |
3366 // CAknGrid marking is implemeted in avkon.dll. But we still need to disable short |
3738 // CAknGrid marking is implemeted in avkon.dll. But we still need to disable short |
3367 // hash mark in here. |
3739 // hash mark in here. |
3368 if ( iListBoxFlags & EMultipleSelection && |
3740 if ( iListBoxExt && iListBoxFlags & EMultipleSelection && |
3369 iListBoxFlags & EShiftEnterMarks && aType == EEventKeyUp ) |
3741 iListBoxFlags & EShiftEnterMarks && aType == EEventKeyUp ) |
3370 { |
3742 { |
3371 if ( aKeyEvent.iScanCode == EStdKeyLeftArrow || |
3743 if ( aKeyEvent.iScanCode == EStdKeyLeftArrow || |
3372 aKeyEvent.iScanCode == EStdKeyUpArrow || |
3744 aKeyEvent.iScanCode == EStdKeyUpArrow || |
3373 aKeyEvent.iScanCode == EStdKeyRightArrow || |
3745 aKeyEvent.iScanCode == EStdKeyRightArrow || |
3768 // This code block watches for hash key presses, and simulates shift + ok |
4142 // This code block watches for hash key presses, and simulates shift + ok |
3769 // if short hash key presses are used for selections. The events are simulated |
4143 // if short hash key presses are used for selections. The events are simulated |
3770 // only if a markable list is active, otherwise the simulated event might open |
4144 // only if a markable list is active, otherwise the simulated event might open |
3771 // the selected item, which we don't want. |
4145 // the selected item, which we don't want. |
3772 if((iListBoxFlags & EMultipleSelection) && (iListBoxFlags & EShiftEnterMarks) && |
4146 if((iListBoxFlags & EMultipleSelection) && (iListBoxFlags & EShiftEnterMarks) && |
3773 iListBoxExt->iWesternVariant && |
4147 iListBoxExt && iListBoxExt->iWesternVariant && |
3774 iListBoxExt->iAknFepHashKeySelection && |
4148 iListBoxExt->iAknFepHashKeySelection && |
3775 iListBoxExt->iQwertyMode == EFalse && |
4149 iListBoxExt->iQwertyMode == EFalse && |
3776 aType == EEventKeyUp && aKeyEvent.iScanCode == EStdKeyHash && |
4150 aType == EEventKeyUp && aKeyEvent.iScanCode == EStdKeyHash && |
3777 IsFocused() ) |
4151 IsFocused() ) |
3778 { |
4152 { |
3869 switch ( aEvent ) |
4243 switch ( aEvent ) |
3870 { |
4244 { |
3871 case MEikListBoxObserver::EEventFlickStarted: |
4245 case MEikListBoxObserver::EEventFlickStarted: |
3872 case MEikListBoxObserver::EEventPanningStarted: |
4246 case MEikListBoxObserver::EEventPanningStarted: |
3873 { |
4247 { |
|
4248 if ( iListBoxExt && ( iListBoxExt->iWorldSize.iHeight |
|
4249 <= iListBoxExt->iViewSize.iHeight ) ) |
|
4250 { |
|
4251 return; |
|
4252 } |
3874 iItemDrawer->SetFlags( CListItemDrawer::EDisableMarquee ); |
4253 iItemDrawer->SetFlags( CListItemDrawer::EDisableMarquee ); |
3875 if ( aEvent == MEikListBoxObserver::EEventFlickStarted ) |
4254 if ( iListBoxExt ) |
3876 iListBoxExt->SetFlickOngoing( ETrue ); |
4255 { |
3877 else |
4256 if ( aEvent == MEikListBoxObserver::EEventFlickStarted ) |
3878 iListBoxExt->SetPanningOngoing( ETrue ); |
4257 { |
|
4258 iListBoxExt->SetFlickOngoing( ETrue ); |
|
4259 } |
|
4260 else |
|
4261 { |
|
4262 iListBoxExt->SetPanningOngoing( ETrue ); |
|
4263 } |
|
4264 } |
3879 break; |
4265 break; |
3880 } |
4266 } |
3881 |
4267 |
3882 case MEikListBoxObserver::EEventFlickStopped: |
4268 case MEikListBoxObserver::EEventFlickStopped: |
3883 case MEikListBoxObserver::EEventPanningStopped: |
4269 case MEikListBoxObserver::EEventPanningStopped: |
3884 { |
4270 { |
|
4271 if ( iListBoxExt && ( iListBoxExt->iWorldSize.iHeight |
|
4272 <= iListBoxExt->iViewSize.iHeight ) ) |
|
4273 { |
|
4274 return; |
|
4275 } |
3885 iItemDrawer->ClearFlags( CListItemDrawer::EDisableMarquee ); |
4276 iItemDrawer->ClearFlags( CListItemDrawer::EDisableMarquee ); |
3886 if ( aEvent == MEikListBoxObserver::EEventFlickStopped ) |
4277 if ( iListBoxExt ) |
3887 { |
4278 { |
3888 iListBoxExt->SetFlickOngoing( EFalse ); |
4279 if ( aEvent == MEikListBoxObserver::EEventFlickStopped ) |
3889 } |
4280 { |
3890 else |
4281 iListBoxExt->SetFlickOngoing( EFalse ); |
3891 { |
4282 } |
3892 iListBoxExt->SetPanningOngoing( EFalse ); |
4283 else |
3893 } |
4284 { |
3894 |
4285 iListBoxExt->SetPanningOngoing( EFalse ); |
|
4286 } |
|
4287 } |
3895 break; |
4288 break; |
3896 } |
4289 } |
3897 } |
4290 } |
3898 |
4291 |
3899 if ( iListBoxObserver ) |
4292 if ( iListBoxObserver ) |
3900 { |
4293 { |
3901 TBool allowed = ETrue; |
4294 TBool allowed = ETrue; |
3902 |
4295 |
3903 if ( iListBoxExt && iListBoxExt->iPhysics |
4296 if ( iListBoxExt && iListBoxExt->iPhysics |
3904 && aEvent != MEikListBoxObserver::EEventFlickStopped ) |
4297 && aEvent != MEikListBoxObserver::EEventFlickStopped |
|
4298 && aEvent != MEikListBoxObserver::EEventFlickStarted ) |
3905 { |
4299 { |
3906 allowed = iListBoxExt->iClickEventsAllowed; |
4300 allowed = iListBoxExt->iClickEventsAllowed; |
|
4301 } |
|
4302 |
|
4303 if ( MarkingMode() && allowed ) |
|
4304 { |
|
4305 switch ( aEvent ) |
|
4306 { |
|
4307 case MEikListBoxObserver::EEventItemSingleClicked: |
|
4308 case MEikListBoxObserver::EEventEnterKeyPressed: |
|
4309 { |
|
4310 TInt index = CurrentItemIndex(); |
|
4311 if ( index >= 0 && |
|
4312 !iItemDrawer->Properties(index).IsSelectionHidden() ) |
|
4313 { |
|
4314 iView->ToggleItemL( iView->CurrentItemIndex() ); |
|
4315 } |
|
4316 |
|
4317 allowed = EFalse; |
|
4318 } |
|
4319 break; |
|
4320 |
|
4321 default: |
|
4322 break; |
|
4323 } |
3907 } |
4324 } |
3908 |
4325 |
3909 if ( allowed ) |
4326 if ( allowed ) |
3910 { |
4327 { |
3911 iListBoxObserver->HandleListBoxEventL(this, aEvent); |
4328 iListBoxObserver->HandleListBoxEventL(this, aEvent); |
4096 MAknListBoxTfxInternal::EListScrollUp : |
4513 MAknListBoxTfxInternal::EListScrollUp : |
4097 MAknListBoxTfxInternal::EListScrollDown ); |
4514 MAknListBoxTfxInternal::EListScrollDown ); |
4098 } |
4515 } |
4099 #endif |
4516 #endif |
4100 |
4517 |
4101 if ( iListBoxExt->iPhysics ) |
4518 if ( iListBoxExt && iListBoxExt->iPhysics ) |
4102 { |
4519 { |
4103 iListBoxExt->InitPhysicsL(); |
4520 iListBoxExt->InitPhysicsL(); |
4104 TInt deltaPixels = newThumbPos; |
4521 TInt deltaPixels = newThumbPos; |
4105 |
4522 |
4106 #ifdef _DEBUG |
4523 #ifdef _DEBUG |
4107 RDebug::Print( _L( "CListBox::HandleScrollEventL, deltaPixels = %d" ), deltaPixels ); |
4524 RDebug::Print( _L( "CListBox::HandleScrollEventL, deltaPixels = %d" ), deltaPixels ); |
4108 #endif // _DEBUG |
4525 #endif // _DEBUG |
4109 |
4526 |
4110 TPoint newPosition( iListBoxExt->iViewPosition.iX, deltaPixels + iView->ViewRect().Height() / 2 ); |
4527 TPoint newPosition( iListBoxExt->iViewPosition.iX, deltaPixels + iView->ViewRect().Height() / 2 ); |
4111 iListBoxExt->ViewPositionChanged( newPosition ); |
4528 iListBoxExt->ViewPositionChanged( newPosition ); |
4112 } |
4529 } |
4113 else |
4530 else |
4114 { |
4531 { |
4115 iView->VScrollTo(newThumbPos/iView->ItemHeight()); |
4532 iView->VScrollTo(newThumbPos/iView->ItemHeight()); |
4116 } |
4533 } |
4633 // Return always if list empty to avoid tactile feedback |
5051 // Return always if list empty to avoid tactile feedback |
4634 _AKNTRACE_FUNC_EXIT; |
5052 _AKNTRACE_FUNC_EXIT; |
4635 return; |
5053 return; |
4636 } |
5054 } |
4637 |
5055 |
4638 |
|
4639 // When in marking mode, pointer events should not be forwarded to |
|
4640 // long tap detector, this boolean indicates if marking mode is active |
|
4641 TBool markingMode( iListBoxExt->MarkedItems() ); |
|
4642 |
|
4643 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
5056 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
4644 { |
5057 { |
4645 if ( iListBoxExt->iSingleClickEnabled && |
5058 if ( iListBoxExt->iSingleClickEnabled && |
4646 itemIndex != iView->CurrentItemIndex() ) |
5059 itemIndex != iView->CurrentItemIndex() ) |
4647 { |
5060 { |
4648 iListBoxExt->EnableHighlight( EFalse ); |
5061 iListBoxExt->EnableHighlight( EFalse ); |
4649 iView->DrawItem( iView->CurrentItemIndex() ); |
5062 iView->DrawItem( iView->CurrentItemIndex() ); |
4650 } |
5063 } |
4651 |
5064 |
4652 iListBoxExt->iFeedbackType = ETouchFeedbackBasicItem; |
5065 iListBoxExt->iFeedbackType = ETouchFeedbackList; |
4653 |
5066 iListBoxExt->iDoubleClickEventIgnored = EFalse; |
4654 if ( itemIndex != iView->CurrentItemIndex() || |
5067 |
4655 iListBoxFlags & ES60StyleMultiselection ) |
5068 if ( !iListBoxExt->iSingleClickEnabled && |
4656 { |
5069 itemIndex != iView->CurrentItemIndex() ) |
4657 iListBoxExt->iFeedbackType = ETouchFeedbackSensitiveItem; |
5070 { |
|
5071 iListBoxExt->iFeedbackType = ETouchFeedbackSensitiveList; |
4658 } |
5072 } |
4659 |
5073 |
4660 if ( iListBoxExt->iPhysics && |
5074 if ( iListBoxExt->iPhysics && |
4661 iListBoxExt->iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionFlicking ) |
5075 iListBoxExt->iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionFlicking ) |
4662 { |
5076 { |
4663 iListBoxExt->iFeedbackType = ETouchFeedbackBasicItem; |
5077 iListBoxExt->iFeedbackType = ETouchFeedbackList; |
4664 } |
|
4665 |
|
4666 if ( !iListBoxExt->iPhysics || itemIndex == iView->CurrentItemIndex() ) |
|
4667 { |
|
4668 iListBoxExt->ImmediateFeedback( iListBoxExt->iFeedbackType, |
|
4669 TTouchFeedbackType(ETouchFeedbackVibra | ETouchFeedbackAudio), |
|
4670 aPointerEvent ); |
|
4671 } |
5078 } |
4672 } |
5079 } |
4673 iListBoxExt->iEventModifiers = aPointerEvent.iModifiers; |
5080 iListBoxExt->iEventModifiers = aPointerEvent.iModifiers; |
4674 CListBoxView::TSelectionMode selectionMode = CListBoxView::ENoSelection; |
5081 CListBoxView::TSelectionMode selectionMode = CListBoxView::ENoSelection; |
4675 TBool shiftKeyPressed = EFalse; |
5082 TBool shiftKeyPressed = EFalse; |
4755 { |
5163 { |
4756 case TPointerEvent::EButton1Down: |
5164 case TPointerEvent::EButton1Down: |
4757 _AKNTRACE("TPointerEvent::EButton1Down"); |
5165 _AKNTRACE("TPointerEvent::EButton1Down"); |
4758 // For drag outside listbox |
5166 // For drag outside listbox |
4759 iListBoxExt->iIsDownOnItem = pointerIsOverAnItem; |
5167 iListBoxExt->iIsDownOnItem = pointerIsOverAnItem; |
4760 iListBoxExt->iLastPoint = pointerPos; |
5168 iListBoxExt->iLastPoint = pointerPos; |
|
5169 iListBoxExt->iLongTappedItem = KErrNotFound; |
4761 |
5170 |
4762 // update index of the last down tapped item |
5171 // update index of the last down tapped item |
4763 iListBoxExt->iLastDownTappedItem = itemIndex; |
5172 iListBoxExt->iLastDownTappedItem = itemIndex; |
|
5173 iListBoxExt->iMarkableListShiftKeyPressed = EFalse; |
4764 |
5174 |
4765 if ((! (Rect().Contains(aPointerEvent.iPosition))) && (iListBoxFlags & EPopout)) |
5175 if ((! (Rect().Contains(aPointerEvent.iPosition))) && (iListBoxFlags & EPopout)) |
4766 { |
5176 { |
4767 ReportEventL(MCoeControlObserver::EEventRequestCancel); |
5177 ReportEventL(MCoeControlObserver::EEventRequestCancel); |
4768 iListBoxExt->iEventModifiers = 0; |
5178 iListBoxExt->iEventModifiers = 0; |
4801 { |
5211 { |
4802 iListBoxExt->EnableHighlight( ETrue, ETrue ); |
5212 iListBoxExt->EnableHighlight( ETrue, ETrue ); |
4803 UpdateHighlightL( itemIndex ); |
5213 UpdateHighlightL( itemIndex ); |
4804 CCoeEnv::Static()->WsSession().Finish(); |
5214 CCoeEnv::Static()->WsSession().Finish(); |
4805 } |
5215 } |
4806 if ( itemIndex != oldCurrentItemIndex ) |
5216 |
|
5217 if ( !( ( iListBoxFlags & EViewerFlag ) && |
|
5218 ( iListBoxFlags & EDisableItemSpecificMenu ) ) ) |
4807 { |
5219 { |
4808 iListBoxExt->ImmediateFeedback( |
5220 iListBoxExt->ImmediateFeedback( |
4809 iListBoxExt->iFeedbackType, |
5221 iListBoxExt->iFeedbackType, |
4810 TTouchFeedbackType( ETouchFeedbackVibra | |
5222 TTouchFeedbackType( ETouchFeedbackVibra | |
4811 ETouchFeedbackAudio ), |
5223 ETouchFeedbackAudio ), |
4812 aPointerEvent ); |
5224 aPointerEvent ); |
4813 } |
5225 } |
|
5226 |
4814 if ( !wasFlicking ) |
5227 if ( !wasFlicking ) |
4815 { |
5228 { |
4816 ReportListBoxEventL( |
5229 ReportListBoxEventL( |
4817 MEikListBoxObserver::EEventPenDownOnItem ); |
5230 MEikListBoxObserver::EEventPenDownOnItem ); |
4818 iListBoxExt->LongTapPointerEventL( aPointerEvent ); |
5231 iListBoxExt->LongTapPointerEventL( aPointerEvent ); |
4819 } |
5232 } |
4820 } |
5233 } |
4821 else |
5234 else |
4822 { |
5235 { |
|
5236 if( itemIndex == oldCurrentItemIndex ) |
|
5237 { |
|
5238 if( !( ( iListBoxFlags & EViewerFlag ) && |
|
5239 ( iListBoxFlags & EDisableItemSpecificMenu ) ) ) |
|
5240 { |
|
5241 iListBoxExt->ImmediateFeedback( |
|
5242 iListBoxExt->iFeedbackType, |
|
5243 TTouchFeedbackType( ETouchFeedbackVibra | |
|
5244 ETouchFeedbackAudio ), |
|
5245 aPointerEvent ); |
|
5246 } |
|
5247 } |
4823 ReportListBoxEventL( |
5248 ReportListBoxEventL( |
4824 MEikListBoxObserver::EEventPenDownOnItem ); |
5249 MEikListBoxObserver::EEventPenDownOnItem ); |
4825 } |
5250 } |
4826 } |
5251 } |
4827 else |
5252 else |
4985 } |
5411 } |
4986 break; |
5412 break; |
4987 |
5413 |
4988 case TPointerEvent::EButton1Up: |
5414 case TPointerEvent::EButton1Up: |
4989 _AKNTRACE("TPointerEvent::EButton1Up"); |
5415 _AKNTRACE("TPointerEvent::EButton1Up"); |
4990 if ( iListBoxExt->FeedbackEnabledOnUpEvent() && iListBoxExt->iClickEventsAllowed ) |
5416 if ( iListBoxExt->FeedbackEnabledOnUpEvent() && |
4991 { |
5417 iListBoxExt->iClickEventsAllowed && |
4992 TTouchLogicalFeedback fbType = ETouchFeedbackBasicItem; |
5418 ( !( ( iListBoxFlags & EViewerFlag ) && |
4993 if ( iListBoxFlags & ES60StyleMultiselection ) |
5419 ( iListBoxFlags & EDisableItemSpecificMenu ) ) )&& |
|
5420 ( iListBoxExt->iLastDownTappedItem == itemIndex ) && |
|
5421 ( !iListBoxExt->iDoubleClickEventIgnored ) && |
|
5422 itemIndex == iView->CurrentItemIndex() ) |
|
5423 { |
|
5424 TTouchLogicalFeedback fbType = ETouchFeedbackList; |
|
5425 if ( iListBoxFlags & ES60StyleMultiselection |
|
5426 || iListBoxFlags & EMultipleSelection ) |
4994 { |
5427 { |
4995 fbType = ETouchFeedbackCheckbox; |
5428 fbType = ETouchFeedbackCheckbox; |
4996 } |
5429 } |
4997 iListBoxExt->ImmediateFeedback( fbType, |
5430 iListBoxExt->ImmediateFeedback( fbType, |
4998 ETouchFeedbackVibra, |
5431 ETouchFeedbackVibra, |
5059 MEikListBoxObserver::EEventItemSingleClicked ); |
5493 MEikListBoxObserver::EEventItemSingleClicked ); |
5060 _AKNTRACE_FUNC_EXIT; |
5494 _AKNTRACE_FUNC_EXIT; |
5061 return; |
5495 return; |
5062 } |
5496 } |
5063 } |
5497 } |
5064 else if ( s60StyleMultiselection && |
5498 // Due to the feature of capactior panel, the pointer position |
5065 iListBoxExt->iLastDownTappedItem == itemIndex && |
5499 // may change between pointer down and up during user click |
5066 !Buffer()->iDragToAnotherItem ) |
5500 // action. When the click position is between two items |
|
5501 // and flick or drag event is not performed, the item index may |
|
5502 // change unwanted, so we make a threshold for this situation. |
|
5503 else if ( s60StyleMultiselection && !Buffer()->iDragToAnotherItem |
|
5504 && ( iListBoxExt->iLastDownTappedItem == itemIndex |
|
5505 || ( iListBoxExt->iLastDownTappedItem != KErrNotFound |
|
5506 && Abs( iListBoxExt->iLastPointerPos.iY - aPointerEvent.iPosition.iY ) < KPointerDownAndUpThreshold ) ) ) |
5067 { |
5507 { |
5068 iListBoxFlags |= EStateChanged; |
5508 iListBoxFlags |= EStateChanged; |
5069 Buffer()->iPressedIndex = itemIndex; |
5509 Buffer()->iPressedIndex = itemIndex; |
5070 iView->SetAnchor(itemIndex-1); // zero indexed |
5510 iView->SetAnchor(itemIndex-1); // zero indexed |
5071 iView->UpdateSelectionL(selectionMode); |
5511 iView->UpdateSelectionL(selectionMode); |
5741 } |
6184 } |
5742 iBackColor=iEikonEnv->ControlColor(IsDimmed() ? |
6185 iBackColor=iEikonEnv->ControlColor(IsDimmed() ? |
5743 EColorControlDimmedBackground : EColorControlBackground,*this); |
6186 EColorControlDimmedBackground : EColorControlBackground,*this); |
5744 UpdateViewColors(); |
6187 UpdateViewColors(); |
5745 UpdateItemDrawerColors(); |
6188 UpdateItemDrawerColors(); |
5746 |
6189 |
|
6190 // store the value of virtical offset as it will be 0 in SizeChange, |
|
6191 // that will affect view position in skin changed, which is a bug. |
|
6192 TInt oldOffset = 0; |
|
6193 if ( iView ) |
|
6194 { |
|
6195 oldOffset = iView->ItemOffsetInPixels(); |
|
6196 } |
|
6197 // TODO: check if this call is real need here. |
5747 SizeChanged(); |
6198 SizeChanged(); |
|
6199 if ( oldOffset !=0 && iView ) |
|
6200 { |
|
6201 iView->SetItemOffsetInPixels( oldOffset ); |
|
6202 UpdateScrollBarThumbs(); |
|
6203 } |
|
6204 // this methord is empty. |
5748 UpdateScrollBarsColors(); |
6205 UpdateScrollBarsColors(); |
5749 |
6206 |
5750 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
6207 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
5751 if ( transApi ) |
6208 if ( transApi ) |
5752 { |
6209 { |
5772 case KEikMessageFadeAllWindows: |
6229 case KEikMessageFadeAllWindows: |
5773 { |
6230 { |
5774 // Some client does not let list get button1up, so we do it there... |
6231 // Some client does not let list get button1up, so we do it there... |
5775 iItemDrawer->ClearFlags( CListItemDrawer::EPressedDownState ); |
6232 iItemDrawer->ClearFlags( CListItemDrawer::EPressedDownState ); |
5776 TInt index = View()->CurrentItemIndex(); |
6233 TInt index = View()->CurrentItemIndex(); |
5777 if ( index != KErrNotFound ) |
6234 TBool enabled( !( iItemDrawer->Flags() |
|
6235 & CListItemDrawer::ESingleClickDisabledHighlight ) ); |
|
6236 if ( index != KErrNotFound && enabled ) |
5778 { |
6237 { |
5779 Window().Invalidate( TRect( View()->ItemPos(index), |
6238 Window().Invalidate( TRect( View()->ItemPos(index), |
5780 View()->ItemSize() ) ); |
6239 iItemDrawer->ItemCellSize() ) ); |
5781 } |
6240 } |
5782 break; |
6241 break; |
5783 } |
6242 } |
5784 case KEikDynamicLayoutVariantSwitch: |
6243 case KEikDynamicLayoutVariantSwitch: |
5785 case KEikMessageColorSchemeChange: |
6244 case KEikMessageColorSchemeChange: |
5950 rect.iTl.iX += LafListBox::InnerGutter(); |
6414 rect.iTl.iX += LafListBox::InnerGutter(); |
5951 if (iItemDrawer->Flags()&CListItemDrawer::EDrawMarkSelection) |
6415 if (iItemDrawer->Flags()&CListItemDrawer::EDrawMarkSelection) |
5952 { |
6416 { |
5953 rect.iTl.iX += iItemDrawer->MarkColumn() + iItemDrawer->MarkGutter(); |
6417 rect.iTl.iX += iItemDrawer->MarkColumn() + iItemDrawer->MarkGutter(); |
5954 } |
6418 } |
5955 iListBoxExt->SetReasonForFocusLost(EFocusLostToInternalEditor); |
6419 if ( iListBoxExt ) |
|
6420 { |
|
6421 iListBoxExt->SetReasonForFocusLost(EFocusLostToInternalEditor); |
|
6422 } |
5956 itemEditor->StartEditingL(*this,rect,index,aMaxLength); |
6423 itemEditor->StartEditingL(*this,rect,index,aMaxLength); |
5957 iListBoxExt->SetReasonForFocusLost(EFocusLostToExternalControl); |
6424 if ( iListBoxExt ) |
|
6425 { |
|
6426 iListBoxExt->SetReasonForFocusLost(EFocusLostToExternalControl); |
|
6427 } |
5958 ReportListBoxEventL( MEikListBoxObserver::EEventEditingStarted ); |
6428 ReportListBoxEventL( MEikListBoxObserver::EEventEditingStarted ); |
5959 } |
6429 } |
5960 _AKNTRACE_FUNC_EXIT; |
6430 _AKNTRACE_FUNC_EXIT; |
5961 } |
6431 } |
5962 |
6432 |
6080 // --------------------------------------------------------------------------- |
6550 // --------------------------------------------------------------------------- |
6081 // |
6551 // |
6082 EXPORT_C void CEikListBox::DisableScrolling( TBool aDisabled ) |
6552 EXPORT_C void CEikListBox::DisableScrolling( TBool aDisabled ) |
6083 { |
6553 { |
6084 _AKNTRACE_FUNC_ENTER; |
6554 _AKNTRACE_FUNC_ENTER; |
6085 iListBoxExt->iScrollingDisabled = aDisabled; |
6555 if ( iListBoxExt ) |
6086 iView->iExtension->iScrollingDisabled = aDisabled; |
6556 { |
6087 |
6557 iListBoxExt->iScrollingDisabled = aDisabled; |
6088 if ( aDisabled && iListBoxExt->iPhysics ) |
6558 iView->iExtension->iScrollingDisabled = aDisabled; |
6089 { |
6559 |
6090 delete iListBoxExt->iPhysics; |
6560 if ( aDisabled && iListBoxExt->iPhysics ) |
6091 iListBoxExt->iPhysics = NULL; |
6561 { |
6092 iView->SetItemOffsetInPixels( 0 ); |
6562 delete iListBoxExt->iPhysics; |
6093 } |
6563 iListBoxExt->iPhysics = NULL; |
6094 else if ( !aDisabled && !iListBoxExt->iPhysics && CAknPhysics::FeatureEnabled() ) |
6564 iView->SetItemOffsetInPixels( 0 ); |
6095 { |
6565 } |
6096 iListBoxExt->iPhysics = CAknPhysics::NewL( *iListBoxExt, this); |
6566 else if ( !aDisabled && !iListBoxExt->iPhysics && CAknPhysics::FeatureEnabled() ) |
|
6567 { |
|
6568 iListBoxExt->iPhysics = CAknPhysics::NewL( *iListBoxExt, this); |
|
6569 } |
6097 } |
6570 } |
6098 _AKNTRACE_FUNC_EXIT; |
6571 _AKNTRACE_FUNC_EXIT; |
6099 } |
6572 } |
6100 |
6573 |
6101 |
6574 |
6103 // Checks if the kinetic scrolling functionality is disabled in the list. |
6576 // Checks if the kinetic scrolling functionality is disabled in the list. |
6104 // --------------------------------------------------------------------------- |
6577 // --------------------------------------------------------------------------- |
6105 // |
6578 // |
6106 EXPORT_C TBool CEikListBox::ScrollingDisabled() |
6579 EXPORT_C TBool CEikListBox::ScrollingDisabled() |
6107 { |
6580 { |
6108 return !iListBoxExt->iPhysics || iListBoxExt->iScrollingDisabled; |
6581 if ( iListBoxExt ) |
|
6582 { |
|
6583 return !iListBoxExt->iPhysics || iListBoxExt->iScrollingDisabled; |
|
6584 } |
|
6585 else |
|
6586 { |
|
6587 return ETrue; |
|
6588 } |
6109 } |
6589 } |
6110 |
6590 |
6111 |
6591 |
6112 EXPORT_C void CEikListBox::SetPointerEventFilterDisabledL( const CArrayFix<TInt>& aItemIndexes ) |
6592 EXPORT_C void CEikListBox::SetPointerEventFilterDisabledL( const CArrayFix<TInt>& aItemIndexes ) |
6113 { |
6593 { |
6114 _AKNTRACE_FUNC_ENTER; |
6594 _AKNTRACE_FUNC_ENTER; |
6115 iListBoxExt->iMutiTappingItems.Reset(); |
6595 if ( iListBoxExt ) |
6116 |
6596 { |
6117 for(TInt i=0; i<aItemIndexes.Count(); i++ ) |
6597 iListBoxExt->iMutiTappingItems.Reset(); |
6118 { |
6598 |
6119 iListBoxExt->iMutiTappingItems.InsertInOrderL( aItemIndexes.At(i) ); |
6599 for(TInt i=0; i<aItemIndexes.Count(); i++ ) |
6120 } |
6600 { |
|
6601 iListBoxExt->iMutiTappingItems.InsertInOrderL( aItemIndexes.At(i) ); |
|
6602 } |
|
6603 } |
6121 _AKNTRACE_FUNC_EXIT; |
6604 _AKNTRACE_FUNC_EXIT; |
6122 } |
6605 } |
6123 |
6606 |
6124 |
6607 |
6125 // --------------------------------------------------------------------------- |
6608 // --------------------------------------------------------------------------- |
6171 // Disables the single click functionality in the list. |
6654 // Disables the single click functionality in the list. |
6172 // --------------------------------------------------------------------------- |
6655 // --------------------------------------------------------------------------- |
6173 // |
6656 // |
6174 EXPORT_C void CEikListBox::DisableSingleClick( TBool aDisabled ) |
6657 EXPORT_C void CEikListBox::DisableSingleClick( TBool aDisabled ) |
6175 { |
6658 { |
6176 _AKNTRACE_FUNC_ENTER; |
6659 _AKNTRACE_FUNC_ENTER; |
6177 if ( aDisabled && iListBoxExt->iSingleClickEnabled ) |
6660 if ( aDisabled && |
|
6661 iListBoxExt && |
|
6662 iListBoxExt->iSingleClickEnabled && |
|
6663 iItemDrawer ) |
6178 { |
6664 { |
6179 iListBoxExt->DisableSingleClick(); |
6665 iListBoxExt->DisableSingleClick(); |
|
6666 iItemDrawer->ClearFlags( CListItemDrawer::ESingleClickEnabled); |
|
6667 } |
|
6668 else if ( !aDisabled && |
|
6669 iListBoxExt && |
|
6670 !iListBoxExt->iSingleClickEnabled && |
|
6671 iItemDrawer ) |
|
6672 { |
|
6673 TRAP_IGNORE( iListBoxExt->EnableSingleClickL() ); |
|
6674 iItemDrawer->SetFlags( CListItemDrawer::ESingleClickEnabled ); |
6180 } |
6675 } |
6181 _AKNTRACE_FUNC_EXIT; |
6676 _AKNTRACE_FUNC_EXIT; |
6182 } |
6677 } |
6183 |
6678 |
6184 |
6679 |
6186 // CEikListBox::DisableItemSpecificMenu |
6681 // CEikListBox::DisableItemSpecificMenu |
6187 // --------------------------------------------------------------------------- |
6682 // --------------------------------------------------------------------------- |
6188 // |
6683 // |
6189 EXPORT_C void CEikListBox::DisableItemSpecificMenu() |
6684 EXPORT_C void CEikListBox::DisableItemSpecificMenu() |
6190 { |
6685 { |
|
6686 _AKNTRACE_FUNC_ENTER; |
6191 if ( iListBoxExt ) |
6687 if ( iListBoxExt ) |
6192 { |
6688 { |
6193 iListBoxExt->DisableItemSpecificMenu(); |
6689 iListBoxExt->DisableItemSpecificMenu(); |
|
6690 } |
|
6691 _AKNTRACE_FUNC_EXIT; |
|
6692 } |
|
6693 |
|
6694 // --------------------------------------------------------------------------- |
|
6695 // CEikListBox::IsHighlightEnabled |
|
6696 // --------------------------------------------------------------------------- |
|
6697 // |
|
6698 EXPORT_C TBool CEikListBox::IsHighlightEnabled() |
|
6699 { |
|
6700 _AKNTRACE_FUNC_ENTER; |
|
6701 TBool enabled( EFalse ); |
|
6702 if ( !( iItemDrawer->Flags() & CListItemDrawer::EDisableHighlight ) ) |
|
6703 { |
|
6704 if ( iListBoxExt && iListBoxExt->iSingleClickEnabled ) |
|
6705 { |
|
6706 enabled = !( iItemDrawer->Flags() |
|
6707 & CListItemDrawer::ESingleClickDisabledHighlight ); |
|
6708 } |
|
6709 else |
|
6710 { |
|
6711 enabled = ETrue; |
|
6712 } |
|
6713 } |
|
6714 _AKNTRACE_FUNC_EXIT; |
|
6715 return enabled; |
|
6716 } |
|
6717 |
|
6718 |
|
6719 // --------------------------------------------------------------------------- |
|
6720 // CEikListBox::SetMarkingMode |
|
6721 // --------------------------------------------------------------------------- |
|
6722 // |
|
6723 EXPORT_C void CEikListBox::SetMarkingMode( TBool aEnable ) |
|
6724 { |
|
6725 if ( iListBoxExt && iListBoxExt->iSingleClickEnabled && |
|
6726 ( iListBoxFlags & CEikListBox::ES60StyleMarkable ) ) |
|
6727 { |
|
6728 if ( iListBoxExt->iMarkingModeInUse != aEnable ) |
|
6729 { |
|
6730 if ( aEnable ) |
|
6731 { |
|
6732 iView->ItemDrawer()->SetFlags( |
|
6733 CListItemDrawer::EMarkingModeEnabled ); |
|
6734 } |
|
6735 else |
|
6736 { |
|
6737 iView->ItemDrawer()->ClearFlags( |
|
6738 CListItemDrawer::EMarkingModeEnabled ); |
|
6739 |
|
6740 if ( iView->SelectionIndexes()->Count() > 0 ) |
|
6741 { |
|
6742 iView->ClearSelection( EFalse ); |
|
6743 } |
|
6744 } |
|
6745 |
|
6746 iListBoxExt->iMarkingModeInUse = aEnable; |
|
6747 DrawDeferred(); |
|
6748 } |
|
6749 |
|
6750 if ( MarkingModeObserver() ) |
|
6751 { |
|
6752 MarkingModeObserver()->MarkingModeStatusChanged( aEnable ); |
|
6753 } |
|
6754 } |
|
6755 } |
|
6756 |
|
6757 |
|
6758 // --------------------------------------------------------------------------- |
|
6759 // CEikListBox::SetMarkingModeObserver |
|
6760 // --------------------------------------------------------------------------- |
|
6761 // |
|
6762 EXPORT_C void CEikListBox::SetMarkingModeObserver( |
|
6763 MAknMarkingModeObserver* aObserver ) |
|
6764 { |
|
6765 if ( iListBoxExt ) |
|
6766 { |
|
6767 iListBoxExt->iMarkingModeObserver = aObserver; |
6194 } |
6768 } |
6195 } |
6769 } |
6196 |
6770 |
6197 |
6771 |
6198 void CEikListBox::ScrollView( const TInt aOffset, TBool aDrawNow ) |
6772 void CEikListBox::ScrollView( const TInt aOffset, TBool aDrawNow ) |
6199 { |
6773 { |
6200 _AKNTRACE_FUNC_ENTER; |
6774 _AKNTRACE_FUNC_ENTER; |
6201 #ifdef _DEBUG |
6775 #ifdef _DEBUG |
6202 RDebug::Print( _L( "CEikListBox::ScrollView, aOffset = %d, aDrawNow = %d" ), aOffset, aDrawNow ); |
6776 RDebug::Print( _L( "CEikListBox::ScrollView, aOffset = %d, aDrawNow = %d" ), aOffset, aDrawNow ); |
6203 #endif // _DEBUG |
6777 #endif // _DEBUG |
6204 |
6778 |
6205 if ( aOffset != 0 ) |
6779 if ( iListBoxExt && aOffset != 0 ) |
6206 { |
6780 { |
6207 TInt itemHeight = iView->ItemHeight(); |
6781 TInt itemHeight = iView->ItemHeight(); |
6208 TInt viewHeight = iView->ViewRect().Size().iHeight; |
6782 TInt viewHeight = iView->ViewRect().Size().iHeight; |
6209 TInt itemsInSingleLine = iListBoxExt->iItemsInSingleLine; |
6783 TInt itemsInSingleLine = iListBoxExt->iItemsInSingleLine; |
6210 TInt oldListTopPos = ( iView->TopItemIndex() / itemsInSingleLine ) * itemHeight |
6784 TInt oldListTopPos = ( iView->TopItemIndex() / itemsInSingleLine ) * itemHeight |
6231 { |
6805 { |
6232 if( ( newListBottomPos < iListBoxExt->ListBottomLimit() && newListTopPos > 0 ) || |
6806 if( ( newListBottomPos < iListBoxExt->ListBottomLimit() && newListTopPos > 0 ) || |
6233 ( newListBottomPos >= iListBoxExt->ListBottomLimit() ) || |
6807 ( newListBottomPos >= iListBoxExt->ListBottomLimit() ) || |
6234 ( newListTopPos <= 0 && newListTopPos + viewHeight >= 0 && newListLastItemPos > viewHeight ) ) |
6808 ( newListTopPos <= 0 && newListTopPos + viewHeight >= 0 && newListLastItemPos > viewHeight ) ) |
6235 { |
6809 { |
6236 if ( CAknPhysics::EAknPhysicsActionFlicking == iListBoxExt->iPhysics->OngoingPhysicsAction() || |
6810 switch(iListBoxExt->iPhysics->OngoingPhysicsAction()) |
6237 CAknPhysics::EAknPhysicsActionBouncing == iListBoxExt->iPhysics->OngoingPhysicsAction() ) |
|
6238 { |
6811 { |
6239 iListBoxExt->ImmediateFeedback( ETouchFeedbackSensitiveItem, |
6812 case CAknPhysics::EAknPhysicsActionBouncing: |
6240 TTouchFeedbackType( ETouchFeedbackVibra ), |
6813 case CAknPhysics::EAknPhysicsActionDragging: |
6241 TPointerEvent() ); |
6814 case CAknPhysics::EAknPhysicsActionFlicking: |
6242 } |
6815 iListBoxExt->ImmediateFeedback( |
6243 else if ( CAknPhysics::EAknPhysicsActionDragging == iListBoxExt->iPhysics->OngoingPhysicsAction() ) |
6816 ETouchFeedbackSensitiveList, |
6244 { |
6817 TTouchFeedbackType( ETouchFeedbackVibra ), |
6245 iListBoxExt->ImmediateFeedback( iListBoxExt->iFeedbackType, |
6818 TPointerEvent() ); |
6246 TTouchFeedbackType( ETouchFeedbackVibra | ETouchFeedbackAudio ), |
6819 break; |
6247 TPointerEvent() ); |
6820 default: |
|
6821 break; |
6248 } |
6822 } |
6249 } |
6823 } |
6250 } |
6824 } |
6251 } |
6825 } |
6252 newTopItemIndex = newTopItemIndexBck; |
6826 newTopItemIndex = newTopItemIndexBck; |
6269 #ifdef _DEBUG |
6843 #ifdef _DEBUG |
6270 RDebug::Print( _L( "CEikListBox::ScrollView, newTopItemIndex = %d" ), newTopItemIndex ); |
6844 RDebug::Print( _L( "CEikListBox::ScrollView, newTopItemIndex = %d" ), newTopItemIndex ); |
6271 #endif // _DEBUG |
6845 #endif // _DEBUG |
6272 iView->SetTopItemIndex( newTopItemIndex ); |
6846 iView->SetTopItemIndex( newTopItemIndex ); |
6273 } |
6847 } |
|
6848 |
6274 if ( aDrawNow ) |
6849 if ( aDrawNow ) |
6275 { |
6850 { |
6276 TRect rect(Rect()); |
6851 TRect rect(Rect()); |
6277 |
6852 |
6278 // list position changed |
6853 // list position changed |
6279 iListBoxExt->iBackgroundDrawingSuppressed = ETrue; |
6854 if ( iListBoxExt && iListBoxExt->FlickOrPanningOngoing() ) |
|
6855 { |
|
6856 iItemDrawer->SetFlags( CListItemDrawer::EDrawWholeBackground ); |
|
6857 } |
|
6858 |
6280 UpdateScrollBarThumbs(); |
6859 UpdateScrollBarThumbs(); |
6281 DrawNow(); |
6860 DrawNow(); |
|
6861 |
6282 if (iSBFrame && iSBFrame->VerticalScrollBar() && !iSBFrame->VerticalScrollBar()->OwnsWindow()) |
6862 if (iSBFrame && iSBFrame->VerticalScrollBar() && !iSBFrame->VerticalScrollBar()->OwnsWindow()) |
6283 { |
6863 { |
6284 TRect srect( iSBFrame->VerticalScrollBar()->Rect() ); |
6864 TRect srect( iSBFrame->VerticalScrollBar()->Rect() ); |
6285 if ( !srect.Intersects( rect )) |
6865 if ( !srect.Intersects( rect )) |
6286 { |
6866 { |
6287 iSBFrame->DrawScrollBarsNow(); |
6867 iSBFrame->DrawScrollBarsNow(); |
6288 } |
6868 } |
6289 } |
6869 } |
6290 iListBoxExt->iBackgroundDrawingSuppressed = EFalse; |
6870 |
|
6871 if ( iListBoxExt ) |
|
6872 { |
|
6873 iItemDrawer->ClearFlags( CListItemDrawer::EDrawWholeBackground |
|
6874 | CListItemDrawer::EBackgroundDrawn ); |
|
6875 } |
6291 } |
6876 } |
6292 _AKNTRACE_FUNC_EXIT; |
6877 _AKNTRACE_FUNC_EXIT; |
6293 } |
6878 } |
6294 |
6879 |
6295 |
6880 |
6300 TBool CEikListBox::HandlePhysicsPointerEventL( const TPointerEvent& aPointerEvent ) |
6885 TBool CEikListBox::HandlePhysicsPointerEventL( const TPointerEvent& aPointerEvent ) |
6301 { |
6886 { |
6302 _AKNTRACE_FUNC_ENTER; |
6887 _AKNTRACE_FUNC_ENTER; |
6303 _AKNTRACE( "aPointerEvent.iType = %d", aPointerEvent.iType ); |
6888 _AKNTRACE( "aPointerEvent.iType = %d", aPointerEvent.iType ); |
6304 if ( iListBoxExt->iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionBouncing ) |
6889 if ( iListBoxExt->iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionBouncing ) |
6305 { |
6890 { |
6306 // Block scrolling events outside listbox area. Note that pointer |
6891 // Block scrolling events outside listbox area. |
6307 // event ignore must be done for the window-owning control or it |
6892 if ( iListBoxExt->IgnorePointerEventsUntilUp() ) |
6308 // doesn't have any effect! |
6893 { |
6309 CCoeControl* windowOwningControl = this; |
|
6310 |
|
6311 while ( windowOwningControl && !windowOwningControl->OwnsWindow() ) |
|
6312 { |
|
6313 windowOwningControl = windowOwningControl->Parent(); |
|
6314 } |
|
6315 |
|
6316 if ( windowOwningControl ) |
|
6317 { |
|
6318 windowOwningControl->IgnoreEventsUntilNextPointerUp(); |
|
6319 _AKNTRACE_FUNC_EXIT; |
6894 _AKNTRACE_FUNC_EXIT; |
6320 return ETrue; |
6895 return ETrue; |
6321 } |
6896 } |
6322 } |
6897 } |
6323 |
6898 |
6324 TBool blockEvent = EFalse; |
6899 TBool blockEvent = EFalse; |
6325 |
6900 |
6326 TBool allowDragEvent( ( iListBoxFlags & ELeftDownInViewRect ) && iSBFrame && !iListBoxExt->iScrollingDisabled ); |
6901 // If tap down in listbox area, kinetic scrolling is enabled and style popup menu is not shown, |
6327 |
6902 // drag event is sent to listbox. |
|
6903 TBool allowDragEvent( ( iListBoxFlags & ELeftDownInViewRect ) |
|
6904 && !iListBoxExt->iScrollingDisabled |
|
6905 && ( iListBoxExt->iSingleClickEnabled |
|
6906 && iListBoxExt->iLongTappedItem == KErrNotFound ) ); |
6328 |
6907 |
6329 switch ( aPointerEvent.iType ) |
6908 switch ( aPointerEvent.iType ) |
6330 { |
6909 { |
6331 case TPointerEvent::EButton1Down: |
6910 case TPointerEvent::EButton1Down: |
6332 { |
6911 { |
6579 // been made visible. |
7165 // been made visible. |
6580 iListBoxExt->LongTapPointerEventL( |
7166 iListBoxExt->LongTapPointerEventL( |
6581 iListBoxExt->iDelayedPointerDownEvent ); |
7167 iListBoxExt->iDelayedPointerDownEvent ); |
6582 } |
7168 } |
6583 |
7169 |
6584 if ( iListBoxExt->iDelayedMultiselection ) |
7170 if ( iListBoxExt && iListBoxExt->iDelayedMultiselection ) |
6585 { |
7171 { |
6586 iItemDrawer->SetFlags( CListItemDrawer::EPressedDownState ); |
7172 iItemDrawer->SetFlags( CListItemDrawer::EPressedDownState ); |
6587 } |
7173 } |
6588 |
7174 |
6589 iView->SetItemIndex( aItemIndex ); |
7175 iView->SetItemIndex( aItemIndex ); |
6590 |
7176 |
6591 if ( iListBoxExt->iMarkableListMarking ) |
7177 if ( iListBoxExt && iListBoxExt->iMarkableListMarking ) |
6592 { |
7178 { |
6593 if ( iListBoxExt->iMarkableListShiftKeyPressed ) |
7179 if ( iListBoxExt->iSingleClickEnabled ) |
|
7180 { |
|
7181 if ( iListBoxExt->iMarkableListShiftKeyPressed ) |
|
7182 { |
|
7183 iView->ToggleItemL( iView->CurrentItemIndex() ); |
|
7184 iListBoxExt->iClickEventsAllowed = EFalse; |
|
7185 } |
|
7186 } |
|
7187 else if ( iListBoxExt->iMarkableListShiftKeyPressed ) |
6594 { |
7188 { |
6595 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
7189 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
6596 iListBoxExt->iAnchor = oldCurrentItemIndex; |
7190 iListBoxExt->iAnchor = oldCurrentItemIndex; |
6597 iListBoxExt->iSelect = |
7191 iListBoxExt->iSelect = |
6598 !iView->ItemIsSelected( iView->CurrentItemIndex() ); |
7192 !iView->ItemIsSelected( iView->CurrentItemIndex() ); |
6616 } |
7210 } |
6617 |
7211 |
6618 iView->DrawItem( oldCurrentItemIndex ); |
7212 iView->DrawItem( oldCurrentItemIndex ); |
6619 iView->DrawItem( aItemIndex ); |
7213 iView->DrawItem( aItemIndex ); |
6620 |
7214 |
6621 if ( iListBoxExt->iDelayedMultiselection ) |
7215 if ( iListBoxExt && iListBoxExt->iDelayedMultiselection ) |
6622 { |
7216 { |
6623 iListBoxFlags |= EStateChanged; |
7217 iListBoxFlags |= EStateChanged; |
6624 Buffer()->iPressedIndex = aItemIndex; |
7218 Buffer()->iPressedIndex = aItemIndex; |
6625 } |
7219 } |
6626 |
7220 |
6627 ReportEventL( MCoeControlObserver::EEventStateChanged ); |
7221 ReportEventL( MCoeControlObserver::EEventStateChanged ); |
6628 _AKNTRACE_FUNC_EXIT; |
7222 _AKNTRACE_FUNC_EXIT; |
|
7223 } |
|
7224 |
|
7225 |
|
7226 // --------------------------------------------------------------------------- |
|
7227 // CEikListBox::MarkingMode |
|
7228 // --------------------------------------------------------------------------- |
|
7229 // |
|
7230 TBool CEikListBox::MarkingMode() const |
|
7231 { |
|
7232 TBool markingModeInUse = EFalse; |
|
7233 |
|
7234 if ( iListBoxExt ) |
|
7235 { |
|
7236 markingModeInUse = iListBoxExt->iMarkingModeInUse; |
|
7237 } |
|
7238 |
|
7239 return markingModeInUse; |
|
7240 } |
|
7241 |
|
7242 |
|
7243 // --------------------------------------------------------------------------- |
|
7244 // CEikListBox::MarkingModeObserver |
|
7245 // --------------------------------------------------------------------------- |
|
7246 // |
|
7247 MAknMarkingModeObserver* CEikListBox::MarkingModeObserver() |
|
7248 { |
|
7249 MAknMarkingModeObserver* observer = NULL; |
|
7250 |
|
7251 if ( iListBoxExt ) |
|
7252 { |
|
7253 observer = iListBoxExt->iMarkingModeObserver; |
|
7254 } |
|
7255 |
|
7256 return observer; |
6629 } |
7257 } |
6630 |
7258 |
6631 |
7259 |
6632 // --------------------------------------------------------------------------- |
7260 // --------------------------------------------------------------------------- |
6633 // Sets this control as visible or invisible. |
7261 // Sets this control as visible or invisible. |