// widgetDropdown.h  -- Dropdown widget API
#ifndef WIDGET_DROPDOWN_H
#define WIDGET_DROPDOWN_H

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

static inline const DropdownApiT *dvxDropdownApi(void) {
    static const DropdownApiT *sApi;
    if (!sApi) { sApi = (const DropdownApiT *)wgtGetApi("dropdown"); }
    return sApi;
}

#define wgtDropdown(parent)                dvxDropdownApi()->create(parent)
#define wgtDropdownSetItems(w, items, count) dvxDropdownApi()->setItems(w, items, count)
#define wgtDropdownGetSelected(w)          dvxDropdownApi()->getSelected(w)
#define wgtDropdownSetSelected(w, idx)     dvxDropdownApi()->setSelected(w, idx)

#endif // WIDGET_DROPDOWN_H
