uifw/ganes/src/HgScroller.cpp
branchRCL_3
changeset 4 8ca85d2f0db7
parent 0 2f259fa3e83a
child 9 aabf2c525e0f
equal deleted inserted replaced
0:2f259fa3e83a 4:8ca85d2f0db7
    70     iPopupText1.CreateL( KMaxPopupTextLength );
    70     iPopupText1.CreateL( KMaxPopupTextLength );
    71     iPopupText2.CreateL( KMaxPopupTextLength );
    71     iPopupText2.CreateL( KMaxPopupTextLength );
    72     
    72     
    73     iScrollbar = CHgScrollbar::NewL(*this);
    73     iScrollbar = CHgScrollbar::NewL(*this);
    74     iPopupDrawer = new (ELeave) THgPopupDrawer();
    74     iPopupDrawer = new (ELeave) THgPopupDrawer();
    75     
    75     iPhysics = CAknPhysics::NewL(*this, this);
       
    76 
    76     TCallBack callback(CHgScroller::MarqueeCallback, this);
    77     TCallBack callback(CHgScroller::MarqueeCallback, this);
    77     iDrawUtils = CHgDrawUtils::NewL( callback );
    78     iDrawUtils = CHgDrawUtils::NewL( callback );
    78     
    79     
    79     iIndicatorManager = CHgIndicatorManager::NewL();
    80     iIndicatorManager = CHgIndicatorManager::NewL();
    80 
    81 
   401 // CHgScroller::InitPhysicsL()
   402 // CHgScroller::InitPhysicsL()
   402 // -----------------------------------------------------------------------------
   403 // -----------------------------------------------------------------------------
   403 //
   404 //
   404 void CHgScroller::InitPhysicsL()
   405 void CHgScroller::InitPhysicsL()
   405     {
   406     {
   406     if(!iPhysics)
       
   407         {
       
   408         iPhysics = CAknPhysics::NewL(*this, this);
       
   409         }
       
   410 
       
   411     // For to be able to pan on a empty area. 
   407     // For to be able to pan on a empty area. 
   412     // The world is set to be at least the size of the view.
   408     // The world is set to be at least the size of the view.
   413     TSize worldSize = TotalSize();
   409     TSize worldSize = TotalSize();
   414     
   410     
   415     if( !iLandscapeScrolling && (worldSize.iHeight < iHeight) )
   411     if( !iLandscapeScrolling && (worldSize.iHeight < iHeight) )
   836     iKeyRepeats = 0;
   832     iKeyRepeats = 0;
   837     iKeyScrollingState = ENoKeyScrolling;
   833     iKeyScrollingState = ENoKeyScrolling;
   838     
   834     
   839     iPointerDown = EFalse;
   835     iPointerDown = EFalse;
   840     iPanning = EFalse;
   836     iPanning = EFalse;
   841     iShowHighlight = ETrue;
       
   842     iDrawUtils->EnableMarquee(HasHighlight());
       
   843     }
   837     }
   844 
   838 
   845 // -----------------------------------------------------------------------------
   839 // -----------------------------------------------------------------------------
   846 // CHgScroller::KeyEventUp()
   840 // CHgScroller::KeyEventUp()
   847 // -----------------------------------------------------------------------------
   841 // -----------------------------------------------------------------------------
  1029             {
  1023             {
  1030             if(iItems[selectedItem]->Title().Length())
  1024             if(iItems[selectedItem]->Title().Length())
  1031                 {
  1025                 {
  1032                 iPopupText1.Zero();
  1026                 iPopupText1.Zero();
  1033                 iPopupText1.Append( iItems[selectedItem]->Title()[0] );
  1027                 iPopupText1.Append( iItems[selectedItem]->Title()[0] );
       
  1028                 iPopupText1.UpperCase();
  1034                 }
  1029                 }
  1035             }
  1030             }
  1036         }
  1031         }
  1037     HandleViewPositionChanged( EFalse );
  1032     HandleViewPositionChanged( EFalse );
  1038     DrawNow();
  1033     DrawNow();
  1070         iScrollbar->SetViewPosition( iViewPosition - TPoint(iWidth/2, iHeight/2));
  1065         iScrollbar->SetViewPosition( iViewPosition - TPoint(iWidth/2, iHeight/2));
  1071 
  1066 
  1072     if(newRow != iCurrentRow)
  1067     if(newRow != iCurrentRow)
  1073         {
  1068         {
  1074         iCurrentRow = newRow;
  1069         iCurrentRow = newRow;
       
  1070         
       
  1071         TInt action = iPhysics->OngoingPhysicsAction();
       
  1072         if( action !=  CAknPhysics::EAknPhysicsActionNone )
       
  1073             {
       
  1074             TTouchFeedbackType type( ETouchFeedbackVibra );
       
  1075             if ( CAknPhysics::EAknPhysicsActionDragging == action )
       
  1076                 {
       
  1077                 type = TTouchFeedbackType(ETouchFeedbackVibra | ETouchFeedbackAudio);
       
  1078                 }
       
  1079 
       
  1080             MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  1081             if(feedback)
       
  1082                 feedback->InstantFeedback( this, ETouchFeedbackSensitiveList,
       
  1083                                             type,
       
  1084                                             TPointerEvent() );
       
  1085             }
  1075 
  1086 
  1076         if(iManager)
  1087         if(iManager)
  1077             {
  1088             {
  1078             iManager->SetPosition( CurrentIndex() );
  1089             iManager->SetPosition( CurrentIndex() );
  1079             }
  1090             }
  1117         case EKeyRightArrow:
  1128         case EKeyRightArrow:
  1118             if( iLandscapeScrolling )
  1129             if( iLandscapeScrolling )
  1119                 possibleKeyScrollingState = EKeyScrollingRight;
  1130                 possibleKeyScrollingState = EKeyScrollingRight;
  1120             break;
  1131             break;
  1121         case EKeyEnter:
  1132         case EKeyEnter:
  1122             {
  1133         case EKeyOK:
  1123             if( iSelectedIndex != KErrNotFound && iSelectionObserver )
  1134             {
  1124                 {
  1135             if( iSelectedIndex != KErrNotFound && HasHighlight() )
  1125                 TRAP_IGNORE( iSelectionObserver->HandleOpenL( iSelectedIndex ); )
  1136                 {
       
  1137                 if( iSelectionObserver )
       
  1138                     TRAP_IGNORE( iSelectionObserver->HandleOpenL( iSelectedIndex ); )
       
  1139                 iShowHighlight = EFalse;
       
  1140                 iDrawUtils->EnableMarquee(HasHighlight());
       
  1141                 return EKeyWasConsumed;
       
  1142                 }
       
  1143             else if( iItemCount )
       
  1144                 {
       
  1145                 iSelectedIndex = iCurrentRow;
       
  1146                 if( iSelectionObserver )
       
  1147                     TRAP_IGNORE( iSelectionObserver->HandleSelectL( iSelectedIndex ); )
       
  1148                 FitSelectionToView();
       
  1149                 iShowHighlight = ETrue;
       
  1150                 iDrawUtils->EnableMarquee(HasHighlight());
       
  1151                 DrawDeferred();
  1126                 return EKeyWasConsumed;
  1152                 return EKeyWasConsumed;
  1127                 }
  1153                 }
  1128             return EKeyWasNotConsumed;
  1154             return EKeyWasNotConsumed;
  1129             }
  1155             }
  1130         default:
  1156         default:
  1142                     TTimeIntervalMicroSeconds32( 0 ),
  1168                     TTimeIntervalMicroSeconds32( 0 ),
  1143                     TTimeIntervalMicroSeconds32( KKeyScrollingUpdateInterval ), 
  1169                     TTimeIntervalMicroSeconds32( KKeyScrollingUpdateInterval ), 
  1144                     TCallBack( KeyScrollingTimerCallback, this ) );
  1170                     TCallBack( KeyScrollingTimerCallback, this ) );
  1145             }
  1171             }
  1146         }
  1172         }
  1147     
  1173 
  1148     TBool handled = DoHandleKeyEvent(aKeyEvent); 
  1174     if( !HasHighlight() )
  1149     
  1175         {
  1150     if( iSelectedIndex != prevSelected && iSelectionObserver )
  1176         // DoHandleKeyEvent will move focus at the first index on screen.  
  1151         {
  1177         iSelectedIndex = KErrNotFound;
  1152         iDrawUtils->ResetMarquee();
  1178         }
  1153         TRAP_IGNORE( iSelectionObserver->HandleSelectL(iSelectedIndex); )
  1179     
  1154         }
  1180     if( DoHandleKeyEvent(aKeyEvent) )
  1155     
  1181         {
  1156     if( !handled )
  1182         iShowHighlight = ETrue;
       
  1183         iDrawUtils->EnableMarquee(HasHighlight());
       
  1184         if( iSelectedIndex != prevSelected && iSelectionObserver )
       
  1185             {
       
  1186             iDrawUtils->ResetMarquee();
       
  1187             TRAP_IGNORE( iSelectionObserver->HandleSelectL(iSelectedIndex); )
       
  1188             }
       
  1189         return EKeyWasConsumed;
       
  1190         }
       
  1191     else
       
  1192         {
  1157         iKeyRepeats--;
  1193         iKeyRepeats--;
  1158     
  1194         return EKeyWasNotConsumed;
  1159     return handled ? EKeyWasConsumed : EKeyWasNotConsumed;
  1195         }
  1160     }
  1196     }
  1161 
  1197 
  1162 // -----------------------------------------------------------------------------
  1198 // -----------------------------------------------------------------------------
  1163 // CHgScroller::Release()
  1199 // CHgScroller::Release()
  1164 // -----------------------------------------------------------------------------
  1200 // -----------------------------------------------------------------------------