Functions | |
struct win_window * | wtk_button_as_child (struct wtk_button *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_button * | wtk_button_create (struct win_window *parent, struct win_area const *area, char const *caption, win_command_t command_data) |
This function creates a new button widget. More... | |
win_command_t | wtk_button_get_command (struct wtk_button *button) |
This function returns the window command of the specified button, as set when the widget was created. More... | |
void | wtk_button_size_hint (struct win_point *size, const char *caption) |
Get minimum widget size. More... | |
#define | WTK_BUTTON_BORDER_COLOR GFX_COLOR_BLACK |
Button border color. More... | |
#define | WTK_BUTTON_BACKGROUND_COLOR GFX_COLOR_GRAY |
Color of button background (text color when highlighted). More... | |
#define | WTK_BUTTON_CAPTION_COLOR GFX_COLOR_WHITE |
Color of button text (background color when highlighted). More... | |
#define | WTK_BUTTON_BORDER_COLOR GFX_COLOR_BLACK |
Button border color. More... | |
#define | WTK_BUTTON_BACKGROUND_COLOR GFX_COLOR_GRAY |
Color of button background (text color when highlighted). More... | |
#define | WTK_BUTTON_CAPTION_COLOR GFX_COLOR_WHITE |
Color of button text (background color when highlighted). More... | |
#define | WTK_BUTTON_BORDER_COLOR GFX_COLOR_BLACK |
Button border color. More... | |
#define | WTK_BUTTON_BACKGROUND_COLOR GFX_COLOR_GRAY |
Color of button background (text color when highlighted). More... | |
#define | WTK_BUTTON_CAPTION_COLOR GFX_COLOR_WHITE |
Color of button text (background color when highlighted). More... | |
#define | WTK_BUTTON_BORDER_COLOR GFX_COLOR_BLACK |
Button border color. More... | |
#define | WTK_BUTTON_BACKGROUND_COLOR GFX_COLOR_GRAY |
Color of button background (text color when highlighted). More... | |
#define | WTK_BUTTON_CAPTION_COLOR GFX_COLOR_WHITE |
Color of button text (background color when highlighted). More... | |
#define | WTK_BUTTON_BORDER_COLOR GFX_COLOR_BLACK |
Button border color. More... | |
#define | WTK_BUTTON_BACKGROUND_COLOR GFX_COLOR_GRAY |
Color of button background (text color when highlighted). More... | |
#define | WTK_BUTTON_CAPTION_COLOR GFX_COLOR_WHITE |
Color of button text (background color when highlighted). More... | |
enum | wtk_button_state { WTK_BUTTON_NORMAL, WTK_BUTTON_PRESSED } |
Valid states for button, relevant to pointer and keyboard operations. More... | |
static bool | wtk_button_handler (struct win_window *win, enum win_event_type type, void const *data) |
This function is the window event handler for button widgets. More... | |
#define WTK_BUTTON_BACKGROUND_COLOR GFX_COLOR_GRAY |
Color of button background (text color when highlighted).
Referenced by wtk_button_handler().
#define WTK_BUTTON_BACKGROUND_COLOR GFX_COLOR_GRAY |
Color of button background (text color when highlighted).
#define WTK_BUTTON_BACKGROUND_COLOR GFX_COLOR_GRAY |
Color of button background (text color when highlighted).
#define WTK_BUTTON_BACKGROUND_COLOR GFX_COLOR_GRAY |
Color of button background (text color when highlighted).
#define WTK_BUTTON_BACKGROUND_COLOR GFX_COLOR_GRAY |
Color of button background (text color when highlighted).
#define WTK_BUTTON_BORDER_COLOR GFX_COLOR_BLACK |
Button border color.
#define WTK_BUTTON_BORDER_COLOR GFX_COLOR_BLACK |
Button border color.
#define WTK_BUTTON_BORDER_COLOR GFX_COLOR_BLACK |
Button border color.
#define WTK_BUTTON_BORDER_COLOR GFX_COLOR_BLACK |
Button border color.
#define WTK_BUTTON_BORDER_COLOR GFX_COLOR_BLACK |
Button border color.
Referenced by wtk_button_handler().
#define WTK_BUTTON_CAPTION_COLOR GFX_COLOR_WHITE |
Color of button text (background color when highlighted).
Referenced by wtk_button_handler().
#define WTK_BUTTON_CAPTION_COLOR GFX_COLOR_WHITE |
Color of button text (background color when highlighted).
#define WTK_BUTTON_CAPTION_COLOR GFX_COLOR_WHITE |
Color of button text (background color when highlighted).
#define WTK_BUTTON_CAPTION_COLOR GFX_COLOR_WHITE |
Color of button text (background color when highlighted).
#define WTK_BUTTON_CAPTION_COLOR GFX_COLOR_WHITE |
Color of button text (background color when highlighted).
enum wtk_button_state |
struct win_window* wtk_button_as_child | ( | struct wtk_button * | button | ) |
This function returns a reference to the window that should be used when managing the widget, such as move, resize, destroy and reparenting.
button | Button widget to manage. |
References Assert, and wtk_button::container.
Referenced by app_widget_launch().
struct wtk_button* wtk_button_create | ( | struct win_window * | parent, |
struct win_area const * | area, | ||
char const * | caption, | ||
win_command_t | command_data | ||
) |
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.
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". |
References win_attributes::area, Assert, win_attributes::background, win_attributes::behavior, wtk_button::caption, wtk_button::command, wtk_button::container, win_attributes::custom, win_attributes::event_handler, membag_alloc(), membag_free(), wtk_button::state, win_create(), wtk_button_handler(), WTK_BUTTON_NORMAL, and wtk_copy_string().
Referenced by app_widget_launch().
win_command_t wtk_button_get_command | ( | struct wtk_button * | button | ) |
This function returns the window command of the specified button, as set when the widget was created.
button | Button widget to manage. |
References Assert, and wtk_button::command.
|
static |
This function is the window event handler for button widgets.
It handles all events sent to the windows composing the widget.
win | Window receiving the event. |
type | The event type. |
data | Custom data, depending on event type. |
References Assert, wtk_button::caption, wtk_button::container, win_command_event::data, GFX_COLOR_TRANSPARENT, gfx_draw_filled_rect, gfx_draw_rect, gfx_draw_string_aligned(), membag_free(), win_clip_region::origin, win_command_event::recipient, win_command_event::sender, win_area::size, wtk_button::state, sysfont, TEXT_ALIGN_CENTER, TEXT_POS_CENTER, WIN_EVENT_DESTROY, WIN_EVENT_DRAW, WIN_EVENT_POINTER, win_get_area(), win_get_custom_data(), win_grab_pointer(), win_is_inside_window(), WIN_POINTER_PRESS, WIN_POINTER_RELEASE, win_queue_command_event(), win_redraw(), WTK_BUTTON_BACKGROUND_COLOR, WTK_BUTTON_BORDER_COLOR, WTK_BUTTON_CAPTION_COLOR, WTK_BUTTON_NORMAL, WTK_BUTTON_PRESSED, win_point::x, and win_point::y.
Referenced by wtk_button_create().
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.
size | Suggested size for the widget |
caption | Pointer to caption string to use for widget. |
References Assert, gfx_get_string_bounding_box(), sysfont, win_point::x, and win_point::y.