uifw/ganes/src/HgScroller.cpp
branchRCL_3
changeset 29 a8834a2e9a96
parent 25 941195f2d488
child 38 c52421ed5f07
equal deleted inserted replaced
25:941195f2d488 29:a8834a2e9a96
   370  :  iDefaultIcon( aDefaultIcon ),
   370  :  iDefaultIcon( aDefaultIcon ),
   371     iItemCount(aItemCount), 
   371     iItemCount(aItemCount), 
   372     iCurrentRow(-1),
   372     iCurrentRow(-1),
   373     iSelectedIndex(KErrNotFound),
   373     iSelectedIndex(KErrNotFound),
   374     iScrollBarType( EHgScrollerScrollBar ),
   374     iScrollBarType( EHgScrollerScrollBar ),
   375     iFirstTime(ETrue),
   375     iResetViewPosition(ETrue),
   376     iOldWinPos(KErrNotFound)
   376     iOldWinPos(KErrNotFound)
   377     {
   377     {
   378     // No implementation required
   378     // No implementation required
   379     }
   379     }
   380         
   380         
   421     {
   421     {
   422     // For to be able to pan on a empty area. 
   422     // For to be able to pan on a empty area. 
   423     // The world is set to be at least the size of the view.
   423     // The world is set to be at least the size of the view.
   424     TSize worldSize = TotalSize();
   424     TSize worldSize = TotalSize();
   425     
   425     
   426     if( !iLandscapeScrolling && (worldSize.iHeight < iHeight) )
   426     if( !iLandscapeScrolling && (worldSize.iHeight <= iHeight) )
       
   427         {
   427         worldSize.iHeight = iHeight;
   428         worldSize.iHeight = iHeight;
   428     
   429         iResetViewPosition = ETrue;
   429     if( iLandscapeScrolling && (worldSize.iWidth < iWidth) )
   430         }
       
   431     
       
   432     if( iLandscapeScrolling && (worldSize.iWidth <= iWidth) )
       
   433         {
   430         worldSize.iWidth = iWidth;
   434         worldSize.iWidth = iWidth;
       
   435         iResetViewPosition = ETrue;
       
   436         }
   431 
   437 
   432     iPhysics->InitPhysicsL( worldSize, 
   438     iPhysics->InitPhysicsL( worldSize, 
   433             TSize(iWidth, iHeight), 
   439                             TSize(iWidth, iHeight), 
   434             iLandscapeScrolling);
   440                             iLandscapeScrolling);
   435     }
   441     }
   436 
   442 
   437 // -----------------------------------------------------------------------------
   443 // -----------------------------------------------------------------------------
   438 // CHgScroller::Draw()
   444 // CHgScroller::Draw()
   439 // Draws the display.
   445 // Draws the display.
   514         iCoeEnv->ScreenDevice()->GetNearestFontInTwips(iPopupFont, fontSpecTitle);
   520         iCoeEnv->ScreenDevice()->GetNearestFontInTwips(iPopupFont, fontSpecTitle);
   515     
   521     
   516         iPopupDrawer->Init( Rect(), iPopupFont );
   522         iPopupDrawer->Init( Rect(), iPopupFont );
   517         }
   523         }
   518     
   524     
   519     if(iFirstTime)
   525     if(iResetViewPosition)
   520         {
   526         {
   521         iViewPosition = TPoint(iWidth/2, iHeight/2);
   527         iViewPosition = TPoint(iWidth/2, iHeight/2);
   522         iFirstTime = EFalse;
   528         iResetViewPosition = EFalse;
   523         }
   529         }
   524     
   530     
   525     HandleViewPositionChanged();
   531     HandleViewPositionChanged();
   526     
   532     
   527     TRAP_IGNORE( InitGraphicsL(); )
   533     TRAP_IGNORE( InitGraphicsL(); )
   605             {
   611             {
   606             if( iDetector && !HasHighlight() )
   612             if( iDetector && !HasHighlight() )
   607                 iDetector->PointerEventL( aEvent );
   613                 iDetector->PointerEventL( aEvent );
   608             
   614             
   609             HandleUpEventL( aEvent );
   615             HandleUpEventL( aEvent );
   610             iPointerDown = EFalse;
       
   611             }
   616             }
   612         }
   617         }
   613     }
   618     }
   614 
   619 
   615 // -----------------------------------------------------------------------------
   620 // -----------------------------------------------------------------------------
   775         // enable physics
   780         // enable physics
   776         TPoint drag = iStart - aEvent.iPosition;
   781         TPoint drag = iStart - aEvent.iPosition;
   777         if(iLandscapeScrolling && AknLayoutUtils::LayoutMirrored())
   782         if(iLandscapeScrolling && AknLayoutUtils::LayoutMirrored())
   778             drag = -drag;
   783             drag = -drag;
   779         iPhysics->StartPhysics(drag, iStartTime);
   784         iPhysics->StartPhysics(drag, iStartTime);
       
   785         iPointerDown = EFalse;
   780         }
   786         }
   781     else
   787     else
   782         {
   788         {
   783         HandleSelectionL();
       
   784         MTouchFeedback* feedback = MTouchFeedback::Instance();
   789         MTouchFeedback* feedback = MTouchFeedback::Instance();
   785         if ( feedback && iSelectedIndex != KErrNotFound )
   790         if ( feedback && iSelectedIndex != KErrNotFound )
   786             {
   791             {
   787             feedback->InstantFeedback( this, ETouchFeedbackList, ETouchFeedbackVibra, aEvent );
   792             feedback->InstantFeedback( this, ETouchFeedbackList, ETouchFeedbackVibra, aEvent );
   788             }
   793             }
       
   794 
       
   795         HandleSelectionL();
   789         }
   796         }
   790     }
   797     }
   791 
   798 
   792 // -----------------------------------------------------------------------------
   799 // -----------------------------------------------------------------------------
   793 // CHgScroller::HandleSelectionL()
   800 // CHgScroller::HandleSelectionL()
   802             {
   809             {
   803             // Highlight timer hasn't triggered so lets set the highlight.
   810             // Highlight timer hasn't triggered so lets set the highlight.
   804             // this is not usually the case since interval is 50ms but just to be sure.
   811             // this is not usually the case since interval is 50ms but just to be sure.
   805             SetHighlightL();
   812             SetHighlightL();
   806             }
   813             }
       
   814 
       
   815         iPointerDown = EFalse;
   807         
   816         
   808         // selection needs to be valid.
   817         // selection needs to be valid.
   809         if( iSelectedIndex >= 0 && iSelectedIndex < iItems.Count() )
   818         if( iSelectedIndex >= 0 && iSelectedIndex < iItems.Count() )
   810             {
   819             {
   811             if( iFlags & EHgScrollerSelectionMode || iSelectionMode != ENoSelection ) 
   820             if( iFlags & EHgScrollerSelectionMode || iSelectionMode != ENoSelection ) 
   828                     if(iSelectionObserver)
   837                     if(iSelectionObserver)
   829                         iSelectionObserver->HandleOpenL(iSelectedIndex);
   838                         iSelectionObserver->HandleOpenL(iSelectedIndex);
   830                     }
   839                     }
   831                 }
   840                 }
   832             }
   841             }
       
   842         }
       
   843     else
       
   844         {
       
   845         iPointerDown = EFalse;
   833         }
   846         }
   834     }
   847     }
   835 
   848 
   836 // -----------------------------------------------------------------------------
   849 // -----------------------------------------------------------------------------
   837 // CHgScroller::OfferKeyEventL()
   850 // CHgScroller::OfferKeyEventL()
  1178         case EKeyEnter:
  1191         case EKeyEnter:
  1179         case EKeyOK:
  1192         case EKeyOK:
  1180             {
  1193             {
  1181             if( iSelectedIndex != KErrNotFound && HasHighlight() )
  1194             if( iSelectedIndex != KErrNotFound && HasHighlight() )
  1182                 {
  1195                 {
       
  1196                 iShowHighlight = EFalse;
       
  1197                 iDrawUtils->EnableMarquee(HasHighlight());
  1183                 if( iSelectionObserver )
  1198                 if( iSelectionObserver )
  1184                     TRAP_IGNORE( iSelectionObserver->HandleOpenL( iSelectedIndex ); )
  1199                     TRAP_IGNORE( iSelectionObserver->HandleOpenL( iSelectedIndex ); )
  1185                 iShowHighlight = EFalse;
       
  1186                 iDrawUtils->EnableMarquee(HasHighlight());
       
  1187                 return EKeyWasConsumed;
  1200                 return EKeyWasConsumed;
  1188                 }
  1201                 }
  1189             else if( iItemCount )
  1202             else if( iItemCount )
  1190                 {
  1203                 {
  1191                 iSelectedIndex = iCurrentRow;
  1204                 iSelectedIndex = iCurrentRow;
  1192                 if( iSelectionObserver )
       
  1193                     TRAP_IGNORE( iSelectionObserver->HandleSelectL( iSelectedIndex ); )
       
  1194                 FitSelectionToView();
  1205                 FitSelectionToView();
  1195                 iShowHighlight = ETrue;
  1206                 iShowHighlight = ETrue;
  1196                 iDrawUtils->EnableMarquee(HasHighlight());
  1207                 iDrawUtils->EnableMarquee(HasHighlight());
  1197                 DrawDeferred();
  1208                 DrawDeferred();
       
  1209                 if( iSelectionObserver )
       
  1210                     TRAP_IGNORE( iSelectionObserver->HandleSelectL( iSelectedIndex ); )
  1198                 return EKeyWasConsumed;
  1211                 return EKeyWasConsumed;
  1199                 }
  1212                 }
  1200             return EKeyWasNotConsumed;
  1213             return EKeyWasNotConsumed;
  1201             }
  1214             }
  1202         default:
  1215         default: