// comboBox.h  -- ComboBox widget API
#ifndef COMBOBOX_H
#define COMBOBOX_H

#include "../../../libs/kpunch/libdvx/dvxWgt.h"

typedef struct {
    WidgetT *(*create)(WidgetT *parent, int32_t maxLen);
    void     (*setItems)(WidgetT *w, const char **items, int32_t count);
    int32_t  (*getSelected)(const WidgetT *w);
    void     (*setSelected)(WidgetT *w, int32_t idx);
    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);
} ComboBoxApiT;

static inline const ComboBoxApiT *dvxComboBoxApi(void) {
    static const ComboBoxApiT *sApi;
    if (!sApi) { sApi = (const ComboBoxApiT *)wgtGetApi("combobox"); }
    return sApi;
}

#define wgtComboBox(parent, maxLen)             dvxComboBoxApi()->create(parent, maxLen)
#define wgtComboBoxSetItems(w, items, count)    dvxComboBoxApi()->setItems(w, items, count)
#define wgtComboBoxGetSelected(w)              dvxComboBoxApi()->getSelected(w)
#define wgtComboBoxSetSelected(w, idx)         dvxComboBoxApi()->setSelected(w, idx)
#define wgtComboBoxAddItem(w, text)            dvxComboBoxApi()->addItem(w, text)
#define wgtComboBoxRemoveItem(w, idx)          dvxComboBoxApi()->removeItem(w, idx)
#define wgtComboBoxClear(w)                    dvxComboBoxApi()->clear(w)
#define wgtComboBoxGetItem(w, idx)             dvxComboBoxApi()->getItem(w, idx)
#define wgtComboBoxGetItemCount(w)             dvxComboBoxApi()->getItemCount(w)

#endif // COMBOBOX_H
