Data Structures | |
struct | wtk_label |
This is the label control struct. More... | |
Functions | |
struct win_window * | wtk_label_as_child (struct wtk_label *label) |
This function returns a reference to the window that should be used when managing the widget, such as move, resize, destroy and reparenting. More... | |
bool | wtk_label_change (struct wtk_label *label, const char *caption) |
Set new caption for label, return false if out of mem. More... | |
struct wtk_label * | wtk_label_create (struct win_window *parent, struct win_area const *area, char const *caption, gfx_color_t text_color, struct gfx_bitmap *background, bool align_right) |
This function creates a new label widget. More... | |
void | wtk_label_size_hint (struct win_point *size, const char *caption) |
Get minimum widget size. More... | |
static bool | wtk_label_handler (struct win_window *win, enum win_event_type type, void const *data) |
This function is the window event handler for label widgets. More... | |
struct win_window* wtk_label_as_child | ( | struct wtk_label * | label | ) |
This function returns a reference to the window that should be used when managing the widget, such as move, resize, destroy and reparenting.
label | Label widget to manage. |
References Assert, and wtk_label::container.
Referenced by app_widget_launch().
Set new caption for label, return false if out of mem.
References Assert, wtk_label::caption, wtk_label::container, membag_alloc(), membag_free(), win_redraw(), and wtk_copy_string().
Referenced by app_calc_update_disp(), and widget_frame_command_handler().
struct wtk_label* wtk_label_create | ( | struct win_window * | parent, |
struct win_area const * | area, | ||
char const * | caption, | ||
gfx_color_t | text_color, | ||
struct gfx_bitmap * | background, | ||
bool | align_right | ||
) |
This function creates a new label 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 label's child reference, given by wtk_label_as_child(), like this: "win_destroy(wtk_label_as_child(myStaticTextPtr));". 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. |
text_color | Foreground color of the text when drawn. |
background | Background of the label. |
align_right | True if caption is to be aligned to the right, false otherwise. |
References wtk_label::align_right, win_attributes::area, Assert, win_attributes::background, win_attributes::behavior, wtk_label::caption, wtk_label::container, win_attributes::custom, win_attributes::event_handler, membag_alloc(), membag_free(), wtk_label::text_color, WIN_BEHAVIOR_REDRAW_PARENT, win_create(), wtk_copy_string(), and wtk_label_handler().
Referenced by app_widget_launch().
|
static |
This function is the window event handler for label 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 wtk_label::align_right, Assert, wtk_label::caption, wtk_label::container, GFX_COLOR_TRANSPARENT, gfx_draw_string(), gfx_get_string_bounding_box(), membag_free(), win_clip_region::origin, win_area::size, sysfont, wtk_label::text_color, WIN_EVENT_DESTROY, WIN_EVENT_DRAW, win_get_area(), win_get_custom_data(), win_point::x, and win_point::y.
Referenced by wtk_label_create().
void wtk_label_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.
Referenced by app_widget_launch().