Radio button widget
[Widget toolkit]

Collaboration diagram for Radio button widget:

Functions

struct wtk_radio_groupwtk_radio_group_create (void)
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)
struct win_windowwtk_radio_button_as_child (struct wtk_radio_button *radio_button)
void wtk_radio_button_select (struct wtk_radio_button *radio_button)
bool wtk_radio_button_is_selected (struct wtk_radio_button const *radio_button)
void wtk_radio_button_size_hint (struct win_point *size, const char *caption)
 Get minimum widget size.



enum  wtk_radio_button_state { WTK_RADIOBUTTON_NORMAL, WTK_RADIOBUTTON_PRESSED }
static bool wtk_radio_button_handler (struct win_window *win, enum win_event_type type, void const *data)



typedef uint8_t wtk_radio_group_size_t
 Datatype holding reference count for radio button groups.

Typedef Documentation

Datatype holding reference count for radio button groups.

Definition at line 255 of file wtk.h.


Enumeration Type Documentation

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

For internal use only.

Enumerator:
WTK_RADIOBUTTON_NORMAL 

Normal state, no highlight or press.

WTK_RADIOBUTTON_PRESSED 

Widget pressed, action occurs when released.

Definition at line 54 of file wtk_radio_button.c.


Function Documentation

struct win_window* wtk_radio_button_as_child ( struct wtk_radio_button radio_button  )  [read]

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_button Radio button widget to manage.
Returns:
Window to be used for managing the radio button.

Definition at line 105 of file wtk_radio_button.c.

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 
) [read]

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:
parent Parent window, possibly wtk_frame_as_parent(myFramePtr).
area Area of the internal contents.
caption Pointer to caption string. Will be copied into widget.
selected Initial state of radio button, true if checked/selected.
group Radio button group to be a member of.
command Command to send to parent window. Must be non-zero to be enabled.
Returns:
Pointer to radio button, or NULL if failed.

Definition at line 372 of file wtk_radio_button.c.

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, L, membag_alloc(), membag_free(), wtk_radio_group::num_references, wtk_radio_group::selected, wtk_radio_button::state, strlen(), WIN_BEHAVIOR_REDRAW_PARENT, win_create(), win_redraw(), wtk_copy_string(), wtk_radio_button_handler(), and WTK_RADIOBUTTON_NORMAL.

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.

Returns:
True if radio button selected.

Definition at line 146 of file wtk_radio_button.c.

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_button Radio button widget to select.

Definition at line 119 of file wtk_radio_button.c.

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

Referenced by 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:
size Suggested size for the widget
Parameters:
caption Pointer to caption string to use for widget.

Definition at line 340 of file wtk_radio_button.c.

References assert, gfx_get_string_bounding_box(), font::height, max_s, font::scale, sysfont, WTK_RADIOBUTTON_BUTTON_Y, WTK_RADIOBUTTON_CAPTION_X, WTK_RADIOBUTTON_CAPTION_Y, and WTK_RADIOBUTTON_RADIUS.

struct wtk_radio_group* wtk_radio_group_create ( void   )  [read]

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.

Definition at line 453 of file wtk_radio_button.c.

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

Generated on Thu Apr 29 14:09:59 2010 for display-demo by  doxygen 1.6.3