// widgetComboBox.h  -- ComboBox widget API
#ifndef WIDGET_COMBOBOX_H
#define WIDGET_COMBOBOX_H

#include "../core/dvxWidget.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);
} 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)

#endif // WIDGET_COMBOBOX_H
