some SWIPELIST and theirs colors

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

  • some SWIPELIST and theirs colors

    Hi,

    I'm configuring a "standard" screen which according a variable I want to configure with one or two SWIPELIST.

    If only there is a Swipelist, I want it will be from pixel 1 to pixel 318, and if there are 2 swipelist, I want the first is from pixel 1 to pixel 158, and the second from pixel 161 to pixel 318.

    C Source Code

    1. For this reason, I define a DialogCreate with 3 types of swipelist, as you can see:
    2. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
    3. { WINDOW_CreateIndirect, "Basica", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
    4. { IMAGE_CreateIndirect, "Msup", ID_IMAGE_0, 0, 0, 320, 23, 0, 0, 0 },
    5. { TEXT_CreateIndirect, "Data", ID_TEXT_0, 226, 4, 50, 15, 0, 0x0, 0 },
    6. { TEXT_CreateIndirect, "Hora", ID_TEXT_1, 285, 4, 30, 15, 0, 0x0, 0 },
    7. { ICONVIEW_CreateIndirect, "Iconview", ID_ICONVIEW_0, 1, 204, 318, 36, 0, ( 36 << 16) | 53, 0 },
    8. { SWIPELIST_CreateIndirect, "", ID_SWIPELIST_0, 1, 89, 318, 115, 0, 0x0 , 0},
    9. { SWIPELIST_CreateIndirect, "", ID_SWIPELIST_1, 1, 89, 158, 115, 0, 0x0 , 0},
    10. { SWIPELIST_CreateIndirect, "", ID_SWIPELIST_2, 1, 89, 158, 115, 0, 0x0 , 0}, // ->> it will be x=161.
    11. // USER START (Optionally insert additional widgets)
    12. // USER END
    13. };
    Display All



    And, then I want to select one option or other, I pass a variable or other into , as you can see:

    C Source Code

    1. WM_HWIN CreateSetup_1r_N(uint8_t num) {
    2. WM_HWIN hWin;
    3. switch (num)
    4. {
    5. case 0: StrMenu = (STRUCTMENU *)&aMSetup; break;
    6. case 1: StrMenu = (STRUCTMENU *)&aMComunicacions; break;
    7. }
    8. hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
    9. return hWin;
    10. }
    Display All


    where:

    C Source Code

    1. const STRUCTMENU aMSetup =
    2. {
    3. 2, // type
    4. 5, // Qty SWP1
    5. 2, // Qty SWP2
    6. _aSetup1,
    7. _aSetup2,
    8. };
    9. const STRUCTMENU aMComunicacions =
    10. {
    11. 1, // type
    12. 5, // Qty SWP1
    13. 0, // Qty SWP2
    14. _aComunicacions,
    15. NULL_,
    16. };
    17. const char *_aSetup1[] = {
    18. "Setup11", //0
    19. "Setup12", //1
    20. "Setup13", //2
    21. "Setup14", //3
    22. "Setup15", //4
    23. };
    24. const char *_aSetup2[] = {
    25. "Setup21", //5
    26. "Setup22", //6
    27. " ",
    28. " ",
    29. " ",
    30. };
    31. const char *_aComunicacions[] = {
    32. "Com 1",
    33. "Com 2",
    34. "Ethernet",
    35. "Rs485",
    36. "USB",
    37. };
    Display All


    So, according to "type" value, I will create one or two Swipelist.

    Into cbDialog, I call:

    C Source Code

    1. static void _cbDialog(WM_MESSAGE * pMsg) {
    2. const void * pData;
    3. WM_HWIN hItem;
    4. U32 FileSize;
    5. int NCode;
    6. int Id;
    7. uint8_t i, j;
    8. // USER START (Optionally insert additional variables)
    9. // USER END
    10. switch (pMsg->MsgId) {
    11. case WM_INIT_DIALOG:
    12. //
    13. // Initialization of 'Msup'
    14. //
    15. hItem = WM_GetDialogItem(pMsg->hWin, ID_IMAGE_0);
    16. pData = _GetImageById(ID_IMAGE_0_IMAGE_0, &FileSize);
    17. IMAGE_SetDTA(hItem, pData, FileSize);
    18. //
    19. // Initialization of 'Data'
    20. //
    21. hTxtData = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    22. TEXT_SetFont(hTxtData, &GUI_FontHelveticaLTStd14_9punts_aa2_normal);
    23. TEXT_SetText(hTxtData, "23.03.17");
    24. TEXT_SetTextColor(hTxtData, GUI_MAKE_COLOR(BLAU_MARI));
    25. //
    26. // Initialization of 'Hora'
    27. //
    28. hTxtHora = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    29. TEXT_SetFont(hTxtHora, &GUI_FontHelveticaLTStd14_9punts_aa2_normal);
    30. TEXT_SetText(hTxtHora, "16:57");
    31. TEXT_SetTextColor(hTxtHora, GUI_MAKE_COLOR(BLAU_MARI));
    32. // USER START (Optionally insert additional code for further widget initialization)
    33. if (StrMenu->type == 1)
    34. { // un sol SWP
    35. WM_InvalidateWindow (hSwp1);
    36. WM_InvalidateWindow (hSwp2);
    37. hSwp0 = WM_GetDialogItem(pMsg->hWin, ID_SWIPELIST_0);
    38. /* lletra */
    39. SWIPELIST_SetFont(hSwp0,SWIPELIST_FI_ITEM_TEXT,&GUI_FontHelveticaLTStd14_9punts_aa2_normal);
    40. SWIPELIST_SetTextColor(hSwp0,SWIPELIST_CI_ITEM_TEXT_UNSEL, 0x00000000);
    41. SWIPELIST_SetTextColor(hSwp0,SWIPELIST_CI_ITEM_TEXT_SEL, 0x00000000);
    42. SWIPELIST_SetTextColor(hSwp0,SWIPELIST_CI_SEP_ITEM_TEXT, 0x00000000);
    43. /* background */
    44. SWIPELIST_SetBkColor(hSwp0,SWIPELIST_CI_BK_ITEM_UNSEL, GRIS_CLAR);
    45. SWIPELIST_SetBkColor(hSwp0,SWIPELIST_CI_BK_ITEM_SEL, BLAU_CIAN);
    46. SWIPELIST_SetBkColor(hSwp0,SWIPELIST_CI_BK_SEP_ITEM, BLANC);
    47. for (i = 0; i < StrMenu->menu1; i++)
    48. {
    49. SWIPELIST_AddItem(hSwp0, StrMenu->MenuPtr1[i], (PIXELS_Y_ITEMP + PIXELS_SEP)); // 21 + 1 del separador
    50. /* alineació text */
    51. SWIPELIST_SetTextColor(hSwp0,SWIPELIST_CI_ITEM_TEXT_SEL,BLANC);
    52. SWIPELIST_SetTextAlign(hSwp0,i, GUI_TA_HCENTER);
    53. /* separador */
    54. SWIPELIST_SetSepSize(hSwp0, i , PIXELS_SEP);
    55. SWIPELIST_SetSepColor(hSwp0,i, BLANC);
    56. }
    57. if(i < MAX_ITEMS)
    58. {
    59. for (j = i; j < MAX_ITEMS; j++)
    60. {
    61. SWIPELIST_AddItem(hSwp0, " ", (PIXELS_Y_ITEMP + PIXELS_SEP));
    62. /* alineació text */
    63. SWIPELIST_SetTextAlign(hSwp0,j, GUI_TA_HCENTER);
    64. /* separador */
    65. SWIPELIST_SetSepSize(hSwp0, j, PIXELS_SEP);
    66. SWIPELIST_SetSepColor(hSwp0,j, BLANC);
    67. }
    68. }
    69. }
    70. else if (StrMenu->type == 2)
    71. {
    72. WM_HideWindow (hSwp0);
    73. /* SWP ESQUERRA */
    74. hSwp1 = WM_GetDialogItem(pMsg->hWin, ID_SWIPELIST_1);
    75. /* lletra */
    76. SWIPELIST_SetFont(hSwp1,SWIPELIST_FI_ITEM_TEXT,&GUI_FontHelveticaLTStd14_9punts_aa2_normal);
    77. SWIPELIST_SetTextColor(hSwp1,SWIPELIST_CI_ITEM_TEXT_UNSEL, 0x00000000);
    78. SWIPELIST_SetTextColor(hSwp1,SWIPELIST_CI_ITEM_TEXT_SEL, 0x00FF0000);
    79. SWIPELIST_SetTextColor(hSwp1,SWIPELIST_CI_SEP_ITEM_TEXT, 0x00FF0000); //vermell
    80. /* background */
    81. SWIPELIST_SetBkColor(hSwp1,SWIPELIST_CI_BK_ITEM_UNSEL, GRIS_CLAR);
    82. SWIPELIST_SetBkColor(hSwp1,SWIPELIST_CI_BK_ITEM_SEL, BLAU_CIAN);
    83. SWIPELIST_SetBkColor(hSwp1,SWIPELIST_CI_BK_SEP_ITEM, BLANC);
    84. SWIPELIST_SetTextColor(hSwp1,SWIPELIST_CI_ITEM_TEXT_SEL,BLANC);
    85. for (i = 0; i < StrMenu->menu1; i++)
    86. {
    87. SWIPELIST_AddItem(hSwp1, StrMenu->MenuPtr1[i], (PIXELS_Y_ITEMP + PIXELS_SEP)); // 21 + 1 del separador
    88. /* alineació text */
    89. SWIPELIST_SetTextAlign(hSwp1,i, GUI_TA_HCENTER);
    90. /* separador */
    91. SWIPELIST_SetSepSize(hSwp1, i , PIXELS_SEP);
    92. SWIPELIST_SetSepColor(hSwp1,i, BLANC);
    93. }
    94. /* SWP DRET */
    95. hSwp2 = WM_GetDialogItem(pMsg->hWin, ID_SWIPELIST_2);
    96. /* lletra */
    97. SWIPELIST_SetFont(hSwp2,SWIPELIST_FI_ITEM_TEXT,&GUI_FontHelveticaLTStd14_9punts_aa2_normal);
    98. SWIPELIST_SetTextColor(hSwp2,SWIPELIST_CI_ITEM_TEXT_UNSEL, GRIS_FOSC);
    99. SWIPELIST_SetTextColor(hSwp2,SWIPELIST_CI_ITEM_TEXT_SEL, BLANC);
    100. SWIPELIST_SetTextColor(hSwp2,SWIPELIST_CI_SEP_ITEM_TEXT, BLANC);
    101. /* background */
    102. SWIPELIST_SetBkColor(hSwp2,SWIPELIST_CI_BK_ITEM_UNSEL, GRIS_CLAR);
    103. SWIPELIST_SetBkColor(hSwp2,SWIPELIST_CI_BK_ITEM_SEL, BLAU_CIAN);
    104. SWIPELIST_SetBkColor(hSwp2,SWIPELIST_CI_BK_SEP_ITEM, BLANC);
    105. for (i = 0; i < StrMenu->menu2; i++)
    106. {
    107. SWIPELIST_AddItem(hSwp2, StrMenu->MenuPtr2[i], (PIXELS_Y_ITEMP + PIXELS_SEP));
    108. /* alineació text */
    109. SWIPELIST_SetTextAlign(hSwp2,i, GUI_TA_HCENTER);
    110. /* separador */
    111. SWIPELIST_SetSepSize(hSwp2, i , PIXELS_SEP);
    112. SWIPELIST_SetSepColor(hSwp2,i, BLANC);
    113. }
    114. if(i < 5)
    115. {
    116. for (j = i; j < 5; j++)
    117. {
    118. SWIPELIST_AddItem(hSwp2, " ", 22);
    119. /* alineació text */
    120. SWIPELIST_SetTextAlign(hSwp2,j, GUI_TA_HCENTER);
    121. /* separador */
    122. SWIPELIST_SetSepSize(hSwp2, j , 1);
    123. SWIPELIST_SetSepColor(hSwp2,j, BLANC);
    124. }
    125. }
    126. }
    127. // USER START (Optionally insert additional code for further widget initialization)
    128. hIcones = WM_GetDialogItem(pMsg->hWin, ID_ICONVIEW_0);
    129. ICONVIEW_SetSpace(hIcones, GUI_COORD_X, 0);
    130. ICONVIEW_SetFrame(hIcones, GUI_COORD_X, 0);
    131. ICONVIEW_SetFrame(hIcones, GUI_COORD_Y, 0);
    132. ICONVIEW_SetIconAlign(hIcones, ICONVIEW_IA_TOP);
    133. for (i = 0; i < GUI_COUNTOF(_aBitmapItem); i++)
    134. {
    135. ICONVIEW_AddBitmapItem(hIcones, _aBitmapItem[i].pBitmap, _aBitmapItem[i].pText);
    136. }
    137. [....]
    Display All


    Where:

    C Source Code

    1. /**** colors ***/
    2. #define BLANC 0x00FFFFFF
    3. #define BLAU_MARI 0x00463726
    4. #define BLAU_CIAN 0x00F0C24D
    5. #define GRIS_CLAR 0x00E1DFDA
    6. #define GRIS_MIG 0x00E1DFDA
    7. #define GRIS_FOSC 0x00928677


    Untill here, it seems without errors. But:

    1) When I want 1 only swipelist, I see this:
    [img]https://i.imgsafe.org/e3f85d0e6f.jpg[/img]

    How I can hide, disable, or delete the others swipelists?

    2) Why, the TextColor is white if I configure it as 0x000000 (black)?


    Thanks
  • Hi,

    Please take a look into the example attached.

    There I create either one or two swipelists dpending on the given paramter.

    To show, hide and delete a window/widget you can use WM_ShowWindow(), WM_HideWindow() and WM_DeleteWindow().

    If you define custom colors I recommedn to do it this way:

    C Source Code

    1. // Red---------------------------------------|
    2. // Green-----------------------------------| |
    3. // Blue----------------------------------| | |
    4. // Alpha-------------------------------| | | |
    5. // | | | |
    6. #define COLOR_CUSTOM GUI_MAKE_COLOR(0x00808080)


    The alpha channel above reaches from 0x00 (opaque) to 0xff (transparent). This macro converts the color into the proper format depending on if GUI_USE_ARGB is defined or not.

    EDIT: Re-uploaded example.

    Regards,
    Sven
    Files
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Thanks Schoenen.

    The swipelist problems are solved.

    But, I still have problems with the colors.

    Is only possible the standard colors of the GUI.h library?

    Can I use the function "GUI_MAKE_COLOR" with my (below) defines?

    C Source Code

    1. #define BLANC 0xFFFFFFFF
    2. #define BLAU_MARI 0xFF263746
    3. #define BLAU_CIAN 0xFF4DC2F0
    4. #define GRIS_CLAR 0xFFDADFE1
    5. #define GRIS_FOSC 0xFF778692


    Thanks
  • Hi,

    Of course you can define your own colors.

    In your case you would need to swap the red and blue channel and invert the alpha channel.

    Like

    C Source Code

    1. #define BLAU_MARI GUI_MAKE_COLOR(0x00463726)


    0x00463726 is the default color notation of emWin. If the preprocessor define GUI_USE_ARGB is set to 1, GUI_MAKE_COLOR() will convert the color into the ARGB format. Like:

    0x00463726 --> 0xFF263746

    Of course, if you are sure that you will work always with GUI_USE_ARGB set to 1 you can keep the colors as they are.

    Regards,
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.