// radio.h  -- Radio button widget API
#ifndef RADIO_H
#define RADIO_H

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

typedef struct {
    WidgetT *(*group)(WidgetT *parent);
    WidgetT *(*create)(WidgetT *parent, const char *text);
    void     (*groupSetSelected)(WidgetT *w, int32_t idx);
    int32_t  (*getIndex)(const WidgetT *w);
} RadioApiT;

static inline const RadioApiT *dvxRadioApi(void) {
    static const RadioApiT *sApi;
    if (!sApi) { sApi = (const RadioApiT *)wgtGetApi("radio"); }
    return sApi;
}

#define wgtRadioGroup(parent)                dvxRadioApi()->group(parent)
#define wgtRadio(parent, text)               dvxRadioApi()->create(parent, text)
#define wgtRadioGroupSetSelected(w, idx)     dvxRadioApi()->groupSetSelected(w, idx)
#define wgtRadioGetIndex(w)                  dvxRadioApi()->getIndex(w)

#endif // RADIO_H
