Atmel Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Radio button widget

Functions

struct win_windowwtk_radio_button_as_child (struct wtk_radio_button *radio_button)
 This function returns a reference to the window that should be used when managing the widget, such as move, resize, destroy and reparenting. More...
 
struct wtk_radio_buttonwtk_radio_button_create (struct win_window *parent, struct win_area const *area, char const *caption, bool selected, struct wtk_radio_group *group, win_command_t command_data)
 This function creates a new radio button widget. More...
 
win_command_t wtk_radio_button_get_command (struct wtk_radio_button *radio_button)
 This function returns the window command of the specified radio button, as set when the widget was created. More...
 
bool wtk_radio_button_is_selected (struct wtk_radio_button const *radio_button)
 This function returns true if the radio button is the one currently selected within its radio button group. More...
 
void wtk_radio_button_select (struct wtk_radio_button *radio_button)
 This function sets this radio button to be the single radio button selected within its group. More...
 
void wtk_radio_button_size_hint (struct win_point *size, const char *caption)
 Get minimum widget size. More...
 
struct wtk_radio_groupwtk_radio_group_create (void)
 This function creates a new radio button group, allocating required memory and properly initializing the object. More...
 
struct wtk_radio_buttonwtk_radio_group_get_selected (struct wtk_radio_group *group)
 This function retrieves a pointer to the currently selected radio button in a radio group. More...
 
enum  wtk_radio_button_state {
  WTK_RADIOBUTTON_NORMAL,
  WTK_RADIOBUTTON_PRESSED
}
 Valid states for radio button, relevant to pointer and keyboard operations. More...
 
static bool wtk_radio_button_handler (struct win_window *win, enum win_event_type type, void const *data)
 This function is the window event handler for radio button widgets. More...
 

Valid states for radio button, relevant to pointer and keyboard operations.

Enumerator
WTK_RADIOBUTTON_NORMAL 

Normal state, no highlight or press.

WTK_RADIOBUTTON_PRESSED 

Widget pressed, action occurs when released.

struct win_window* wtk_radio_button_as_child ( struct wtk_radio_button radio_button)

This function returns a reference to the window that should be used when managing the widget, such as move, resize, destroy and reparenting.

Parameters
radio_buttonRadio button widget to manage.
Returns
Window to be used for managing the radio button.

References Assert, and wtk_radio_button::container.

struct wtk_radio_button* wtk_radio_button_create ( struct win_window parent,
struct win_area const *  area,
char const *  caption,
bool  selected,
struct wtk_radio_group group,
win_command_t  command 
)

This function creates a new radio button widget.

It allocates required memory and intializes necessary windows to create the widget. If there is not enough memory, the function returns NULL. To destroy the widget and all its contents, and free its memory, call win_destroy() on the radio button's child reference, given by wtk_radio_button_as_child(), like this: "win_destroy(wtk_radio_button_as_child(myButtonPtr));". Usually it will be destroyed automatically when it's parent is destroyed.

Parameters
parentParent window, possibly wtk_frame_as_parent(myFramePtr).
areaArea of the internal contents.
captionPointer to caption string. Will be copied into widget.
selectedInitial state of radio button, true if checked/selected.
groupRadio button group to be a member of.
commandCommand to send to parent window. Must be non-zero to be enabled.
Returns
Pointer to radio button, or NULL if failed.

References win_attributes::area, Assert, win_attributes::background, win_attributes::behavior, wtk_radio_button::caption, wtk_radio_button::command, wtk_radio_button::container, win_attributes::custom, win_attributes::event_handler, wtk_radio_button::group, membag_alloc(), membag_free(), NULL, wtk_radio_group::num_references, wtk_radio_group::selected, wtk_radio_button::state, WIN_BEHAVIOR_REDRAW_PARENT, win_create(), wtk_copy_string(), wtk_radio_button_handler(), wtk_radio_button_select(), and WTK_RADIOBUTTON_NORMAL.

win_command_t wtk_radio_button_get_command ( struct wtk_radio_button radio_button)

This function returns the window command of the specified radio button, as set when the widget was created.

Parameters
radio_buttonRadio button widget to manage.
Returns
Associated window command of the radio button widget.

References Assert, and wtk_radio_button::command.

static bool wtk_radio_button_handler ( struct win_window win,
enum win_event_type  type,
void const *  data 
)
static
bool wtk_radio_button_is_selected ( struct wtk_radio_button const *  radio_button)

This function returns true if the radio button is the one currently selected within its radio button group.

Parameters
radio_buttonRadio button widget to check.
Returns
True if radio button selected.

References Assert, wtk_radio_button::group, and wtk_radio_group::selected.

void wtk_radio_button_select ( struct wtk_radio_button radio_button)

This function sets this radio button to be the single radio button selected within its group.

If another radio button was selected, it will be deselected. Both widgets will be redrawn if visible.

Parameters
radio_buttonRadio button widget to select.

References Assert, wtk_radio_button::container, wtk_radio_button::group, wtk_radio_group::selected, and win_redraw().

Referenced by wtk_radio_button_create(), and wtk_radio_button_handler().

void wtk_radio_button_size_hint ( struct win_point size,
const char *  caption 
)

Get minimum widget size.

This function returns the minimum size that is required for showing the full widget and the caption.

Return values
sizeSuggested size for the widget
Parameters
captionPointer to caption string to use for widget.

References Assert, gfx_get_string_bounding_box(), sysfont, win_point::x, and win_point::y.

struct wtk_radio_group* wtk_radio_group_create ( void  )

This function creates a new radio button group, allocating required memory and properly initializing the object.

If there is not enough memory, the function returns NULL. The radio button group will keep a reference count for its members, and will be automatically destroyed when the last member is destroyed.

Returns
Pointer to radio button group, or NULL if failed.

References membag_alloc(), NULL, wtk_radio_group::num_references, and wtk_radio_group::selected.

struct wtk_radio_button* wtk_radio_group_get_selected ( struct wtk_radio_group group)

This function retrieves a pointer to the currently selected radio button in a radio group.

Returns
Pointer to the selected radio button in a radio button group, or NULL if no item is selected.

References Assert, and wtk_radio_group::selected.