238 { |
239 { |
239 iItems[aIndex]->SetFlags( CHgItem::EHgItemFlagMarked ); |
240 iItems[aIndex]->SetFlags( CHgItem::EHgItemFlagMarked ); |
240 if( iMarkingObserver ) |
241 if( iMarkingObserver ) |
241 { |
242 { |
242 TRAP_IGNORE( iMarkingObserver->HandleMarkingL( aIndex, ETrue ) ); |
243 TRAP_IGNORE( iMarkingObserver->HandleMarkingL( aIndex, ETrue ) ); |
243 } |
244 } |
244 } |
245 } |
245 } |
246 } |
246 } |
247 } |
247 |
248 |
248 // ----------------------------------------------------------------------------- |
249 // ----------------------------------------------------------------------------- |
249 // CHgScroller::UnMark() |
250 // CHgScroller::UnMark() |
250 // ----------------------------------------------------------------------------- |
251 // ----------------------------------------------------------------------------- |
587 if( aEvent.iType == TPointerEvent::EButton1Down ) |
588 if( aEvent.iType == TPointerEvent::EButton1Down ) |
588 { |
589 { |
589 iPointerDown = ETrue; |
590 iPointerDown = ETrue; |
590 HandleDownEventL( aEvent ); |
591 HandleDownEventL( aEvent ); |
591 |
592 |
592 // Long tap is supported in marking mode only for an item that is marked. |
|
593 const TBool validIndex = iSelectedIndex != KErrNotFound && |
|
594 iSelectedIndex >= 0 && iSelectedIndex < iItems.Count(); |
|
595 const TBool selectionMode = iFlags & EHgScrollerSelectionMode; |
|
596 const TBool longTapEnabled = validIndex && (!selectionMode || |
|
597 (selectionMode && iItems[iSelectedIndex]->Flags() & CHgItem::EHgItemFlagMarked)); |
|
598 |
|
599 if( iDetector |
593 if( iDetector |
600 && longTapEnabled |
594 && iSelectedIndex != KErrNotFound |
601 && !HasHighlight() |
595 && !HasHighlight() |
602 && iActionMenu->InitMenuL() ) |
596 && iActionMenu->InitMenuL() ) |
603 { |
597 { |
604 iDetector->PointerEventL( aEvent ); |
598 iDetector->PointerEventL( aEvent ); |
605 } |
599 } |
606 } |
600 } |
889 iKeyRepeats = 0; |
883 iKeyRepeats = 0; |
890 iKeyScrollingState = ENoKeyScrolling; |
884 iKeyScrollingState = ENoKeyScrolling; |
891 |
885 |
892 iPointerDown = EFalse; |
886 iPointerDown = EFalse; |
893 iPanning = EFalse; |
887 iPanning = EFalse; |
894 iEnterKeyHandled = EFalse; |
|
895 } |
888 } |
896 |
889 |
897 // ----------------------------------------------------------------------------- |
890 // ----------------------------------------------------------------------------- |
898 // CHgScroller::KeyEventUp() |
891 // CHgScroller::KeyEventUp() |
899 // ----------------------------------------------------------------------------- |
892 // ----------------------------------------------------------------------------- |
1060 return; |
1053 return; |
1061 |
1054 |
1062 iViewPosition = aNewPosition; |
1055 iViewPosition = aNewPosition; |
1063 iPhysics->StopPhysics(); |
1056 iPhysics->StopPhysics(); |
1064 |
1057 |
1065 // show a letter popup only if we are currently dragging with scrollbar |
1058 if( iScrollBarType == EHgScrollerTimeStrip ) |
1066 if(iScrollbar && iScrollbar->IsDragging()) |
1059 { |
1067 { |
1060 // Show first item's time. |
1068 if( iScrollBarType == EHgScrollerTimeStrip ) |
1061 TInt selectedItem = CurrentIndex(); |
1069 { |
1062 if( selectedItem >= 0 && selectedItem < iItems.Count() |
1070 // Show first item's time. |
1063 && iItems[selectedItem]->Time().Int64() ) |
1071 TInt selectedItem = CurrentIndex(); |
1064 { |
1072 if( selectedItem >= 0 && selectedItem < iItems.Count() |
1065 TRAP_IGNORE( |
1073 && iItems[selectedItem]->Time().Int64() ) |
1066 iItems[selectedItem]->Time().FormatL( iPopupText1, KGanesMonthString ); |
|
1067 iItems[selectedItem]->Time().FormatL( iPopupText2, KGanesYearString ); |
|
1068 ) |
|
1069 // To display month and year correctly in arabic. |
|
1070 AknTextUtils::LanguageSpecificNumberConversion( iPopupText1 ); |
|
1071 AknTextUtils::LanguageSpecificNumberConversion( iPopupText2 ); |
|
1072 } |
|
1073 } |
|
1074 else if( iScrollBarType == EHgScrollerLetterStrip |
|
1075 || iScrollBarType == EHgScrollerLetterStripLite ) |
|
1076 { |
|
1077 TInt selectedItem = CurrentIndex(); |
|
1078 if( selectedItem >= 0 && selectedItem < iItems.Count() ) |
|
1079 { |
|
1080 if(iItems[selectedItem]->Title().Length()) |
1074 { |
1081 { |
1075 TRAP_IGNORE( |
1082 iPopupText1.Zero(); |
1076 iItems[selectedItem]->Time().FormatL( iPopupText1, KGanesMonthString ); |
1083 iPopupText1.Append( iItems[selectedItem]->Title()[0] ); |
1077 iItems[selectedItem]->Time().FormatL( iPopupText2, KGanesYearString ); |
1084 iPopupText1.UpperCase(); |
1078 ) |
|
1079 // To display month and year correctly in arabic. |
|
1080 AknTextUtils::LanguageSpecificNumberConversion( iPopupText1 ); |
|
1081 AknTextUtils::LanguageSpecificNumberConversion( iPopupText2 ); |
|
1082 } |
|
1083 } |
|
1084 else if( iScrollBarType == EHgScrollerLetterStrip |
|
1085 || iScrollBarType == EHgScrollerLetterStripLite ) |
|
1086 { |
|
1087 TInt selectedItem = CurrentIndex(); |
|
1088 if( selectedItem >= 0 && selectedItem < iItems.Count() ) |
|
1089 { |
|
1090 if(iItems[selectedItem]->Title().Length()) |
|
1091 { |
|
1092 iPopupText1.Zero(); |
|
1093 iPopupText1.Append( iItems[selectedItem]->Title()[0] ); |
|
1094 iPopupText1.UpperCase(); |
|
1095 } |
|
1096 } |
1085 } |
1097 } |
1086 } |
1098 } |
1087 } |
1099 HandleViewPositionChanged( EFalse ); |
1088 HandleViewPositionChanged( EFalse ); |
1100 DrawNow(); |
1089 DrawNow(); |
1194 possibleKeyScrollingState = EKeyScrollingRight; |
1183 possibleKeyScrollingState = EKeyScrollingRight; |
1195 break; |
1184 break; |
1196 case EKeyEnter: |
1185 case EKeyEnter: |
1197 case EKeyOK: |
1186 case EKeyOK: |
1198 { |
1187 { |
1199 // If enter key is pushed down for a long time, many key events |
1188 if( iSelectedIndex != KErrNotFound && HasHighlight() ) |
1200 // are generated. Enter should be handled only ones. |
|
1201 if (!iEnterKeyHandled) |
|
1202 { |
1189 { |
1203 iEnterKeyHandled = ETrue; |
1190 iShowHighlight = EFalse; |
1204 if( iSelectedIndex != KErrNotFound && HasHighlight()) |
1191 iDrawUtils->EnableMarquee(HasHighlight()); |
1205 { |
1192 if( iSelectionObserver ) |
1206 iEnterKeyHandled = ETrue; |
1193 TRAP_IGNORE( iSelectionObserver->HandleOpenL( iSelectedIndex ); ) |
1207 const TBool validIndex = iSelectedIndex >= 0 && iSelectedIndex < iItems.Count(); |
1194 return EKeyWasConsumed; |
1208 const TBool selectionMode = iFlags & EHgScrollerSelectionMode; |
1195 } |
1209 if (validIndex && selectionMode) |
1196 else if( iItemCount ) |
1210 { |
1197 { |
1211 // In selection mode enterkey should mark/unmark item. |
1198 iSelectedIndex = iCurrentRow; |
1212 iItems[iSelectedIndex]->Flags() & CHgItem::EHgItemFlagMarked ? |
1199 FitSelectionToView(); |
1213 UnMark(iSelectedIndex) : Mark(iSelectedIndex); |
1200 iShowHighlight = ETrue; |
1214 DrawDeferred(); |
1201 iDrawUtils->EnableMarquee(HasHighlight()); |
1215 } |
1202 DrawDeferred(); |
1216 else |
1203 if( iSelectionObserver ) |
1217 { |
1204 TRAP_IGNORE( iSelectionObserver->HandleSelectL( iSelectedIndex ); ) |
1218 // Item will be opened so highlight is removed. |
1205 return EKeyWasConsumed; |
1219 iShowHighlight = EFalse; |
|
1220 if( iSelectionObserver ) |
|
1221 { |
|
1222 TRAP_IGNORE( iSelectionObserver->HandleOpenL( iSelectedIndex ); ) |
|
1223 } |
|
1224 } |
|
1225 iDrawUtils->EnableMarquee(HasHighlight()); |
|
1226 return EKeyWasConsumed; |
|
1227 } |
|
1228 else if( iItemCount ) |
|
1229 { |
|
1230 iSelectedIndex = CurrentIndex(); |
|
1231 FitSelectionToView(); |
|
1232 iShowHighlight = ETrue; |
|
1233 iDrawUtils->EnableMarquee(HasHighlight()); |
|
1234 DrawDeferred(); |
|
1235 if( iSelectionObserver ) |
|
1236 TRAP_IGNORE( iSelectionObserver->HandleSelectL( iSelectedIndex ); ) |
|
1237 return EKeyWasConsumed; |
|
1238 } |
|
1239 } |
1206 } |
1240 return EKeyWasNotConsumed; |
1207 return EKeyWasNotConsumed; |
1241 } |
1208 } |
1242 default: |
1209 default: |
1243 break; |
1210 break; |
1302 // |
1269 // |
1303 EXPORT_C void CHgScroller::Reset() |
1270 EXPORT_C void CHgScroller::Reset() |
1304 { |
1271 { |
1305 if(iItemCount) |
1272 if(iItemCount) |
1306 { |
1273 { |
1307 iHighlightTimer->Cancel(); |
|
1308 iPointerDown = EFalse; |
|
1309 if(iDetector) |
|
1310 { |
|
1311 TRAP_IGNORE(iDetector->CancelAnimationL()); |
|
1312 } |
|
1313 iPanning = EFalse; |
|
1314 |
|
1315 iPhysics->StopPhysics(); |
|
1316 iPhysics->ResetFriction(); |
|
1317 |
|
1318 iFocusedIndex = KErrNotFound; |
|
1319 iSelectionToFocusedItem = EFalse; |
|
1320 iDrawUtils->EnableMarquee(false); |
|
1321 |
|
1322 iItems.ResetAndDestroy(); |
1274 iItems.ResetAndDestroy(); |
1323 iItemCount = 0; |
1275 iItemCount = 0; |
1324 iSelectedIndex = KErrNotFound; |
1276 iSelectedIndex = KErrNotFound; |
1325 |
1277 |
1326 if( iManager ) |
1278 if( iManager ) |
1327 { |
1279 { |
1328 iManager->ResetBuffer( iSelectedIndex, iItemCount ); |
1280 iManager->ResetBuffer( iSelectedIndex, iItemCount ); |
1329 } |
1281 } |
1330 |
1282 |
1331 HandleItemCountChanged(); |
1283 HandleItemCountChanged(); |
1332 |
|
1333 iViewPosition = TPoint(iWidth/2, iHeight/2); |
|
1334 HandleViewPositionChanged(); |
|
1335 } |
1284 } |
1336 } |
1285 } |
1337 |
1286 |
1338 // ----------------------------------------------------------------------------- |
1287 // ----------------------------------------------------------------------------- |
1339 // CHgScroller::SetFlags() |
1288 // CHgScroller::SetFlags() |
1340 // ----------------------------------------------------------------------------- |
1289 // ----------------------------------------------------------------------------- |
1341 // |
1290 // |
1342 EXPORT_C void CHgScroller::SetFlags(TInt aFlags) |
1291 EXPORT_C void CHgScroller::SetFlags(TInt aFlags) |
1343 { |
1292 { |
1344 const TBool currentSelectionMode = iFlags & EHgScrollerSelectionMode; |
|
1345 const TBool newSelectionMode = aFlags & EHgScrollerSelectionMode; |
|
1346 if( currentSelectionMode != newSelectionMode ) |
|
1347 { |
|
1348 // when selection mode changes we need to repaint |
|
1349 DrawDeferred(); |
|
1350 } |
|
1351 |
|
1352 iFlags |= aFlags; |
1293 iFlags |= aFlags; |
1353 } |
1294 } |
1354 |
1295 |
1355 // ----------------------------------------------------------------------------- |
1296 // ----------------------------------------------------------------------------- |
1356 // CHgScroller::ClearFlags() |
1297 // CHgScroller::ClearFlags() |
1655 // CHgScroller::SetSelectionMode() |
1596 // CHgScroller::SetSelectionMode() |
1656 // --------------------------------------------------------------------------- |
1597 // --------------------------------------------------------------------------- |
1657 // |
1598 // |
1658 void CHgScroller::SetSelectionMode( TSelectionMode aMode ) |
1599 void CHgScroller::SetSelectionMode( TSelectionMode aMode ) |
1659 { |
1600 { |
1660 if( aMode != iSelectionMode ) |
|
1661 { |
|
1662 DrawDeferred(); |
|
1663 } |
|
1664 |
|
1665 iSelectionMode = aMode; |
1601 iSelectionMode = aMode; |
1666 if( iSelectionMode == ESelectionPossible |
1602 if( iSelectionMode == ESelectionPossible |
1667 || iSelectionMode == ENoSelection ) |
1603 || iSelectionMode == ENoSelection ) |
1668 { |
1604 { |
1669 iCoeEnv->InputCapabilitiesChanged(); |
1605 iCoeEnv->InputCapabilitiesChanged(); |
1670 } |
1606 } |
1671 |
|
1672 } |
1607 } |
1673 |
1608 |
1674 // --------------------------------------------------------------------------- |
1609 // --------------------------------------------------------------------------- |
1675 // CHgScroller::SelectionMode() |
1610 // CHgScroller::SelectionMode() |
1676 // --------------------------------------------------------------------------- |
1611 // --------------------------------------------------------------------------- |
1809 // --------------------------------------------------------------------------- |
1744 // --------------------------------------------------------------------------- |
1810 // |
1745 // |
1811 void CHgScroller::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/, |
1746 void CHgScroller::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/, |
1812 const TPoint& aPenEventScreenLocation) |
1747 const TPoint& aPenEventScreenLocation) |
1813 { |
1748 { |
1814 // Long tap is supported in marking mode only for an item that is marked. |
1749 if( iActionMenu ) |
1815 const TBool validIndex = iSelectedIndex != KErrNotFound && |
|
1816 iSelectedIndex >= 0 && iSelectedIndex < iItems.Count(); |
|
1817 const TBool selectionMode = iFlags & EHgScrollerSelectionMode; |
|
1818 const TBool longTapEnabled = validIndex && (!selectionMode || |
|
1819 (selectionMode && iItems[iSelectedIndex]->Flags() & CHgItem::EHgItemFlagMarked)); |
|
1820 |
|
1821 if( iActionMenu && longTapEnabled ) |
|
1822 { |
1750 { |
1823 iOldWinPos = DrawableWindow()->OrdinalPosition(); |
1751 iOldWinPos = DrawableWindow()->OrdinalPosition(); |
1824 iActionMenu->ShowMenuL(aPenEventScreenLocation); |
1752 iActionMenu->ShowMenuL(aPenEventScreenLocation); |
1825 iPointerDown = EFalse; |
1753 iPointerDown = EFalse; |
1826 } |
1754 } |