Separate color for separate row listbox

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

    • Separate color for separate row listbox

      Hello,

      I wanted to implement the design similar to attached image.

      I tried to implement this using listbox widget but I am unable to set separate color for each row similar attached image.

      Could you please let me know that is it possible/alternative way to add separate color for separate row in the list?

      Thanks,
      Vikram
      Images
      • listbox_color_issue.png

        4.91 kB, 459×174, viewed 267 times
    • Hi,

      you can do that by setting an owner draw function to the widget and doing the drawing yourself. Have a look at this sample.

      Unfortunately, there is no WIDGET_ITEM_DRAW_BACKGROUND command, only a WIDGET_ITEM_DRAW command, which means you have to draw each item completely (background, text, ...).

      When drawing the item in the WIDGET_ITEM_DRAW case, you can set the background color based on the current item index. The current item index is stored in pDrawItemInfo->ItemIndex.

      Best regards,

      Florian
      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,

      do you mean updating the scroll position of the Listbox/-view by buttons? That can be done the same way as in the sample I sent you for the MULTIEDIT. You can find that sample in the wiki now, by the way.

      Best regards,

      Florian
      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.
    • Hello,

      I don't mean that.

      I wanted to say that if i use multiple button widgets one below another and will set different background color one by another as shown in the image.
      (Here I will not use listbox/listview buttons). I think this will not be possible to scroll the normal button widgets.so, I may need to change the requirement.


      Thanks,
      Vikram

      The post was edited 2 times, last by vikramtathe ().

    • Hello,

      I am referring "WIDGET_ListBoxOwnerDraw.c" sample example code.

      As image attached in the first post, I can able to draw alternate colors to rows in the listbox.

      I tried to adjust the row height for the listbox using LISTBOX_SetItemSpacing(hListBox, 31) but I am unable to achieve this.

      Could you please look at the source code and let me know how to adjust the row height?

      About scrolling, consider the scenario that 6 rows are in the list box and I have added 10 itens in the listbox. I have tried the scroll down by calling LISTBOX_IncSel() in the button callback(Not using scrollbar). Here in this case what happen when I click 6 times on button then only I get the scrolling effect. Is it possible to add offset index in the LISTBOX_IncSel() so that I can get scroll effect in one click.

      Thanks,
      Vikram
      Files
      • Main.txt

        (9.03 kB, downloaded 249 times, last: )
    • Hi,

      the item spacing you set is not considered because of the WIDGET_ITEM_GET_YSIZE case in the owner draw function. With your method you overwrite the y-size of an item, but without adding the item spacing.

      When removing the WIDGET_ITEM_GET_XSIZE and WIDGET_ITEM_GET_YSIZE cases, the spacing seems correct.

      LISTBOX_IncSel() increments the selection by one. You would have to increment the selection by 6 in one go so that the widget would scroll by one element. You can do that using LISTBOX_SetSel() and LISTBOX_GetSel().

      Best regards,

      Florian
      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.