EasyGUI  Version v1.0
Radio box

Radio box widget. More...

Data Structures

struct  gui_radio_t
 Radio object structure. More...
 

Macros

#define GUI_FLAG_RADIO_CHECKED   0x01
 
#define GUI_FLAG_RADIO_DISABLED   0x02
 

Enumerations

enum  gui_radio_color_t { GUI_RADIO_COLOR_BG = 0x00, GUI_RADIO_COLOR_FG, GUI_RADIO_COLOR_BORDER, GUI_RADIO_COLOR_DISABLED_BG }
 List of radio colors. More...
 

Functions

gui_handle_p gui_radio_create (gui_id_t id, float x, float y, float width, float height, gui_handle_p parent, gui_widget_callback_t cb, uint16_t flags)
 Create new radio widget. More...
 
uint8_t gui_radio_setcolor (gui_handle_p h, gui_radio_color_t index, gui_color_t color)
 Set color to specific part of widget. More...
 
uint8_t gui_radio_setgroup (gui_handle_p h, uint8_t groupId)
 Set radio group for widget. More...
 
uint8_t gui_radio_getgroup (gui_handle_p h)
 Get radio group for widget. More...
 
uint8_t gui_radio_setvalue (gui_handle_p h, uint32_t value)
 Set value for widget when pressed. More...
 
uint32_t gui_radio_getvalue (gui_handle_p h)
 Get value for specific widget. More...
 
uint32_t gui_radio_getselectedvalue (gui_handle_p h)
 Get value of selected widget from widget group. More...
 
uint8_t gui_radio_setdisabled (gui_handle_p h, uint8_t disabled)
 Set disabled status to widget. More...
 
uint8_t gui_radio_isdisabled (gui_handle_p h)
 Check if Radio is disabled. More...
 
uint8_t gui_radio_setselected (gui_handle_p h)
 Set radio widget selected in radio group. More...
 

Detailed Description

Radio box widget.

Radiobox widget acts in a group of radio widgets to have support for single selection from multiple available choices

image_widget_radiobox.png
Radiobox widgets in different states

Sample code to create example image above

uint8_t i;
for (i = 0; i < 4; i++) {
handle = gui_radio_create(10, 10, 10 + (i * 30), 300, 25, h, 0, 0);
switch (i) {
case 0: gui_widget_settext(handle, _GT("Radio box default")); break;
case 1: gui_widget_settext(handle, _GT("Radio box selected")); break;
case 2: gui_widget_settext(handle, _GT("Radio box disabled")); break;
case 3: gui_widget_settext(handle, _GT("Radio box disabled checked")); break;
default: break;
}
gui_radio_setgroup(handle, i < 2 ? 1 : 2);
gui_radio_setvalue(handle, i);
if (i % 2) {
}
gui_radio_setdisabled(handle, i / 2);
}

Macro Definition Documentation

◆ GUI_FLAG_RADIO_CHECKED

#define GUI_FLAG_RADIO_CHECKED   0x01

Indicates radio is currently checked

◆ GUI_FLAG_RADIO_DISABLED

#define GUI_FLAG_RADIO_DISABLED   0x02

Indicates radio is currently disabled

Enumeration Type Documentation

◆ gui_radio_color_t

List of radio colors.

Enumerator
GUI_RADIO_COLOR_BG 

Background color index

GUI_RADIO_COLOR_FG 

Foreground color index

GUI_RADIO_COLOR_BORDER 

Border color index

GUI_RADIO_COLOR_DISABLED_BG 

Background color index when disabled

Function Documentation

◆ gui_radio_create()

gui_handle_p gui_radio_create ( gui_id_t  id,
float  x,
float  y,
float  width,
float  height,
gui_handle_p  parent,
gui_widget_callback_t  cb,
uint16_t  flags 
)

Create new radio widget.

Parameters
[in]idWidget unique ID to use for identity for callback processing
[in]xWidget X position relative to parent widget
[in]yWidget Y position relative to parent widget
[in]widthWidget width in units of pixels
[in]heightWidget height in uints of pixels
[in]parentParent widget handle. Set to NULL to use current active parent widget
[in]cbPointer to gui_widget_callback_t callback function. Set to NULL to use default widget callback
[in]flagsflags for widget creation
Returns
gui_handle_p object of created widget on success, NULL otherwise

◆ gui_radio_getgroup()

uint8_t gui_radio_getgroup ( gui_handle_p  h)

Get radio group for widget.

Parameters
[in,out]hWidget handle
Returns
Widget group
See also
gui_radio_setgroup

◆ gui_radio_getselectedvalue()

uint32_t gui_radio_getselectedvalue ( gui_handle_p  h)

Get value of selected widget from widget group.

Note
If 3 widgets share the same group ID, no matter which widget is used in this function, result will be always the same
Parameters
[in,out]hWidget handle
Returns
Widget selected value

◆ gui_radio_getvalue()

uint32_t gui_radio_getvalue ( gui_handle_p  h)

Get value for specific widget.

Parameters
[in,out]hWidget handle
Returns
Widget value
See also
gui_radio_setvalue

◆ gui_radio_isdisabled()

uint8_t gui_radio_isdisabled ( gui_handle_p  h)

Check if Radio is disabled.

Parameters
[in,out]hWidget handle
Returns
1 on success, 0 otherwise

◆ gui_radio_setcolor()

uint8_t gui_radio_setcolor ( gui_handle_p  h,
gui_radio_color_t  index,
gui_color_t  color 
)

Set color to specific part of widget.

Parameters
[in,out]hWidget handle
[in]indexColor index. This parameter can be a value of gui_radio_color_t enumeration
[in]colorColor value
Returns
1 on success, 0 otherwise

◆ gui_radio_setdisabled()

uint8_t gui_radio_setdisabled ( gui_handle_p  h,
uint8_t  disabled 
)

Set disabled status to widget.

Parameters
[in,out]hWidget handle
[in]disabledDisabled status
Returns
1 on success, 0 otherwise

◆ gui_radio_setgroup()

uint8_t gui_radio_setgroup ( gui_handle_p  h,
uint8_t  groupId 
)

Set radio group for widget.

Note
Radio widgets with the same group must be on the same parent widget
Parameters
[in,out]hWidget handle
[in]groupIdGroup ID for widget
Returns
1 on success, 0 otherwise
See also
gui_radio_getgroup

◆ gui_radio_setselected()

uint8_t gui_radio_setselected ( gui_handle_p  h)

Set radio widget selected in radio group.

Parameters
[in,out]hWidget handle
Returns
1 on success, 0 otherwise

◆ gui_radio_setvalue()

uint8_t gui_radio_setvalue ( gui_handle_p  h,
uint32_t  value 
)

Set value for widget when pressed.

Parameters
[in,out]hWidget handle
[in]valueValue of widget group when specific widget is selected
Returns
1 on success, 0 otherwise
See also
gui_radio_getvalue