menufw/menufwui/mmwidgets/src/mmlistbox.cpp
branchRCL_3
changeset 9 f966699dea19
parent 4 4d54b72983ae
child 38 79311d856354
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
   133 // -----------------------------------------------------------------------------
   133 // -----------------------------------------------------------------------------
   134 //
   134 //
   135 void CMmListBox::HandlePointerEventInEditModeL(
   135 void CMmListBox::HandlePointerEventInEditModeL(
   136         const TPointerEvent& aPointerEvent )
   136         const TPointerEvent& aPointerEvent )
   137     {
   137     {
       
   138     CMmWidgetContainer* parent = static_cast<CMmWidgetContainer*>( Parent() );
   138     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
   139     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
   139         {
   140         {
   140         iButton1DownPos = aPointerEvent.iPosition;
   141         iButton1DownPos = aPointerEvent.iPosition;
   141         }
   142         }
   142     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   143     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
   143         {
   144         {
   144         CMmWidgetContainer* parent = static_cast<CMmWidgetContainer*>( Parent() );
       
   145         TPoint dragDelta = iButton1DownPos - aPointerEvent.iPosition;
   145         TPoint dragDelta = iButton1DownPos - aPointerEvent.iPosition;
   146         if ( Abs( dragDelta.iY ) > KDragTreshold || parent->LongTapInProgress() )
   146         if ( Abs( dragDelta.iY ) > KDragTreshold || parent->LongTapInProgress() )
   147             {
   147             {
   148             iListBoxFlags &= ~ELeftDownInViewRect;
   148             iListBoxFlags &= ~ELeftDownInViewRect;
   149             }
   149             }
   151     
   151     
   152     TInt itemUnderPointerIndex = KErrNotFound;
   152     TInt itemUnderPointerIndex = KErrNotFound;
   153     if ( aPointerEvent.iType == TPointerEvent::EButton1Up ||
   153     if ( aPointerEvent.iType == TPointerEvent::EButton1Up ||
   154             aPointerEvent.iType == TPointerEvent::EButton1Down )
   154             aPointerEvent.iType == TPointerEvent::EButton1Down )
   155         {
   155         {
       
   156         TBool highlightWasVisible = parent->IsHighlightVisible();
   156         CEikFormattedCellListBoxTypedef::HandlePointerEventL( aPointerEvent );
   157         CEikFormattedCellListBoxTypedef::HandlePointerEventL( aPointerEvent );
       
   158         // Tricky: Do not allow the base class implementation of HandlePointerEventL 
       
   159         //         to remove the highlight on EButton1Up event when context menu
       
   160         //         is displayed for an item
       
   161         if ( aPointerEvent.iType == TPointerEvent::EButton1Up &&
       
   162                 highlightWasVisible && parent->LongTapInProgress()
       
   163                 && !parent->IsHighlightVisible() )
       
   164             {
       
   165             ItemDrawer()->ClearFlags( CListItemDrawer::ESingleClickDisabledHighlight );
       
   166             }
   157         }
   167         }
   158     else if ( View()->XYPosToItemIndex(
   168     else if ( View()->XYPosToItemIndex(
   159             aPointerEvent.iPosition, itemUnderPointerIndex ) )
   169             aPointerEvent.iPosition, itemUnderPointerIndex ) )
   160         {
   170         {
   161         TInt currentItemIndex = CurrentItemIndex();
   171         TInt currentItemIndex = CurrentItemIndex();
   198 //
   208 //
   199 TBool CMmListBox::IsPointerInTopScrollingThreshold(
   209 TBool CMmListBox::IsPointerInTopScrollingThreshold(
   200             const TPointerEvent& aPointerEvent ) const
   210             const TPointerEvent& aPointerEvent ) const
   201     {
   211     {
   202     TInt topScrollingTreshold = Rect().iTl.iY
   212     TInt topScrollingTreshold = Rect().iTl.iY
   203         + ( MmEffects::KFocusScrollingThreshold
   213         + ( MmListBox::KFocusScrollingThreshold
   204             * TReal( View()->ItemSize().iHeight ) );
   214             * TReal( View()->ItemSize().iHeight ) );
   205 
   215 
   206     return ( aPointerEvent.iPosition.iY < topScrollingTreshold );
   216     return ( aPointerEvent.iPosition.iY < topScrollingTreshold );
   207     }
   217     }
   208 
   218 
   212 //
   222 //
   213 TBool CMmListBox::IsPointerInBottomScrollingThreshold(
   223 TBool CMmListBox::IsPointerInBottomScrollingThreshold(
   214             const TPointerEvent& aPointerEvent ) const
   224             const TPointerEvent& aPointerEvent ) const
   215     {
   225     {
   216     TInt bottomScrollingTreshold = Rect().iBr.iY
   226     TInt bottomScrollingTreshold = Rect().iBr.iY
   217         - ( MmEffects::KFocusScrollingThreshold
   227         - ( MmListBox::KFocusScrollingThreshold
   218             * TReal( View()->ItemSize().iHeight ) );
   228             * TReal( View()->ItemSize().iHeight ) );
   219 
   229 
   220     return ( aPointerEvent.iPosition.iY > bottomScrollingTreshold );
   230     return ( aPointerEvent.iPosition.iY > bottomScrollingTreshold );
   221     }
   231     }
   222 
   232 
   382 
   392 
   383 // -----------------------------------------------------------------------------
   393 // -----------------------------------------------------------------------------
   384 //
   394 //
   385 // -----------------------------------------------------------------------------
   395 // -----------------------------------------------------------------------------
   386 //
   396 //
   387 void CMmListBox::HandleRedrawTimerEvent()
   397 void CMmListBox::HandleRedrawTimerEventL()
   388     {
   398     {
   389     if ( iSkippedScrollbarEventsCount )
   399     if ( iSkippedScrollbarEventsCount )
   390         {
   400         {
   391         ProcessScrollEventL( ScrollBarFrame()->VerticalScrollBar(),
   401         ProcessScrollEventL( ScrollBarFrame()->VerticalScrollBar(),
   392                 EEikScrollThumbDragVert );
   402                 EEikScrollThumbDragVert );
   399 // -----------------------------------------------------------------------------
   409 // -----------------------------------------------------------------------------
   400 //
   410 //
   401 TInt CMmListBox::RedrawTimerCallback( TAny* aPtr )
   411 TInt CMmListBox::RedrawTimerCallback( TAny* aPtr )
   402     {
   412     {
   403     CMmListBox* self = static_cast<CMmListBox*>( aPtr );
   413     CMmListBox* self = static_cast<CMmListBox*>( aPtr );
   404     self->HandleRedrawTimerEvent();
   414     TRAP_IGNORE( self->HandleRedrawTimerEventL() );
       
   415     // Do not bother returning a meaningful error code, CPeriodic will ignore it
       
   416     // anyway.
   405     return 0;
   417     return 0;
   406     }
   418     }
   407 
   419 
   408 // -----------------------------------------------------------------------------
   420 // -----------------------------------------------------------------------------
   409 //
   421 //