menufw/menufwui/mmwidgets/src/mmgrid.cpp
branchRCL_3
changeset 9 f966699dea19
parent 5 c743ef5928ba
child 16 9674c1a575e9
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *  Version     : %version: MM_98 % << Don't touch! Updated by Synergy at check-out.
    15 *  Version     : %version: MM_101 % << Don't touch! Updated by Synergy at check-out.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 #include <AknsDrawUtils.h>
    20 #include <AknsDrawUtils.h>
   255 // 2. Prevent highlight removal when popup menu is displayed.
   255 // 2. Prevent highlight removal when popup menu is displayed.
   256 // -----------------------------------------------------------------------------
   256 // -----------------------------------------------------------------------------
   257 //
   257 //
   258 void CMmGrid::HandlePointerEventInEditModeL( const TPointerEvent& aPointerEvent )
   258 void CMmGrid::HandlePointerEventInEditModeL( const TPointerEvent& aPointerEvent )
   259     {
   259     {
       
   260     CMmWidgetContainer* parent = static_cast<CMmWidgetContainer*>( Parent() );
   260     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
   261     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
   261         {
   262         {
   262         iButton1DownPos = aPointerEvent.iPosition;
   263         iButton1DownPos = aPointerEvent.iPosition;
   263         }
   264         }
   264     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   265     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   265         {
   266         {
   266         CMmWidgetContainer* parent = static_cast<CMmWidgetContainer*>( Parent() );
       
   267         TPoint dragDelta = iButton1DownPos - aPointerEvent.iPosition;
   267         TPoint dragDelta = iButton1DownPos - aPointerEvent.iPosition;
   268         if ( Abs( dragDelta.iY ) > KDragTreshold || parent->LongTapInProgress() )
   268         if ( Abs( dragDelta.iY ) > KDragTreshold || parent->LongTapInProgress() )
   269             {
   269             {
   270             iListBoxFlags &= ~ELeftDownInViewRect;
   270             iListBoxFlags &= ~ELeftDownInViewRect;
   271             }
   271             }
   273 
   273 
   274     TInt itemUnderPointerIndex = KErrNotFound;
   274     TInt itemUnderPointerIndex = KErrNotFound;
   275     if ( aPointerEvent.iType == TPointerEvent::EButton1Up ||
   275     if ( aPointerEvent.iType == TPointerEvent::EButton1Up ||
   276             aPointerEvent.iType == TPointerEvent::EButton1Down )
   276             aPointerEvent.iType == TPointerEvent::EButton1Down )
   277         {
   277         {
       
   278         TBool highlightWasVisible = parent->IsHighlightVisible();
   278         CAknGrid::HandlePointerEventL( aPointerEvent );
   279         CAknGrid::HandlePointerEventL( aPointerEvent );
       
   280         // Tricky: Do not allow the base class implementation of HandlePointerEventL 
       
   281         //         to remove the highlight on EButton1Up event when context menu
       
   282         //         is displayed for an item
       
   283         if ( aPointerEvent.iType == TPointerEvent::EButton1Up &&
       
   284                 highlightWasVisible && parent->LongTapInProgress()
       
   285                 && !parent->IsHighlightVisible() )
       
   286             {
       
   287             ItemDrawer()->ClearFlags( CListItemDrawer::ESingleClickDisabledHighlight );
       
   288             }
   279         }
   289         }
   280     else if ( View()->XYPosToItemIndex(
   290     else if ( View()->XYPosToItemIndex(
   281             aPointerEvent.iPosition, itemUnderPointerIndex ) )
   291             aPointerEvent.iPosition, itemUnderPointerIndex ) )
   282         {
   292         {
   283         if ( CurrentItemIndex() != itemUnderPointerIndex )
   293         if ( CurrentItemIndex() != itemUnderPointerIndex )
   406 //
   416 //
   407 TBool CMmGrid::IsPointerInTopScrollingThreshold(
   417 TBool CMmGrid::IsPointerInTopScrollingThreshold(
   408             const TPointerEvent& aPointerEvent ) const
   418             const TPointerEvent& aPointerEvent ) const
   409     {
   419     {
   410     TInt topScrollingTreshold = Rect().iTl.iY
   420     TInt topScrollingTreshold = Rect().iTl.iY
   411         + ( MmEffects::KFocusScrollingThreshold
   421         + ( MmGrid::KFocusScrollingThreshold
   412             * TReal( View()->ItemSize().iHeight ) );
   422             * TReal( View()->ItemSize().iHeight ) );
   413 
   423 
   414     return ( aPointerEvent.iPosition.iY < topScrollingTreshold );
   424     return ( aPointerEvent.iPosition.iY < topScrollingTreshold );
   415     }
   425     }
   416 
   426 
   420 //
   430 //
   421 TBool CMmGrid::IsPointerInBottomScrollingThreshold(
   431 TBool CMmGrid::IsPointerInBottomScrollingThreshold(
   422             const TPointerEvent& aPointerEvent ) const
   432             const TPointerEvent& aPointerEvent ) const
   423     {
   433     {
   424     TInt bottomScrollingTreshold = Rect().iBr.iY
   434     TInt bottomScrollingTreshold = Rect().iBr.iY
   425         - ( MmEffects::KFocusScrollingThreshold
   435         - ( MmGrid::KFocusScrollingThreshold
   426             * TReal( View()->ItemSize().iHeight ) );
   436             * TReal( View()->ItemSize().iHeight ) );
   427 
   437 
   428     return ( aPointerEvent.iPosition.iY > bottomScrollingTreshold );
   438     return ( aPointerEvent.iPosition.iY > bottomScrollingTreshold );
   429     }
   439     }
   430 
   440 
  1014 
  1024 
  1015 // -----------------------------------------------------------------------------
  1025 // -----------------------------------------------------------------------------
  1016 //
  1026 //
  1017 // -----------------------------------------------------------------------------
  1027 // -----------------------------------------------------------------------------
  1018 //
  1028 //
  1019 void CMmGrid::HandleRedrawTimerEvent()
  1029 void CMmGrid::HandleRedrawTimerEventL()
  1020     {
  1030     {
  1021     if ( iSkippedScrollbarEventsCount )
  1031     if ( iSkippedScrollbarEventsCount )
  1022         {
  1032         {
  1023         ProcessScrollEventL( ScrollBarFrame()->VerticalScrollBar(),
  1033         ProcessScrollEventL( ScrollBarFrame()->VerticalScrollBar(),
  1024                 EEikScrollThumbDragVert );
  1034                 EEikScrollThumbDragVert );
  1031 // -----------------------------------------------------------------------------
  1041 // -----------------------------------------------------------------------------
  1032 //
  1042 //
  1033 TInt CMmGrid::RedrawTimerCallback( TAny* aPtr )
  1043 TInt CMmGrid::RedrawTimerCallback( TAny* aPtr )
  1034     {
  1044     {
  1035     CMmGrid* self = static_cast<CMmGrid*>( aPtr );
  1045     CMmGrid* self = static_cast<CMmGrid*>( aPtr );
  1036     self->HandleRedrawTimerEvent();
  1046     TRAP_IGNORE( self->HandleRedrawTimerEventL() );
       
  1047     // Do not bother returning a meaningful error code, CPeriodic will ignore it
       
  1048     // anyway.
  1037     return 0;
  1049     return 0;
  1038     }
  1050     }
  1039 
  1051 
  1040 // -----------------------------------------------------------------------------
  1052 // -----------------------------------------------------------------------------
  1041 //
  1053 //