Horizontal scrolling for SWIPELIST?

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Horizontal scrolling for SWIPELIST?

      I am using a SWIPELIST within a window to display a "table" of static text data. LISTVIEW may be more appropriate for this, but the out-of-the-box scrolling behavior and appearance of the SWIPELIST widget is desirable in this case.

      Setup:
      (1) A window is created which is larger than the SWIPELIST in height so that static "header" labels are on top. Let's call this the "Header window". This window is also wider than the display screen. It is scrollable horizontally by using WM_MOTION_SetMoveable().
      (2) The SWIPELIST is created and attached to the horizontally scrollable window.

      Result:
      The SWIPELIST works as expected to scroll through items which do not all fit on the screen vertically. The "Header window" is scrollable horizontally by touching and dragging in the area not covered by the SWIPELIST. Since the SWIPELIST is attached to this window it also moves along as desired. However, I would also like to be able to drag the SWIPELIST and it's parent "Header window" horizontally by dragging horizontally within the SWIPELIST area. I have tried to use a custom callback function in hopes that I could pass horizontal motion (WM_MOTION messages) from the SWIPELIST through to the parent window. But I could not get this to work.

      Is there a way to create a SWIPELIST that is horizontally scrollable?
    • Hello,

      is that what you want?

      C Source Code: Main.c

      1. #include "DIALOG.h"
      2. #include "stdio.h"
      3. WM_HWIN hWin;
      4. int xPos = 0;
      5. void _cbSwipe(WM_MESSAGE * pMsg) {
      6. WM_MESSAGE Msg_Motion;
      7. switch (pMsg->MsgId) {
      8. case WM_MOTION:
      9. Msg_Motion = *pMsg;
      10. SWIPELIST_Callback(pMsg);
      11. WM_SendToParent(pMsg->hWin, &Msg_Motion);
      12. break;
      13. default:
      14. SWIPELIST_Callback(pMsg);
      15. break;
      16. }
      17. }
      18. void _cbWin(WM_MESSAGE * pMsg) {
      19. SWIPELIST_Handle hSwipe;
      20. GUI_RECT Rect1 = { 20, 40, 419, 69 };
      21. GUI_RECT Rect2 = { 20, 70, 419, 239 };
      22. int i;
      23. char str[20];
      24. WM_MOTION_INFO * pInfo;
      25. switch (pMsg->MsgId) {
      26. case WM_CREATE:
      27. hSwipe = SWIPELIST_CreateEx(21, 70, 398, 170, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_SWIPELIST0);
      28. for (i = 0; i < 32; i++) {
      29. sprintf(str, "Text data %d", i + 1);
      30. SWIPELIST_AddItem(hSwipe, str, 30);
      31. SWIPELIST_SetTextAlign(hSwipe, i, GUI_TA_HCENTER | GUI_TA_VCENTER);
      32. SWIPELIST_SetSepColor(hSwipe, i, GUI_WHITE);
      33. }
      34. SWIPELIST_SetBkColor(hSwipe, SWIPELIST_CI_BK_ITEM_SEL, GUI_RED);
      35. SWIPELIST_SetBkColor(hSwipe, SWIPELIST_CI_BK_ITEM_UNSEL, GUI_RED);
      36. SWIPELIST_SetFont(hSwipe, SWIPELIST_FI_ITEM_HEADER, GUI_FONT_20_ASCII);
      37. WM_SetCallback(hSwipe, _cbSwipe);
      38. break;
      39. case WM_MOTION:
      40. pInfo = (WM_MOTION_INFO *)pMsg->Data.p;
      41. switch (pInfo->Cmd) {
      42. case WM_MOTION_INIT:
      43. pInfo->Flags = WM_CF_MOTION_X | WM_MOTION_MANAGE_BY_WINDOW;
      44. break;
      45. case WM_MOTION_MOVE:
      46. xPos += pInfo->dx;
      47. if (xPos < -120) {
      48. xPos = -120;
      49. pInfo->StopMotion = 1;
      50. }
      51. if (xPos > 0) {
      52. xPos = 0;
      53. pInfo->StopMotion = 1;
      54. }
      55. WM_MoveTo(pMsg->hWin, xPos, WM_GetWinOrgY(pMsg->hWin));
      56. break;
      57. case WM_MOTION_GETPOS:
      58. pInfo->xPos = xPos;
      59. break;
      60. }
      61. break;
      62. case WM_PAINT:
      63. GUI_SetBkColor(GUI_RED);
      64. GUI_Clear();
      65. GUI_SetColor(GUI_WHITE);
      66. GUI_DrawRectEx(&Rect1);
      67. GUI_SetFont(GUI_FONT_20_ASCII);
      68. GUI_DispStringInRect("Text header data", &Rect1, GUI_TA_HCENTER | GUI_TA_VCENTER);
      69. GUI_DrawRectEx(&Rect2);
      70. break;
      71. default:
      72. WM_DefaultProc(pMsg);
      73. break;
      74. }
      75. }
      76. void MainTask(void) {
      77. GUI_Init();
      78. WM_MULTIBUF_Enable(1);
      79. // Ex. 320x240 desktop
      80. WM_SetSize(WM_HBKWIN, 320, 240);
      81. hWin = WM_CreateWindow(0, 0, 440, 480, WM_CF_SHOW, _cbWin, 0);
      82. WM_MOTION_Enable(1);
      83. while (1) {
      84. GUI_Delay(50);
      85. }
      86. }
      Display All
      In this case I would just make a motion for parent window completely manually.
      Then after handling a motion message by swipelist just send a copy of the motion message to parent window.
    • LexaGb,

      Thank You! When I tried this initially, I was missing some details in the SWIPELIST and parent window callbacks regarding motion. Following your example, I was able to modify my code to get it working properly in my application.