uifw/ganes/src/HgScroller.cpp
branchRCL_3
changeset 21 978afdc0236f
parent 20 d48ab3b357f1
equal deleted inserted replaced
20:d48ab3b357f1 21:978afdc0236f
    13 *
    13 *
    14 * Description:    
    14 * Description:    
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
       
    19 // INCLUDE FILES
    18 // INCLUDE FILES
    20 #include <ganes/HgScroller.h>
    19 #include <ganes/HgScroller.h>
    21 
    20 
    22 #include <aknphysics.h>
    21 #include <aknphysics.h>
    23 
    22 
   588         if( aEvent.iType == TPointerEvent::EButton1Down )
   587         if( aEvent.iType == TPointerEvent::EButton1Down )
   589             {
   588             {
   590             iPointerDown = ETrue;
   589             iPointerDown = ETrue;
   591             HandleDownEventL( aEvent );
   590             HandleDownEventL( aEvent );
   592 
   591 
       
   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             
   593             if( iDetector 
   599             if( iDetector 
   594                     && iSelectedIndex != KErrNotFound 
   600                     && longTapEnabled
   595                     && !HasHighlight()
   601                     && !HasHighlight()
   596                     && !(iFlags & EHgScrollerSelectionMode)
       
   597                     && iActionMenu->InitMenuL() )
   602                     && iActionMenu->InitMenuL() )
   598                 {
   603                 {
   599                 iDetector->PointerEventL( aEvent );
   604                 iDetector->PointerEventL( aEvent );
   600                 }
   605                 }
   601             }
   606             }
  1270 //
  1275 //
  1271 EXPORT_C void CHgScroller::Reset()
  1276 EXPORT_C void CHgScroller::Reset()
  1272     {
  1277     {
  1273     if(iItemCount)
  1278     if(iItemCount)
  1274         {
  1279         {
       
  1280         iHighlightTimer->Cancel();
       
  1281         iPointerDown = EFalse;
       
  1282         if(iDetector)
       
  1283             iDetector->CancelAnimationL();
       
  1284         iPanning = EFalse;
       
  1285     
       
  1286         iPhysics->StopPhysics();
       
  1287         iPhysics->ResetFriction();
       
  1288     
       
  1289         iFocusedIndex = KErrNotFound;
       
  1290         iSelectionToFocusedItem = EFalse;
       
  1291         iDrawUtils->EnableMarquee(false);    
       
  1292     
  1275         iItems.ResetAndDestroy();
  1293         iItems.ResetAndDestroy();
  1276         iItemCount = 0;
  1294         iItemCount = 0;
  1277         iSelectedIndex = KErrNotFound;
  1295         iSelectedIndex = KErrNotFound;
  1278         
  1296         
  1279         if( iManager )
  1297         if( iManager )
  1280             {
  1298             {
  1281             iManager->ResetBuffer( iSelectedIndex, iItemCount );
  1299             iManager->ResetBuffer( iSelectedIndex, iItemCount );
  1282             }
  1300             }
  1283     
  1301     
  1284         HandleItemCountChanged();
  1302         HandleItemCountChanged();
       
  1303     
       
  1304         iViewPosition = TPoint(iWidth/2, iHeight/2);    
       
  1305         HandleViewPositionChanged();        
  1285         }
  1306         }
  1286     }
  1307     }
  1287 
  1308 
  1288 // -----------------------------------------------------------------------------
  1309 // -----------------------------------------------------------------------------
  1289 // CHgScroller::SetFlags()
  1310 // CHgScroller::SetFlags()
  1290 // -----------------------------------------------------------------------------
  1311 // -----------------------------------------------------------------------------
  1291 //
  1312 //
  1292 EXPORT_C void CHgScroller::SetFlags(TInt aFlags)
  1313 EXPORT_C void CHgScroller::SetFlags(TInt aFlags)
  1293     {
  1314     {
       
  1315     const TBool currentSelectionMode = iFlags & EHgScrollerSelectionMode;
       
  1316     const TBool newSelectionMode = aFlags & EHgScrollerSelectionMode;
       
  1317     if( currentSelectionMode != newSelectionMode )
       
  1318         {
       
  1319         // when selection mode changes we need to repaint
       
  1320         DrawDeferred();
       
  1321         }
       
  1322     
  1294     iFlags |= aFlags;
  1323     iFlags |= aFlags;
  1295     }
  1324     }
  1296 
  1325 
  1297 // -----------------------------------------------------------------------------
  1326 // -----------------------------------------------------------------------------
  1298 // CHgScroller::ClearFlags()
  1327 // CHgScroller::ClearFlags()
  1597 // CHgScroller::SetSelectionMode()
  1626 // CHgScroller::SetSelectionMode()
  1598 // ---------------------------------------------------------------------------
  1627 // ---------------------------------------------------------------------------
  1599 //     
  1628 //     
  1600 void CHgScroller::SetSelectionMode( TSelectionMode aMode )
  1629 void CHgScroller::SetSelectionMode( TSelectionMode aMode )
  1601     {
  1630     {
       
  1631     if( aMode != iSelectionMode )
       
  1632         {
       
  1633         DrawDeferred();
       
  1634         }
       
  1635     
  1602     iSelectionMode = aMode;
  1636     iSelectionMode = aMode;
  1603     if( iSelectionMode == ESelectionPossible
  1637     if( iSelectionMode == ESelectionPossible
  1604             || iSelectionMode == ENoSelection )
  1638             || iSelectionMode == ENoSelection )
  1605         {
  1639         {
  1606         iCoeEnv->InputCapabilitiesChanged();
  1640         iCoeEnv->InputCapabilitiesChanged();
  1607         }
  1641         }
       
  1642     
  1608     }
  1643     }
  1609 
  1644 
  1610 // ---------------------------------------------------------------------------
  1645 // ---------------------------------------------------------------------------
  1611 // CHgScroller::SelectionMode()
  1646 // CHgScroller::SelectionMode()
  1612 // ---------------------------------------------------------------------------
  1647 // ---------------------------------------------------------------------------
  1745 // ---------------------------------------------------------------------------
  1780 // ---------------------------------------------------------------------------
  1746 //     
  1781 //     
  1747 void CHgScroller::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/,
  1782 void CHgScroller::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/,
  1748                         const TPoint& aPenEventScreenLocation)
  1783                         const TPoint& aPenEventScreenLocation)
  1749     {
  1784     {
  1750     if( iActionMenu && !(iFlags & EHgScrollerSelectionMode) )
  1785     // Long tap is supported in marking mode only for an item that is marked.
       
  1786     const TBool validIndex = iSelectedIndex != KErrNotFound && 
       
  1787             iSelectedIndex >= 0 && iSelectedIndex < iItems.Count();
       
  1788     const TBool selectionMode = iFlags & EHgScrollerSelectionMode;
       
  1789     const TBool longTapEnabled = validIndex && (!selectionMode ||
       
  1790             (selectionMode && iItems[iSelectedIndex]->Flags() & CHgItem::EHgItemFlagMarked));
       
  1791     
       
  1792     if( iActionMenu && longTapEnabled )
  1751         {
  1793         {
  1752         iOldWinPos = DrawableWindow()->OrdinalPosition();
  1794         iOldWinPos = DrawableWindow()->OrdinalPosition();
  1753         iActionMenu->ShowMenuL(aPenEventScreenLocation);
  1795         iActionMenu->ShowMenuL(aPenEventScreenLocation);
  1754         iPointerDown = EFalse;
  1796         iPointerDown = EFalse;
  1755         }
  1797         }