DVX_GUI/widgets/listBox/listBox.h

42 lines
2 KiB
C

// listBox.h -- ListBox widget API
#ifndef LISTBOX_H
#define LISTBOX_H
#include "../../core/dvxWgt.h"
typedef struct {
WidgetT *(*create)(WidgetT *parent);
void (*setItems)(WidgetT *w, const char **items, int32_t count);
int32_t (*getSelected)(const WidgetT *w);
void (*setSelected)(WidgetT *w, int32_t idx);
void (*setMultiSelect)(WidgetT *w, bool multi);
bool (*isItemSelected)(const WidgetT *w, int32_t idx);
void (*setItemSelected)(WidgetT *w, int32_t idx, bool selected);
void (*selectAll)(WidgetT *w);
void (*clearSelection)(WidgetT *w);
void (*setReorderable)(WidgetT *w, bool reorderable);
void (*addItem)(WidgetT *w, const char *text);
void (*removeItem)(WidgetT *w, int32_t idx);
void (*clear)(WidgetT *w);
const char *(*getItem)(const WidgetT *w, int32_t idx);
int32_t (*getItemCount)(const WidgetT *w);
} ListBoxApiT;
static inline const ListBoxApiT *dvxListBoxApi(void) {
static const ListBoxApiT *sApi;
if (!sApi) { sApi = (const ListBoxApiT *)wgtGetApi("listbox"); }
return sApi;
}
#define wgtListBox(parent) dvxListBoxApi()->create(parent)
#define wgtListBoxSetItems(w, items, count) dvxListBoxApi()->setItems(w, items, count)
#define wgtListBoxGetSelected(w) dvxListBoxApi()->getSelected(w)
#define wgtListBoxSetSelected(w, idx) dvxListBoxApi()->setSelected(w, idx)
#define wgtListBoxSetMultiSelect(w, multi) dvxListBoxApi()->setMultiSelect(w, multi)
#define wgtListBoxIsItemSelected(w, idx) dvxListBoxApi()->isItemSelected(w, idx)
#define wgtListBoxSetItemSelected(w, idx, selected) dvxListBoxApi()->setItemSelected(w, idx, selected)
#define wgtListBoxSelectAll(w) dvxListBoxApi()->selectAll(w)
#define wgtListBoxClearSelection(w) dvxListBoxApi()->clearSelection(w)
#define wgtListBoxSetReorderable(w, reorderable) dvxListBoxApi()->setReorderable(w, reorderable)
#endif // LISTBOX_H