javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtlistbase.cpp
branchRCL_3
changeset 19 71c436fe3ce0
parent 17 0fd27995241b
child 24 6c158198356e
equal deleted inserted replaced
18:9ac0a0a7da70 19:71c436fe3ce0
   533 //
   533 //
   534 CSwtListBase::CSwtListBase(
   534 CSwtListBase::CSwtListBase(
   535     MSwtDisplay& aDisplay,
   535     MSwtDisplay& aDisplay,
   536     TSwtPeer aPeer,
   536     TSwtPeer aPeer,
   537     MSwtComposite& aParent,
   537     MSwtComposite& aParent,
   538     TInt aStyle) :
   538     TInt aStyle)
   539         ASwtScrollableBase(aDisplay, aPeer, &aParent, aStyle)
   539         : ASwtScrollableBase(aDisplay, aPeer, &aParent, aStyle)
       
   540         , iFlickScrollingOngoing(EFalse)
   540 {
   541 {
   541 }
   542 }
   542 
   543 
   543 // ---------------------------------------------------------------------------
   544 // ---------------------------------------------------------------------------
   544 // CSwtListBase::~CSwtListBase
   545 // CSwtListBase::~CSwtListBase
   956     }
   957     }
   957 
   958 
   958     // Deliver event to scrollbar
   959     // Deliver event to scrollbar
   959     if (iVScrollBarGrabsPointerEvents && vsb)
   960     if (iVScrollBarGrabsPointerEvents && vsb)
   960     {
   961     {
   961         vsb->HandlePointerEventL(aPointerEvent);
   962         if (!iFlickScrollingOngoing
       
   963                 && aPointerEvent.iType == TPointerEvent::EButton1Down)
       
   964         {
       
   965             // Scrollbar was tapped after scrolling stopped
       
   966             // by itself, so no need to redirect events
       
   967             iScrollbarPointerEventToListbox = EFalse;
       
   968         }
       
   969 
       
   970         if (iScrollbarPointerEventToListbox)
       
   971         {
       
   972             // Stops kinetic scrolling when scrollbar is tapped
       
   973             iList->HandlePointerEventL(aPointerEvent);
       
   974             // Continue delivering events until button up appears to prevent
       
   975             // some unexpected behavior in both scrollbar and listbox
       
   976             switch (aPointerEvent.iType)
       
   977             {
       
   978             case TPointerEvent::EButton1Up:
       
   979                 iScrollbarPointerEventToListbox = EFalse;
       
   980                 break;
       
   981             }
       
   982         }
       
   983         else
       
   984         {
       
   985             // Handles scrollbar behavior
       
   986             vsb->HandlePointerEventL(aPointerEvent);
       
   987         }
   962     }
   988     }
   963 
   989 
   964     // Deliver event to list
   990     // Deliver event to list
   965     if (!iVScrollBarGrabsPointerEvents)
   991     if (!iVScrollBarGrabsPointerEvents)
   966     {
   992     {
  1028     if (iVScrollBarGrabsPointerEvents
  1054     if (iVScrollBarGrabsPointerEvents
  1029             && aPointerEvent.iType == TPointerEvent::EButton1Up)
  1055             && aPointerEvent.iType == TPointerEvent::EButton1Up)
  1030     {
  1056     {
  1031         iVScrollBarGrabsPointerEvents = EFalse;
  1057         iVScrollBarGrabsPointerEvents = EFalse;
  1032     }
  1058     }
       
  1059 
       
  1060     PostMouseEventL(aPointerEvent);
  1033 }
  1061 }
  1034 #else //RD_SCALABLE_UI_V2
  1062 #else //RD_SCALABLE_UI_V2
  1035 void CSwtListBase::HandlePointerEventL(
  1063 void CSwtListBase::HandlePointerEventL(
  1036     const TPointerEvent& /*aPointerEvent*/)
  1064     const TPointerEvent& /*aPointerEvent*/)
  1037 {
  1065 {
  1067 void CSwtListBase::FocusChanged(TDrawNow aDrawNow)
  1095 void CSwtListBase::FocusChanged(TDrawNow aDrawNow)
  1068 {
  1096 {
  1069     ASSERT(iList);
  1097     ASSERT(iList);
  1070 
  1098 
  1071     TBool isFocused = IsFocusControl();
  1099     TBool isFocused = IsFocusControl();
       
  1100 #ifdef RD_JAVA_S60_RELEASE_9_2
       
  1101     EnableFocusHighlight(isFocused);
       
  1102 #endif //RD_JAVA_S60_RELEASE_9_2
  1072     iList->SetFocus(isFocused, aDrawNow);
  1103     iList->SetFocus(isFocused, aDrawNow);
  1073     HandleFocusChanged(aDrawNow);
  1104     HandleFocusChanged(aDrawNow);
  1074 }
  1105 }
  1075 
  1106 
  1076 // ---------------------------------------------------------------------------
  1107 // ---------------------------------------------------------------------------
  1205 // From MSwtControl
  1236 // From MSwtControl
  1206 // ---------------------------------------------------------------------------
  1237 // ---------------------------------------------------------------------------
  1207 //
  1238 //
  1208 void CSwtListBase::ProcessKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
  1239 void CSwtListBase::ProcessKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
  1209 {
  1240 {
       
  1241 #ifdef RD_JAVA_S60_RELEASE_9_2
       
  1242     if (aType == EEventKeyDown)
       
  1243     {
       
  1244         // After panning focus highlight was disabled, so enabling again
       
  1245         EnableFocusHighlight(ETrue);
       
  1246     }
       
  1247 #endif //RD_JAVA_S60_RELEASE_9_2
       
  1248 
  1210     // No items or not a normal key event
  1249     // No items or not a normal key event
  1211     if (iList->Model()->NumberOfItems() == 0 || aType != EEventKey)
  1250     if (iList->Model()->NumberOfItems() == 0 || aType != EEventKey)
  1212     {
  1251     {
  1213         iList->OfferKeyEventL(aKeyEvent, aType);
  1252         iList->OfferKeyEventL(aKeyEvent, aType);
  1214         return;
  1253         return;
  1367 TBool CSwtListBase::IsLongTapAnimationCandidate(const TPointerEvent& /*aPointerEvent*/) const
  1406 TBool CSwtListBase::IsLongTapAnimationCandidate(const TPointerEvent& /*aPointerEvent*/) const
  1368 {
  1407 {
  1369     return EFalse;
  1408     return EFalse;
  1370 }
  1409 }
  1371 #endif
  1410 #endif
       
  1411 
       
  1412 #ifdef RD_JAVA_S60_RELEASE_9_2
       
  1413 // ---------------------------------------------------------------------------
       
  1414 // CSwtListBase::EnableFocusHighlight
       
  1415 // From MSwtControl
       
  1416 // ---------------------------------------------------------------------------
       
  1417 //
       
  1418 void CSwtListBase::EnableFocusHighlight(TBool aEnable)
       
  1419 {
       
  1420     ASSERT(iList);
       
  1421     ASSERT(iList->View());
       
  1422 
       
  1423     CSwtListBoxLists::EnableFocusHighlight(iList->View()->ItemDrawer(),
       
  1424                                            aEnable);
       
  1425 }
       
  1426 #endif //RD_JAVA_S60_RELEASE_9_2
  1372 
  1427 
  1373 // ---------------------------------------------------------------------------
  1428 // ---------------------------------------------------------------------------
  1374 // CSwtListBase::SbFrame
  1429 // CSwtListBase::SbFrame
  1375 // From ASwtScrollableBase
  1430 // From ASwtScrollableBase
  1376 // ---------------------------------------------------------------------------
  1431 // ---------------------------------------------------------------------------
  1523     if (aListBox != iList)
  1578     if (aListBox != iList)
  1524     {
  1579     {
  1525         return;
  1580         return;
  1526     }
  1581     }
  1527 
  1582 
       
  1583     UpdateFlickScrollingState(aEventType);
       
  1584 
  1528     switch (aEventType)
  1585     switch (aEventType)
  1529     {
  1586     {
  1530         // On 5.0, drawing trough Java gives simply a better fps.
  1587         // On 5.0, drawing trough Java gives simply a better fps.
  1531 #ifdef RD_JAVA_S60_RELEASE_9_2
  1588 #ifdef RD_JAVA_S60_RELEASE_9_2
  1532     case EEventPanningStarted:
  1589     case EEventPanningStarted:
  1556 void CSwtListBase::HandleListBoxEventL(CEikListBox*, TListBoxEvent)
  1613 void CSwtListBase::HandleListBoxEventL(CEikListBox*, TListBoxEvent)
  1557 {
  1614 {
  1558 }
  1615 }
  1559 #endif //RD_SCALABLE_UI_V2
  1616 #endif //RD_SCALABLE_UI_V2
  1560 
  1617 
       
  1618 // ---------------------------------------------------------------------------
       
  1619 // CSwtListBase::UpdateFlickScrollingState
       
  1620 // Updates flick scrolling status based on received listbox event.
       
  1621 // ---------------------------------------------------------------------------
       
  1622 //
       
  1623 void CSwtListBase::UpdateFlickScrollingState(TListBoxEvent aEventType)
       
  1624 {
       
  1625     switch (aEventType)
       
  1626     {
       
  1627     case EEventFlickStarted:
       
  1628         iFlickScrollingOngoing = ETrue;
       
  1629         iScrollbarPointerEventToListbox = ETrue;
       
  1630         break;
       
  1631     case EEventFlickStopped:
       
  1632         iFlickScrollingOngoing = EFalse;
       
  1633         break;
       
  1634     }
       
  1635 }