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, GUI_iDim_t x, GUI_iDim_t y, GUI_Dim_t width, GUI_Dim_t 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,
GUI_iDim_t  x,
GUI_iDim_t  y,
GUI_Dim_t  width,
GUI_Dim_t  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
Return values
>0: GUI_HANDLE_p object of created widget
0Widget creation failed

◆ gui_radio_getgroup()

uint8_t gui_radio_getgroup ( GUI_HANDLE_p  h)

Get radio group for widget.

Parameters
[in,out]hWidget handle
Return values
Widgetgroup
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
Return values
Widgetselected value

◆ gui_radio_getvalue()

uint32_t gui_radio_getvalue ( GUI_HANDLE_p  h)

Get value for specific widget.

Parameters
[in,out]hWidget handle
Return values
Widgetvalue
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
Return values
1Radio is disabled
0Radio is not disabled

◆ 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
Return values
1Color was set ok
0Color vas not set

◆ 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
Return values
1Radio was set to desired disabled value
0Radio was not set to desired disabled value

◆ 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
Return values
1Group set ok
0Group was not set
See also
gui_radio_getgroup

Find radio widgets on the same parent and with the group the same as desired group ID

This is to set selected value to new radio with new group ID

◆ gui_radio_setselected()

uint8_t gui_radio_setselected ( GUI_HANDLE_p  h)

Set radio widget selected in radio group.

Parameters
[in,out]hWidget handle
Return values
1Widget selected ok
0Widget was not selected

◆ 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
Return values
1Value set ok
0Value was not set
See also
gui_radio_getvalue