GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
A choice class for widgets. More...
Go to the source code of this file.
Data Structures | |
struct | gp_widget_choice_ops |
A choice widget ops. More... | |
struct | gp_widget_choice_arr |
struct | gp_widget_choice_desc |
Typedefs | |
typedef struct gp_widget_choice_ops | gp_widget_choice_ops |
A choice widget ops. | |
typedef struct gp_widget_choice_arr | gp_widget_choice_arr |
typedef struct gp_widget_choice_desc | gp_widget_choice_desc |
Enumerations | |
enum | gp_widget_choice_op { GP_WIDGET_CHOICE_OP_SEL , GP_WIDGET_CHOICE_OP_CNT } |
A choice op for the get callback. More... | |
Functions | |
gp_widget * | gp_widget_choice_new (enum gp_widget_type widget_type, const char *choices[], size_t cnt, size_t sel) |
Allocates and initializes new choice widget. | |
gp_widget * | gp_widget_choice_ops_new (enum gp_widget_type widget_type, const struct gp_widget_choice_ops *ops) |
Creates a choice widget based on widget ops. | |
gp_widget * | gp_widget_choice_arr_new (enum gp_widget_type widget_type, const void *array, size_t memb_cnt, uint16_t memb_size, uint16_t memb_off, size_t sel, enum gp_widget_choice_flags flags) |
Creates a choice widget based on a static array. | |
void | gp_widget_choice_refresh (gp_widget *self) |
Request update after the choices has been changed. | |
size_t | gp_widget_choice_cnt_get (gp_widget *self) |
Returns the number of choices to choose from. | |
void | gp_widget_choice_sel_set (gp_widget *self, size_t sel) |
Sets a selected choice in the choice widget. | |
size_t | gp_widget_choice_sel_get (gp_widget *self) |
Returns a selected choice. | |
size_t | gp_widget_choice_prev_sel_get (gp_widget *self) |
Returns previously selected choice. | |
const char * | gp_widget_choice_name_get (gp_widget *self, size_t idx) |
Returns a choice value for a given index. | |
static const char * | gp_widget_choice_sel_name_get (gp_widget *self) |
Returns name of selected choice. | |
gp_widget * | gp_widget_choice_from_json (enum gp_widget_type widget_type, gp_json_reader *json, gp_json_val *val, gp_widget_json_ctx *ctx) |
Parses JSON into a choice widget. | |
A choice class for widgets.
Definition in file gp_widget_class_choice.h.
typedef struct gp_widget_choice_arr gp_widget_choice_arr |
An array description to take the choices from along with ops to operate on the description.
typedef struct gp_widget_choice_desc gp_widget_choice_desc |
Choice description which could be passed to the JSON loader.
typedef struct gp_widget_choice_ops gp_widget_choice_ops |
A choice widget ops.
These are callbacks called by the widget implementation to get the choice values, selected choice and the number of choices.
The application needs to call gp_widget_choice_refresh() when the state changes, e.g. choice was added to or removed from the set.
enum gp_widget_choice_op |
A choice op for the get callback.
Enumerator | |
---|---|
GP_WIDGET_CHOICE_OP_SEL | Gets index of the selected choice. |
GP_WIDGET_CHOICE_OP_CNT | Gets the number of choices. |
Definition at line 19 of file gp_widget_class_choice.h.
gp_widget * gp_widget_choice_arr_new | ( | enum gp_widget_type | widget_type, |
const void * | array, | ||
size_t | memb_cnt, | ||
uint16_t | memb_size, | ||
uint16_t | memb_off, | ||
size_t | sel, | ||
enum gp_widget_choice_flags | flags | ||
) |
Creates a choice widget based on a static array.
widget_type | A widget type. |
array | A pointer an array. |
memb_cnt | An array size, i.e. number of elements. |
memb_size | An array member size, e.g. sizeof(struct foo) |
memb_off | An offset of the string for the choice in the array, e.g. offsetof(struct foo, str_elem) |
sel | A selected choice. |
flags | A bitwise combination of flags. |
Referenced by gp_widget_radiobutton_arr_new(), and gp_widget_spinbutton_arr_new().
size_t gp_widget_choice_cnt_get | ( | gp_widget * | self | ) |
Returns the number of choices to choose from.
self | A choice widget. |
gp_widget * gp_widget_choice_from_json | ( | enum gp_widget_type | widget_type, |
gp_json_reader * | json, | ||
gp_json_val * | val, | ||
gp_widget_json_ctx * | ctx | ||
) |
Parses JSON into a choice widget.
widget_type | A widget type. |
json | A JSON widget. |
val | A JSON value. |
ctx | A widget JSON loader context. |
const char * gp_widget_choice_name_get | ( | gp_widget * | self, |
size_t | idx | ||
) |
Returns a choice value for a given index.
self | A choice widget. |
idx | An choice index. |
Referenced by gp_widget_choice_sel_name_get().
gp_widget * gp_widget_choice_new | ( | enum gp_widget_type | widget_type, |
const char * | choices[], | ||
size_t | cnt, | ||
size_t | sel | ||
) |
Allocates and initializes new choice widget.
widget_type | A widget type. |
choices | An array of strings describing available choices. |
cnt | Size of the choices array. |
sel | Initially selected choice. |
Referenced by gp_widget_radiobutton_new(), and gp_widget_spinbutton_new().
gp_widget * gp_widget_choice_ops_new | ( | enum gp_widget_type | widget_type, |
const struct gp_widget_choice_ops * | ops | ||
) |
Creates a choice widget based on widget ops.
widget_type | A widget type. |
ops | A pointer to the widget ops. |
Referenced by gp_widget_radiobutton_ops_new(), and gp_widget_spinbutton_ops_new().
size_t gp_widget_choice_prev_sel_get | ( | gp_widget * | self | ) |
Returns previously selected choice.
The value is valid only after choice was changed from the UI, i.e. can be used in the widget event callback to get the previosly selected choice.
self | A choice widget. |
void gp_widget_choice_refresh | ( | gp_widget * | self | ) |
Request update after the choices has been changed.
Causes the choice widget to be resized and rerendered. Since there are cases when the widget state is not stored in the widget, but rather feched by the gp_widget_choice_ops this call tells the widget to call the callback to refresh the state.
self | A choice widget. |
size_t gp_widget_choice_sel_get | ( | gp_widget * | self | ) |
Returns a selected choice.
self | A choice widget. |
Referenced by gp_widget_choice_sel_name_get().
|
inlinestatic |
Returns name of selected choice.
self | A choice widget. |
Definition at line 230 of file gp_widget_class_choice.h.
References gp_widget_choice_name_get(), and gp_widget_choice_sel_get().
void gp_widget_choice_sel_set | ( | gp_widget * | self, |
size_t | sel | ||
) |
Sets a selected choice in the choice widget.
self | A choice widget. |
sel | A choice to select. |