GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Functions
gp_widget_radiobutton.h File Reference

A radio button widget. More...

#include <widgets/gp_widget_class_choice.h>

Go to the source code of this file.

Functions

static gp_widgetgp_widget_radiobutton_new (const char *choices[], size_t cnt, size_t sel)
 Allocates and initializes new radiobutton widget.
 
static gp_widgetgp_widget_radiobutton_ops_new (const struct gp_widget_choice_ops *ops)
 Creates a radiobutton widget based on widget ops.
 
static gp_widgetgp_widget_radiobutton_arr_new (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 radiobutton widget based on a static array.
 

Detailed Description

A radio button widget.

Radio button is a choice class widget, after it's created it's acessed by the class functions such as gp_widget_choice_sel_set().

Choice class JSON attributes

Attribute Type Default Description
choices array of strings List of choices.
ops string The gp_widget_choice_ops structure id.
selected uint or string 0 Currently selected choice name or index.

Only one of the choices or ops can be present for a widget. If choices is present all the choices are statically defined in the widget JSON description. If ops is set it points to a gp_widget_choice_ops structure with callbacks to retrieve the choices at a runtime, this is usally used when the choices are produced by another library e.g. hardware discovery.

Definition in file gp_widget_radiobutton.h.

Function Documentation

◆ gp_widget_radiobutton_arr_new()

static gp_widget * gp_widget_radiobutton_arr_new ( const void *  array,
size_t  memb_cnt,
uint16_t  memb_size,
uint16_t  memb_off,
size_t  sel,
enum gp_widget_choice_flags  flags 
)
inlinestatic

Creates a radiobutton widget based on a static array.

Example use:

static struct unit {
const char *name;
const int mul;
} choices[] = {
...
{.name = "km", .mul = 1000},
{.name = "m", .mul = 1},
...
};
...
choices, GP_ARRAY_SIZE(choices),
sizeof(struct unit), offsetof(struct unit, name),
0, 0);
#define GP_ARRAY_SIZE(array)
Computes number of elements of a statically defined array size.
Definition gp_common.h:144
@ GP_WIDGET_RADIOBUTTON
A radiobutton widget.
Definition gp_widget.h:217
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.
Parameters
arrayA pointer an array.
memb_cntAn array size, i.e. number of elements.
memb_sizeAn array member size, e.g. sizeof(struct foo)
memb_offAn offset of the string for the choice in the array, e.g. offsetof(struct foo, str_elem)
selA selected choice.
flagsA bitwise combination of flags.
Returns
A radiobutton widget.

Definition at line 103 of file gp_widget_radiobutton.h.

References gp_widget_choice_arr_new(), and GP_WIDGET_RADIOBUTTON.

◆ gp_widget_radiobutton_new()

static gp_widget * gp_widget_radiobutton_new ( const char *  choices[],
size_t  cnt,
size_t  sel 
)
inlinestatic

Allocates and initializes new radiobutton widget.

Parameters
choicesAn array of strings describing available choices.
cntSize of the choices array.
selInitially selected choice.
Returns
A radiobutton widget.

Definition at line 49 of file gp_widget_radiobutton.h.

References gp_widget_choice_new(), and GP_WIDGET_RADIOBUTTON.

◆ gp_widget_radiobutton_ops_new()

static gp_widget * gp_widget_radiobutton_ops_new ( const struct gp_widget_choice_ops ops)
inlinestatic

Creates a radiobutton widget based on widget ops.

Parameters
opsA pointer to the choice widget ops.
Returns
A radio button widget.

Definition at line 63 of file gp_widget_radiobutton.h.

References gp_widget_choice_ops_new(), and GP_WIDGET_RADIOBUTTON.