|
Functions | |
| struct wtk_button * | wtk_button_create (struct win_window *parent, struct win_area const *area, char const *caption, win_command_t command_data) |
| struct win_window * | wtk_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 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) |
| #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().
| enum wtk_button_state |
Valid states for button, relevant to pointer and keyboard operations.
For internal use only.
| 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.
| 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.
| button | Button widget to manage. |
Definition at line 87 of file wtk_button.c.
References assert, and wtk_button::container.
| 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.
| 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. |
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().
| static bool wtk_button_handler | ( | struct win_window * | win, | |
| enum win_event_type | type, | |||
| void const * | data | |||
| ) | [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. |
Definition at line 103 of file wtk_button.c.
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(), gfx_get_string_bounding_box(), membag_free(), win_clip_region::origin, win_command_event::recipient, win_command_event::sender, win_area::size, wtk_button::state, sysfont, 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, and WTK_BUTTON_PRESSED.
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. |
Definition at line 277 of file wtk_button.c.
References assert, gfx_get_string_bounding_box(), and sysfont.
1.6.3