menufw/menufwui/mmwidgets/src/mmlistbox.cpp
changeset 4 4d54b72983ae
parent 2 08c6ee43b396
child 9 f966699dea19
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
    56 //
    56 //
    57 // -----------------------------------------------------------------------------
    57 // -----------------------------------------------------------------------------
    58 //
    58 //
    59 CMmListBox::~CMmListBox()
    59 CMmListBox::~CMmListBox()
    60 	{
    60 	{
       
    61 	delete iRedrawTimer;
    61 	}
    62 	}
    62 
    63 
    63 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
    64 //
    65 //
    65 // -----------------------------------------------------------------------------
    66 // -----------------------------------------------------------------------------
   114 	iModel = iMmModel = CMmListBoxModel::NewL();
   115 	iModel = iMmModel = CMmListBoxModel::NewL();
   115     CreateItemDrawerL( aTemplateLibrary );
   116     CreateItemDrawerL( aTemplateLibrary );
   116 
   117 
   117     EnableExtendedDrawingL();
   118     EnableExtendedDrawingL();
   118 
   119 
   119 
       
   120     iItemDrawer->SetDrawMark(EFalse);
   120     iItemDrawer->SetDrawMark(EFalse);
   121     CEikListBox::ConstructL(aParent,aFlags);
   121     CEikListBox::ConstructL(aParent,aFlags);
   122     iMmDrawer->SetView( this );
   122     iMmDrawer->SetView( this );
   123 	}
   123     iRedrawTimer = CPeriodic::NewL( EPriorityRealTime );
   124 
   124 	}
   125 // -----------------------------------------------------------------------------
   125 
   126 //
   126 // -----------------------------------------------------------------------------
       
   127 // Clearing ELeftDownInViewRect flag before invoking the base class
       
   128 // HandlePointerEventL method effectively prevents that method from doing most
       
   129 // of the things it would normally do in response to EButton1Down event.
       
   130 // This flag is explicitly cleared to achieve two things:
       
   131 // 1. Prevent kinetic scrolling (flick) in edit mode.
       
   132 // 2. Prevent highlight removal when popup menu is displayed.
   127 // -----------------------------------------------------------------------------
   133 // -----------------------------------------------------------------------------
   128 //
   134 //
   129 void CMmListBox::HandlePointerEventInEditModeL(
   135 void CMmListBox::HandlePointerEventInEditModeL(
   130         const TPointerEvent& aPointerEvent )
   136         const TPointerEvent& aPointerEvent )
   131     {
   137     {
       
   138     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   139         {
       
   140         iButton1DownPos = aPointerEvent.iPosition;
       
   141         }
       
   142     else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   143         {
       
   144         CMmWidgetContainer* parent = static_cast<CMmWidgetContainer*>( Parent() );
       
   145         TPoint dragDelta = iButton1DownPos - aPointerEvent.iPosition;
       
   146         if ( Abs( dragDelta.iY ) > KDragTreshold || parent->LongTapInProgress() )
       
   147             {
       
   148             iListBoxFlags &= ~ELeftDownInViewRect;
       
   149             }
       
   150         }
       
   151     
   132     TInt itemUnderPointerIndex = KErrNotFound;
   152     TInt itemUnderPointerIndex = KErrNotFound;
   133     if ( aPointerEvent.iType == TPointerEvent::EButton1Up ||
   153     if ( aPointerEvent.iType == TPointerEvent::EButton1Up ||
   134             aPointerEvent.iType == TPointerEvent::EButton1Down )
   154             aPointerEvent.iType == TPointerEvent::EButton1Down )
   135         {
   155         {
   136         iListBoxFlags &= ~ELeftDownInViewRect; // prevent kinetic scrolling
       
   137         CEikFormattedCellListBoxTypedef::HandlePointerEventL( aPointerEvent );
   156         CEikFormattedCellListBoxTypedef::HandlePointerEventL( aPointerEvent );
   138         }
   157         }
   139     else if ( View()->XYPosToItemIndex(
   158     else if ( View()->XYPosToItemIndex(
   140             aPointerEvent.iPosition, itemUnderPointerIndex ) )
   159             aPointerEvent.iPosition, itemUnderPointerIndex ) )
   141         {
   160         {
   346                 gc->SetBrushColor( BackColor() );
   365                 gc->SetBrushColor( BackColor() );
   347                 gc->Clear( scrollbarRect );
   366                 gc->Clear( scrollbarRect );
   348                 }
   367                 }
   349             }
   368             }
   350         }
   369         }
       
   370     }
       
   371 
       
   372 // -----------------------------------------------------------------------------
       
   373 //
       
   374 // -----------------------------------------------------------------------------
       
   375 //
       
   376 void CMmListBox::ProcessScrollEventL( CEikScrollBar* aScrollBar, 
       
   377             TEikScrollEvent aEventType )
       
   378     {
       
   379     CEikFormattedCellListBoxTypedef::HandleScrollEventL(
       
   380             aScrollBar, aEventType );
       
   381     }
       
   382 
       
   383 // -----------------------------------------------------------------------------
       
   384 //
       
   385 // -----------------------------------------------------------------------------
       
   386 //
       
   387 void CMmListBox::HandleRedrawTimerEvent()
       
   388     {
       
   389     if ( iSkippedScrollbarEventsCount )
       
   390         {
       
   391         ProcessScrollEventL( ScrollBarFrame()->VerticalScrollBar(),
       
   392                 EEikScrollThumbDragVert );
       
   393         }
       
   394     iSkippedScrollbarEventsCount = 0;
       
   395     }
       
   396     
       
   397 // -----------------------------------------------------------------------------
       
   398 //
       
   399 // -----------------------------------------------------------------------------
       
   400 //
       
   401 TInt CMmListBox::RedrawTimerCallback( TAny* aPtr )
       
   402     {
       
   403     CMmListBox* self = static_cast<CMmListBox*>( aPtr );
       
   404     self->HandleRedrawTimerEvent();
       
   405     return 0;
   351     }
   406     }
   352 
   407 
   353 // -----------------------------------------------------------------------------
   408 // -----------------------------------------------------------------------------
   354 //
   409 //
   355 // -----------------------------------------------------------------------------
   410 // -----------------------------------------------------------------------------
   885 void CMmListBox::SetDisableChildComponentDrawing( TBool aDisable )
   940 void CMmListBox::SetDisableChildComponentDrawing( TBool aDisable )
   886     {
   941     {
   887     iDisableChildComponentDrawing = aDisable;
   942     iDisableChildComponentDrawing = aDisable;
   888     }
   943     }
   889 
   944 
       
   945 // -----------------------------------------------------------------------------
       
   946 //
       
   947 // -----------------------------------------------------------------------------
       
   948 //
       
   949 void CMmListBox::HandleScrollEventL( CEikScrollBar* aScrollBar, 
       
   950             TEikScrollEvent aEventType )
       
   951     {
       
   952     if ( aEventType == EEikScrollThumbDragVert && !iScrollbarThumbIsBeingDragged )
       
   953         {
       
   954         iScrollbarThumbIsBeingDragged = ETrue;
       
   955         static_cast<CMmListBoxItemDrawer*>(
       
   956                 View()->ItemDrawer() )->EnableCachedDataUse( ETrue );
       
   957         iRedrawTimer->Start( KScrollingRedrawInterval, KScrollingRedrawInterval,
       
   958                 TCallBack( &CMmListBox::RedrawTimerCallback, static_cast<TAny*>( this ) ) );
       
   959         }
       
   960     else if ( aEventType == EEikScrollThumbReleaseVert )
       
   961         {
       
   962         iScrollbarThumbIsBeingDragged = EFalse;
       
   963         static_cast<CMmListBoxItemDrawer*>(
       
   964                 View()->ItemDrawer() )->EnableCachedDataUse( EFalse );
       
   965         // The view will be redrawn with cache disabled when ProcessScrollEventL
       
   966         // calls the base class's HandleScrollEventL method -- no need to
       
   967         // explicitly redraw the view.
       
   968         iRedrawTimer->Cancel();
       
   969         }
       
   970 
       
   971     if ( !iScrollbarThumbIsBeingDragged )
       
   972         {
       
   973         ProcessScrollEventL( aScrollBar, aEventType );
       
   974         }
       
   975     else
       
   976         {
       
   977         __ASSERT_DEBUG( aEventType == EEikScrollThumbDragVert, User::Invariant() );
       
   978         ++iSkippedScrollbarEventsCount;
       
   979         }
       
   980     }
       
   981 
   890 // End of file
   982 // End of file