Cross-platform C SDK logo

Cross-platform C SDK

ListBox

❮ Back
Next ❯
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.

Functions

ListBox*listbox_create (void)
voidlistbox_OnSelect (...)
voidlistbox_size (...)
voidlistbox_checkbox (...)
voidlistbox_multisel (...)
voidlistbox_add_elem (...)
voidlistbox_set_elem (...)
voidlistbox_clear (...)
voidlistbox_color (...)
voidlistbox_select (...)
voidlistbox_check (...)
uint32_tlistbox_count (...)
const char_t*listbox_text (...)
bool_tlistbox_selected (...)
bool_tlistbox_checked (...)

The ListBox are controls that display a series of elements as a list (Figure 1), (Figure 2), (Figure 3). Depending on how it is configured, we can select one or more elements or view checkboxes to check them. The control enables scroll bars when necessary and allows keyboard navigation. In Hello ListBox! you have an example of use.


listbox_create ()

Create a new list control.

ListBox*
listbox_create(void);

Return

The newly created listbox.


listbox_OnSelect ()

Set an event handler for the selection of a new item.

void
listbox_OnSelect(ListBox *listbox,
                 Listener *listener);
1
2
3
4
5
6
7
static void i_OnSelect(UserData *data, Event *e)
{
    const EvButton *p = event_params(e, EvButton);
    do_something_onselect(data, p->index);
}
...
listbox_OnSelect(list, listener(data, i_OnSelect, UserData));
listbox

The ListBox.

listener

Callback function to be called after selecting a new item from the list.

Remarks

See GUI Events.


listbox_size ()

Set the default size of the list.

void
listbox_size(ListBox *listbox,
             const S2Df size);
listbox

The ListBox.

size

The size.

Remarks

It corresponds to Natural sizing of control Default 128x128.


listbox_checkbox ()

Show or hide checkboxes to the left of items.

void
listbox_checkbox(ListBox *listbox,
                 const bool_t show);
listbox

ListBox.

show

TRUE for show them.


listbox_multisel ()

Enable multiple selection.

void
listbox_multisel(ListBox *listbox,
                 const bool_t multisel);
listbox

ListBox.

multisel

TRUE to allow multiple selected items at the same time.


listbox_add_elem ()

Adds a new element.

void
listbox_add_elem(ListBox *listbox,
                 const char_t *text,
                 const Image *image);
listbox

ListBox.

text

The text of the element in UTF-8 or the identifier of the resource. Resources.

image

Icon associated with the element or resource identifier.


listbox_set_elem ()

Edit a list item.

void
listbox_set_elem(ListBox *listbox,
                 const uint32_t index,
                 const char_t *text,
                 const Image *image);
listbox

ListBox.

index

The index of the element to replace.

text

The text of the element in UTF-8 or the identifier of the resource. Resources.

image

Icon associated with the element or resource identifier.


listbox_clear ()

Remove all items from the list.

void
listbox_clear(ListBox *listbox);
listbox

ListBox.


listbox_color ()

Sets the text color of an element.

void
listbox_color(ListBox *listbox,
              const color_t color);
listbox

ListBox.

color

The. By default kCOLOR_DEFAULT.


listbox_select ()

Select an item from the program code.

void
listbox_select(ListBox *listbox,
               const uint32_t index,
               const bool_t select);
listbox

ListBox.

index

The index of the item to select.

select

Select or deselect.

Remarks

If multiple selection is not enabled, selecting one item implies de-selecting all the others.


listbox_check ()

Check or uncheck the checkbox of the element from the program code.

void
listbox_check(ListBox *listbox,
              const uint32_t index,
              const bool_t check);
listbox

ListBox.

index

The item index.

check

Check or uncheck.

Remarks

Checking an item is independent of selecting it. Items can be marked even if checkboxes are not visible. See listbox_checkbox.


listbox_count ()

Returns the number of elements in the list.

uint32_t
listbox_count(const ListBox *listbox);
listbox

ListBox.

Return

The number of elements.


listbox_text ()

Returns the text of an element.

const char_t*
listbox_text(const ListBox *listbox);
listbox

ListBox.

Return

The UTF-8 text terminated in null character '\0'.


listbox_selected ()

Returns whether or not an element is selected.

bool_t
listbox_selected(const ListBox *listbox);
listbox

ListBox.

Return

The selection state.


listbox_checked ()

Returns whether an element is checked or not.

bool_t
listbox_checked(const ListBox *listbox);
listbox

ListBox.

Return

The checkbox state.

Remarks

Checking an item is independent of selecting it. Items can be marked even if checkboxes are not visible. See listbox_checkbox.

❮ Back
Next ❯