LISTVIEW_SetRBorder and LISTVIEW_SetLBorder don't work.

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

    • LISTVIEW_SetRBorder and LISTVIEW_SetLBorder don't work.

      Hello,

      I'm trying to create a LISTVIEW widget in the centre of a window. The problem is that the LISTVIEW that I create does not have the left border. I tried LISTVIEW_SetLBorder(ListviewHandle, 1); but it seems to not work at all. I also tried using LISTVIEW_SetRBorder(ListviewHandle, 0); to remove the right border, just to see if the function works but I had the same result - this function also does not seem have any effect || .

      Please, tell me what I'm doing wrong or how to create a LISTVIEW widget with both right and left borders. Here is my callback function for the window in which I want to create the LISTVIEW.


      Source Code

      1. static void
      2. cbTableOfResultsWindow (WM_MESSAGE *pMsg)
      3. {
      4. //**************************************************************************
      5. switch (pMsg->MsgId)
      6. {
      7. //**********************************************************************
      8. case WM_PAINT:
      9. {
      10. GUI_SetBkColor(GUI_BROWN); // debug
      11. GUI_Clear();
      12. break;
      13. }
      14. //**********************************************************************
      15. case WM_CREATE:
      16. {
      17. LISTVIEW_Handle ListviewHandle;
      18. HEADER_Handle hHeader;
      19. int Columns = 4;
      20. int Rows = 5;
      21. int ColWidth = (int)(300 / Columns);
      22. int RowHeight = (int)(100 / Rows);
      23. int BorderH = 0;
      24. int BorderV = 0;
      25. // create the listview
      26. ListviewHandle = LISTVIEW_CreateEx(TAB_OF_RESULTS_MARGIN,
      27. TAB_OF_RESULTS_MARGIN,
      28. 300+1, // 1 extra pixel to show the right border
      29. 100,
      30. pMsg->hWin,
      31. WM_CF_SHOW,
      32. 0,
      33. UI_ID_TAB_OF_RESULTS_LISTVIEW);
      34. WIDGET_SetEffect(ListviewHandle, &WIDGET_Effect_None);
      35. LISTVIEW_SetGridVis(ListviewHandle, true);
      36. // create columns
      37. for (uint8_t i = 0; i < Columns; i++)
      38. {
      39. LISTVIEW_AddColumn(ListviewHandle,
      40. ColWidth,
      41. NULL,
      42. GUI_TA_VCENTER | GUI_TA_HCENTER);
      43. }
      44. hHeader = LISTVIEW_GetHeader(ListviewHandle);
      45. HEADER_SetHeight(hHeader, RowHeight);
      46. // create rows
      47. for (uint8_t i = 0; i < Rows; i++)
      48. {
      49. LISTVIEW_AddRow(ListviewHandle, NULL);
      50. }
      51. LISTVIEW_SetRowHeight(ListviewHandle, RowHeight);
      52. // !!! these two don't work !!!
      53. LISTVIEW_SetRBorder(ListviewHandle, 0);
      54. LISTVIEW_SetLBorder(ListviewHandle, 1);
      55. break;
      56. }
      57. //**********************************************************************
      58. default:
      59. {
      60. WM_DefaultProc(pMsg);
      61. break;
      62. }
      63. }
      64. }
      Display All

      Regards
      Piotr
    • Hi,

      On my end this is working fine. To see the effect of the border functions you have to set a text to a cell.

      Here is the callback fucntion with some changes to make the border visible (or better not visible since they are 0 and 1).

      C Source Code

      1. static void _cbTableOfResultsWindow(WM_MESSAGE *pMsg) {
      2. LISTVIEW_Handle ListviewHandle;
      3. HEADER_Handle hHeader;
      4. int Columns = 4;
      5. int Rows = 5;
      6. int ColWidth = (int)(300 / Columns);
      7. int RowHeight = (int)(100 / Rows);
      8. int BorderH = 0;
      9. int BorderV = 0;
      10. int i;
      11. switch (pMsg->MsgId) {
      12. case WM_PAINT: {
      13. GUI_SetBkColor(GUI_BROWN); // debug
      14. GUI_Clear();
      15. break;
      16. }
      17. case WM_CREATE: {
      18. // create the listview
      19. ListviewHandle = LISTVIEW_CreateEx(10, 10, 300, 100, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_LISTVIEW0);
      20. WIDGET_SetEffect(ListviewHandle, &WIDGET_Effect_None);
      21. LISTVIEW_SetGridVis(ListviewHandle, 1);
      22. // create columns
      23. for (i = 0; i < Columns; i++) {
      24. LISTVIEW_AddColumn(ListviewHandle, ColWidth, NULL, GUI_TA_VCENTER | GUI_TA_HCENTER); // If the string is too short the border functions have allmost no effect.
      25. // Try to use GUI_TA_LEFT/RIGHT to see the effect of the border functions
      26. }
      27. hHeader = LISTVIEW_GetHeader(ListviewHandle);
      28. HEADER_SetHeight(hHeader, RowHeight);
      29. // create rows
      30. for (i = 0; i < Rows; i++) {
      31. LISTVIEW_AddRow(ListviewHandle, NULL);
      32. }
      33. LISTVIEW_SetRowHeight(ListviewHandle, RowHeight);
      34. // !!! these two don't work !!!
      35. LISTVIEW_SetItemText(ListviewHandle, 0, 0, "ALongTestStringWhichShouldntFitIntoOneCell"); // no border to the right, and 1p border left
      36. LISTVIEW_SetRBorder(ListviewHandle, 0);
      37. LISTVIEW_SetLBorder(ListviewHandle, 1);
      38. break;
      39. }
      40. default: {
      41. WM_DefaultProc(pMsg);
      42. break;
      43. }
      44. }
      45. }
      Display All
      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.
    • Hi Sven,

      I had to leave this problem and concentrate on further development. I have now come back to it and I have just realised that I had thought that LISTVIEW_SetLBorder() would draw a line on the left edge of my listview. Instead, it adds a margin within a cell.

      So, my actual problem is that when I create a listview in the middle of a window, the first left vertical line is missing (one of the lines forming the table).

      Do I have to draw that line manually or there is a less nasty way of dealing with this issue???

      Thank You.
    • Hi,
      I'm not entirely sure about which line you mean.

      In the example above you have set the effect of the LISTVIEW to none, try if it is better when commenting the line:

      C Source Code

      1. //WIDGET_SetEffect(ListviewHandle, &WIDGET_Effect_None);

      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.
    • Hi,

      yes, this is possible. Unfortunately this is not documented but you could do something like this:

      C Source Code

      1. #include "DIALOG.h"
      2. /*********************************************************************
      3. *
      4. * Externals
      5. *
      6. **********************************************************************
      7. */
      8. /*********************************************************************
      9. *
      10. * Types
      11. *
      12. **********************************************************************
      13. */
      14. /*********************************************************************
      15. *
      16. * Defines
      17. *
      18. **********************************************************************
      19. */
      20. /*********************************************************************
      21. *
      22. * Static data
      23. *
      24. **********************************************************************
      25. */
      26. static void _DrawDownRect(const GUI_RECT* pRect) {
      27. GUI_SetColor(GUI_RED);
      28. GUI_DrawRect(pRect->x0, pRect->y0, pRect->x1, pRect->y1);
      29. }
      30. /*********************************************************************
      31. *
      32. * Static code
      33. *
      34. **********************************************************************
      35. */
      36. static void _cbTableOfResultsWindow(WM_MESSAGE *pMsg) {
      37. LISTVIEW_Handle ListviewHandle;
      38. static WIDGET_EFFECT Effect;
      39. switch (pMsg->MsgId) {
      40. case WM_PAINT:
      41. GUI_SetBkColor(GUI_BROWN); // debug
      42. GUI_Clear();
      43. break;
      44. case WM_CREATE:
      45. ListviewHandle = LISTVIEW_CreateEx(10, 10, 300, 100, pMsg->hWin, WM_CF_SHOW, 0, GUI_ID_LISTVIEW0);
      46. Effect = WIDGET_Effect_Simple;
      47. Effect.pfDrawDownRect = _DrawDownRect;
      48. WIDGET_SetEffect(ListviewHandle, &Effect);
      49. LISTVIEW_SetGridVis(ListviewHandle, 1);
      50. break;
      51. default:
      52. WM_DefaultProc(pMsg);
      53. break;
      54. }
      55. }
      56. /*********************************************************************
      57. *
      58. * Public code
      59. *
      60. **********************************************************************
      61. */
      62. /*********************************************************************
      63. *
      64. * MainTask
      65. */
      66. void MainTask(void) {
      67. GUI_Init();
      68. WM_CreateWindowAsChild(0, 0, 480, 272, WM_HBKWIN, WM_CF_SHOW, _cbTableOfResultsWindow, 0);
      69. while (1) {
      70. GUI_Delay(100);
      71. }
      72. }
      73. /*************************** End of file ****************************/
      Display All
      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.