javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtlistbox.cpp
branchRCL_3
changeset 19 71c436fe3ce0
parent 17 0fd27995241b
child 24 6c158198356e
equal deleted inserted replaced
18:9ac0a0a7da70 19:71c436fe3ce0
   138     MSwtDisplay& aDisplay,
   138     MSwtDisplay& aDisplay,
   139     TSwtPeer aPeer,
   139     TSwtPeer aPeer,
   140     MSwtComposite& aParent,
   140     MSwtComposite& aParent,
   141     TInt aStyle)
   141     TInt aStyle)
   142         : ASwtScrollableBase(aDisplay, aPeer, &aParent, aStyle)
   142         : ASwtScrollableBase(aDisplay, aPeer, &aParent, aStyle)
       
   143         , iFlickScrollingOngoing(EFalse)
       
   144 
   143 {
   145 {
   144 }
   146 }
   145 
   147 
   146 // ---------------------------------------------------------------------------
   148 // ---------------------------------------------------------------------------
   147 // CSwtListBox::~CSwtListBox
   149 // CSwtListBox::~CSwtListBox
   341     }
   343     }
   342 
   344 
   343     // Deliver event to scrollbar
   345     // Deliver event to scrollbar
   344     if (iVScrollBarGrabsPointerEvents && vsb)
   346     if (iVScrollBarGrabsPointerEvents && vsb)
   345     {
   347     {
   346         vsb->HandlePointerEventL(aPointerEvent);
   348         if (!iFlickScrollingOngoing
       
   349                 && aPointerEvent.iType == TPointerEvent::EButton1Down)
       
   350         {
       
   351             // Scrollbar was tapped after scrolling stopped
       
   352             // by itself, so no need to redirect events
       
   353             iScrollbarPointerEventToListbox = EFalse;
       
   354         }
       
   355 
       
   356         if (iScrollbarPointerEventToListbox)
       
   357         {
       
   358             // Stops kinetic scrolling when scrollbar is tapped
       
   359             iList->HandlePointerEventL(aPointerEvent);
       
   360             // Continue delivering events until button up appears to prevent
       
   361             // some unexpected behavior in both scrollbar and listbox
       
   362             switch (aPointerEvent.iType)
       
   363             {
       
   364             case TPointerEvent::EButton1Up:
       
   365                 iScrollbarPointerEventToListbox = EFalse;
       
   366                 break;
       
   367             }
       
   368         }
       
   369         else
       
   370         {
       
   371             // Handles scrollbar behavior
       
   372             vsb->HandlePointerEventL(aPointerEvent);
       
   373         }
   347     }
   374     }
   348 
   375 
   349     // Deliver event to list
   376     // Deliver event to list
   350     if (!iVScrollBarGrabsPointerEvents)
   377     if (!iVScrollBarGrabsPointerEvents)
   351     {
   378     {
   413     if (iVScrollBarGrabsPointerEvents
   440     if (iVScrollBarGrabsPointerEvents
   414             && aPointerEvent.iType == TPointerEvent::EButton1Up)
   441             && aPointerEvent.iType == TPointerEvent::EButton1Up)
   415     {
   442     {
   416         iVScrollBarGrabsPointerEvents = EFalse;
   443         iVScrollBarGrabsPointerEvents = EFalse;
   417     }
   444     }
       
   445 
       
   446     PostMouseEventL(aPointerEvent);
   418 }
   447 }
   419 #else //RD_SCALABLE_UI_V2
   448 #else //RD_SCALABLE_UI_V2
   420 void CSwtListBox::HandlePointerEventL(
   449 void CSwtListBox::HandlePointerEventL(
   421     const TPointerEvent& /*aPointerEvent*/)
   450     const TPointerEvent& /*aPointerEvent*/)
   422 {
   451 {
   470 {
   499 {
   471     TBool isFocused = IsFocusControl();
   500     TBool isFocused = IsFocusControl();
   472     // This gets called before contained list is created.
   501     // This gets called before contained list is created.
   473     if (iList)
   502     if (iList)
   474     {
   503     {
       
   504 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   505         EnableFocusHighlight(isFocused);
       
   506 #endif //RD_JAVA_S60_RELEASE_9_2
   475         iList->SetFocus(isFocused, aDrawNow);
   507         iList->SetFocus(isFocused, aDrawNow);
   476     }
   508     }
   477     HandleFocusChanged(aDrawNow);
   509     HandleFocusChanged(aDrawNow);
   478 }
   510 }
   479 
   511 
   643 // From MSwtControl
   675 // From MSwtControl
   644 // ---------------------------------------------------------------------------
   676 // ---------------------------------------------------------------------------
   645 //
   677 //
   646 void CSwtListBox::ProcessKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
   678 void CSwtListBox::ProcessKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
   647 {
   679 {
       
   680 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   681     if (aType == EEventKeyDown)
       
   682     {
       
   683         // After panning focus highlight was disabled, so enabling again
       
   684         EnableFocusHighlight(ETrue);
       
   685     }
       
   686 #endif //RD_JAVA_S60_RELEASE_9_2
       
   687 
   648     // No items or not a normal key event
   688     // No items or not a normal key event
   649     if (iList->Model()->NumberOfItems() == 0 || aType != EEventKey)
   689     if (iList->Model()->NumberOfItems() == 0 || aType != EEventKey)
   650     {
   690     {
   651         iList->OfferKeyEventL(aKeyEvent, aType);
   691         iList->OfferKeyEventL(aKeyEvent, aType);
   652         return;
   692         return;
   816 {
   856 {
   817     return EFalse;
   857     return EFalse;
   818 }
   858 }
   819 #endif
   859 #endif
   820 
   860 
       
   861 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   862 // ---------------------------------------------------------------------------
       
   863 // CSwtListBox::EnableFocusHighlight
       
   864 // From MSwtControl
       
   865 // ---------------------------------------------------------------------------
       
   866 //
       
   867 void CSwtListBox::EnableFocusHighlight(TBool aEnable)
       
   868 {
       
   869     ASSERT(iList);
       
   870     ASSERT(iList->View());
       
   871 
       
   872     CSwtListBoxLists::EnableFocusHighlight(iList->View()->ItemDrawer(),
       
   873                                            aEnable);
       
   874 }
       
   875 #endif //RD_JAVA_S60_RELEASE_9_2
       
   876 
   821 // ---------------------------------------------------------------------------
   877 // ---------------------------------------------------------------------------
   822 // CSwtListBox::Scrollable
   878 // CSwtListBox::Scrollable
   823 // From MSwtListBox
   879 // From MSwtListBox
   824 // ---------------------------------------------------------------------------
   880 // ---------------------------------------------------------------------------
   825 //
   881 //
  1327 {
  1383 {
  1328     if (aListBox != iList)
  1384     if (aListBox != iList)
  1329     {
  1385     {
  1330         return;
  1386         return;
  1331     }
  1387     }
       
  1388 
       
  1389     UpdateFlickScrollingState(aEventType);
  1332 
  1390 
  1333     switch (aEventType)
  1391     switch (aEventType)
  1334     {
  1392     {
  1335         // On 5.0, drawing trough Java gives simply a better fps.
  1393         // On 5.0, drawing trough Java gives simply a better fps.
  1336 #ifdef RD_JAVA_S60_RELEASE_9_2
  1394 #ifdef RD_JAVA_S60_RELEASE_9_2
  2478             break;
  2536             break;
  2479         }
  2537         }
  2480     }
  2538     }
  2481 }
  2539 }
  2482 #endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
  2540 #endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
       
  2541 
       
  2542 // ---------------------------------------------------------------------------
       
  2543 // CSwtTableListBox::UpdateFlickScrollingState
       
  2544 // Updates flick scrolling status based on received listbox event.
       
  2545 // ---------------------------------------------------------------------------
       
  2546 //
       
  2547 void CSwtListBox::UpdateFlickScrollingState(TListBoxEvent aEventType)
       
  2548 {
       
  2549     switch (aEventType)
       
  2550     {
       
  2551     case EEventFlickStarted:
       
  2552         iFlickScrollingOngoing = ETrue;
       
  2553         iScrollbarPointerEventToListbox = ETrue;
       
  2554         break;
       
  2555     case EEventFlickStopped:
       
  2556         iFlickScrollingOngoing = EFalse;
       
  2557         break;
       
  2558     }
       
  2559 }