uifw/ganes/src/HgScroller.cpp
branchRCL_3
changeset 64 85902f042028
parent 59 978afdc0236f
child 72 a5e7a4f63858
equal deleted inserted replaced
59:978afdc0236f 64:85902f042028
   889     iKeyRepeats = 0;
   889     iKeyRepeats = 0;
   890     iKeyScrollingState = ENoKeyScrolling;
   890     iKeyScrollingState = ENoKeyScrolling;
   891     
   891     
   892     iPointerDown = EFalse;
   892     iPointerDown = EFalse;
   893     iPanning = EFalse;
   893     iPanning = EFalse;
       
   894     iEnterKeyHandled = EFalse;
   894     }
   895     }
   895 
   896 
   896 // -----------------------------------------------------------------------------
   897 // -----------------------------------------------------------------------------
   897 // CHgScroller::KeyEventUp()
   898 // CHgScroller::KeyEventUp()
   898 // -----------------------------------------------------------------------------
   899 // -----------------------------------------------------------------------------
  1059         return;
  1060         return;
  1060     
  1061     
  1061     iViewPosition = aNewPosition;
  1062     iViewPosition = aNewPosition;
  1062     iPhysics->StopPhysics();
  1063     iPhysics->StopPhysics();
  1063     
  1064     
  1064     if( iScrollBarType == EHgScrollerTimeStrip )
  1065     // show a letter popup only if we are currently dragging with scrollbar
  1065         {
  1066     if(iScrollbar && iScrollbar->IsDragging())
  1066         // Show first item's time.
  1067         {
  1067         TInt selectedItem = CurrentIndex();
  1068         if( iScrollBarType == EHgScrollerTimeStrip )
  1068         if( selectedItem >= 0 && selectedItem < iItems.Count()
  1069             {
  1069                 && iItems[selectedItem]->Time().Int64() )
  1070             // Show first item's time.
  1070             {
  1071             TInt selectedItem = CurrentIndex();
  1071             TRAP_IGNORE(
  1072             if( selectedItem >= 0 && selectedItem < iItems.Count()
  1072                     iItems[selectedItem]->Time().FormatL( iPopupText1, KGanesMonthString );
  1073                     && iItems[selectedItem]->Time().Int64() )
  1073                     iItems[selectedItem]->Time().FormatL( iPopupText2, KGanesYearString );
       
  1074                 )
       
  1075             // To display month and year correctly in arabic.
       
  1076             AknTextUtils::LanguageSpecificNumberConversion( iPopupText1 );
       
  1077             AknTextUtils::LanguageSpecificNumberConversion( iPopupText2 );
       
  1078             }
       
  1079         }
       
  1080     else if( iScrollBarType == EHgScrollerLetterStrip
       
  1081             || iScrollBarType == EHgScrollerLetterStripLite )
       
  1082         {
       
  1083         TInt selectedItem = CurrentIndex();
       
  1084         if( selectedItem >= 0 && selectedItem < iItems.Count() )
       
  1085             {
       
  1086             if(iItems[selectedItem]->Title().Length())
       
  1087                 {
  1074                 {
  1088                 iPopupText1.Zero();
  1075                 TRAP_IGNORE(
  1089                 iPopupText1.Append( iItems[selectedItem]->Title()[0] );
  1076                         iItems[selectedItem]->Time().FormatL( iPopupText1, KGanesMonthString );
  1090                 iPopupText1.UpperCase();
  1077                         iItems[selectedItem]->Time().FormatL( iPopupText2, KGanesYearString );
       
  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                     }
  1091                 }
  1096                 }
  1092             }
  1097             }
  1093         }
  1098         }
  1094     HandleViewPositionChanged( EFalse );
  1099     HandleViewPositionChanged( EFalse );
  1095     DrawNow();
  1100     DrawNow();
  1189                 possibleKeyScrollingState = EKeyScrollingRight;
  1194                 possibleKeyScrollingState = EKeyScrollingRight;
  1190             break;
  1195             break;
  1191         case EKeyEnter:
  1196         case EKeyEnter:
  1192         case EKeyOK:
  1197         case EKeyOK:
  1193             {
  1198             {
  1194             if( iSelectedIndex != KErrNotFound && HasHighlight() )
  1199             // If enter key is pushed down for a long time, many key events
       
  1200             // are generated. Enter should be handled only ones.
       
  1201             if (!iEnterKeyHandled)
  1195                 {
  1202                 {
  1196                 iShowHighlight = EFalse;
  1203                 iEnterKeyHandled = ETrue;
  1197                 iDrawUtils->EnableMarquee(HasHighlight());
  1204                 if( iSelectedIndex != KErrNotFound && HasHighlight())
  1198                 if( iSelectionObserver )
  1205                     {                
  1199                     TRAP_IGNORE( iSelectionObserver->HandleOpenL( iSelectedIndex ); )
  1206                     iEnterKeyHandled = ETrue;
  1200                 return EKeyWasConsumed;
  1207                     const TBool validIndex = iSelectedIndex >= 0 && iSelectedIndex < iItems.Count();
  1201                 }
  1208                     const TBool selectionMode = iFlags & EHgScrollerSelectionMode;
  1202             else if( iItemCount )
  1209                     if (validIndex && selectionMode)
  1203                 {
  1210                         {
  1204                 iSelectedIndex = CurrentIndex();
  1211                         // In selection mode enterkey should mark/unmark item.
  1205                 FitSelectionToView();
  1212                         iItems[iSelectedIndex]->Flags() & CHgItem::EHgItemFlagMarked ? 
  1206                 iShowHighlight = ETrue;
  1213                             UnMark(iSelectedIndex) : Mark(iSelectedIndex);
  1207                 iDrawUtils->EnableMarquee(HasHighlight());
  1214                         DrawDeferred();
  1208                 DrawDeferred();
  1215                         }
  1209                 if( iSelectionObserver )
  1216                     else
  1210                     TRAP_IGNORE( iSelectionObserver->HandleSelectL( iSelectedIndex ); )
  1217                         {
  1211                 return EKeyWasConsumed;
  1218                         // Item will be opened so highlight is removed.
       
  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                     }
  1212                 }
  1239                 }
  1213             return EKeyWasNotConsumed;
  1240             return EKeyWasNotConsumed;
  1214             }
  1241             }
  1215         default:
  1242         default:
  1216             break;
  1243             break;
  1278     if(iItemCount)
  1305     if(iItemCount)
  1279         {
  1306         {
  1280         iHighlightTimer->Cancel();
  1307         iHighlightTimer->Cancel();
  1281         iPointerDown = EFalse;
  1308         iPointerDown = EFalse;
  1282         if(iDetector)
  1309         if(iDetector)
  1283             iDetector->CancelAnimationL();
  1310             {
       
  1311             TRAP_IGNORE(iDetector->CancelAnimationL());
       
  1312             }
  1284         iPanning = EFalse;
  1313         iPanning = EFalse;
  1285     
  1314     
  1286         iPhysics->StopPhysics();
  1315         iPhysics->StopPhysics();
  1287         iPhysics->ResetFriction();
  1316         iPhysics->ResetFriction();
  1288     
  1317