9#ifndef GP_WIDGET_CHOICE_H
10#define GP_WIDGET_CHOICE_H
12enum gp_widget_choice_op {
13 GP_WIDGET_CHOICE_OP_SEL,
14 GP_WIDGET_CHOICE_OP_CNT,
17typedef struct gp_widget_choice_ops {
18 const char *(*get_choice)(gp_widget *self,
size_t idx);
19 size_t (*get)(gp_widget *self,
enum gp_widget_choice_op op);
20 void (*set)(gp_widget *self,
size_t val);
21} gp_widget_choice_ops;
34extern const gp_widget_choice_ops gp_widget_choice_arr_ops;
40 const gp_widget_choice_ops *ops;
43 const char *
const *choices;
48enum gp_widget_choice_flags {
49 GP_WIDGET_CHOICE_COPY = 1,
52struct gp_widget_choice {
54 const struct gp_widget_choice_ops *ops;
86gp_widget *gp_widget_choice_new(
unsigned int widget_type,
87 const char *choices[],
88 size_t cnt,
size_t sel);
98gp_widget *gp_widget_choice_ops_new(
unsigned int widget_type,
99 const struct gp_widget_choice_ops *ops);
117gp_widget *gp_widget_choice_arr_new(
unsigned int widget_type,
const void *array,
118 size_t memb_cnt, uint16_t memb_size,
119 uint16_t memb_off,
size_t sel,
int flags);
128void gp_widget_choice_refresh(gp_widget *self);
136size_t gp_widget_choice_cnt_get(gp_widget *self);
144void gp_widget_choice_sel_set(gp_widget *self,
size_t sel);
152size_t gp_widget_choice_sel_get(gp_widget *self);
163size_t gp_widget_choice_prev_sel_get(gp_widget *self);
173const char *gp_widget_choice_name_get(gp_widget *self,
size_t idx);
180static inline const char *gp_widget_choice_sel_name_get(gp_widget *self)
182 return gp_widget_choice_name_get(self, gp_widget_choice_sel_get(self));
194gp_widget *gp_widget_choice_from_json(
unsigned int widget_type,
A JSON parser internal state.
A parsed JSON key value pair.