Button widget
[Widget toolkit]

Collaboration diagram for Button widget:

Functions

struct wtk_buttonwtk_button_create (struct win_window *parent, struct win_area const *area, char const *caption, win_command_t command_data)
struct win_windowwtk_button_as_child (struct wtk_button *button)
void wtk_button_size_hint (struct win_point *size, const char *caption)
 Get minimum widget size.



enum  wtk_button_state { WTK_BUTTON_NORMAL, WTK_BUTTON_PRESSED }
static bool wtk_button_handler (struct win_window *win, enum win_event_type type, void const *data)



#define WTK_BUTTON_BORDER_COLOR   GFX_COLOR(0, 0, 0)
 Button border color.
#define WTK_BUTTON_BACKGROUND_COLOR   GFX_COLOR(128, 128, 128)
 Color of button background (text color when highlighted).
#define WTK_BUTTON_CAPTION_COLOR   GFX_COLOR(255, 255, 255)
 Color of button text (background color when highlighted).

Define Documentation

#define WTK_BUTTON_BACKGROUND_COLOR   GFX_COLOR(128, 128, 128)

Color of button background (text color when highlighted).

Definition at line 192 of file wtk.h.

Referenced by wtk_button_handler().

#define WTK_BUTTON_BORDER_COLOR   GFX_COLOR(0, 0, 0)

Button border color.

Definition at line 187 of file wtk.h.

Referenced by wtk_button_handler().

#define WTK_BUTTON_CAPTION_COLOR   GFX_COLOR(255, 255, 255)

Color of button text (background color when highlighted).

Definition at line 197 of file wtk.h.

Referenced by wtk_button_handler().


Enumeration Type Documentation

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

For internal use only.

Enumerator:
WTK_BUTTON_NORMAL 

Normal state, no highlight or press.

WTK_BUTTON_PRESSED 

Widget pressed, action occurs when released.

Definition at line 53 of file wtk_button.c.


Function Documentation

struct win_window* wtk_button_as_child ( struct wtk_button 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:
button Button widget to manage.
Returns:
Window to be used for managing the button.

Definition at line 87 of file wtk_button.c.

References assert, and wtk_button::container.

Referenced by app_fonts_load_worker(), app_memgame_launch(), and app_tank_launch().

struct wtk_button* wtk_button_create ( struct win_window parent,
struct win_area const *  area,
char const *  caption,
win_command_t  command_data 
) [read]

This function creates a new 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 button's child reference, given by wtk_button_as_child(), like this: "win_destroy(wtk_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.
command_data Custom data to put into a command event when "clicked". Must be non-zero.
Returns:
Pointer to button, or NULL if failed.

Definition at line 307 of file wtk_button.c.

References win_attributes::area, assert, win_attributes::background, win_attributes::behavior, wtk_button::caption, wtk_button::command_data, wtk_button::container, win_attributes::custom, win_attributes::event_handler, membag_alloc(), membag_free(), wtk_button::state, strlen(), win_create(), wtk_button_handler(), WTK_BUTTON_NORMAL, and wtk_copy_string().

Referenced by app_memgame_launch(), and app_tank_launch().

static bool wtk_button_handler ( struct win_window win,
enum win_event_type  type,
void const *  data 
) [static]
void wtk_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 277 of file wtk_button.c.

References assert, gfx_get_string_bounding_box(), and sysfont.

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