Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Label widget

Data Structures

struct  wtk_label
 This is the label control struct. More...
 

Functions

struct win_windowwtk_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_labelwtk_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.

Parameters
labelLabel widget to manage.
Returns
Window to be used for managing the label.

References Assert, and wtk_label::container.

Referenced by app_widget_launch(), app_widget_launch_audio(), app_widget_launch_info(), app_widget_launch_lpm(), app_widget_launch_lpm_backup(), app_widget_launch_lpm_sleep(), app_widget_launch_lpm_wait(), app_widget_launch_main(), app_widget_launch_settings(), app_widget_launch_settings_backlight(), app_widget_launch_settings_date(), and app_widget_launch_settings_time().

bool wtk_label_change ( struct wtk_label label,
const char *  caption 
)
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.

Parameters
parentParent window, possibly wtk_frame_as_parent(myFramePtr).
areaArea of the internal contents.
captionPointer to caption string. Will be copied into widget.
text_colorForeground color of the text when drawn.
backgroundBackground of the label.
align_rightTrue if caption is to be aligned to the right, false otherwise.
Returns
Pointer to label, or NULL if failed.

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(), NULL, wtk_label::text_color, WIN_BEHAVIOR_REDRAW_PARENT, win_create(), wtk_copy_string(), and wtk_label_handler().

Referenced by app_widget_launch(), app_widget_launch_audio(), app_widget_launch_info(), app_widget_launch_lpm(), app_widget_launch_lpm_backup(), app_widget_launch_lpm_sleep(), app_widget_launch_lpm_wait(), app_widget_launch_main(), app_widget_launch_settings(), app_widget_launch_settings_backlight(), app_widget_launch_settings_date(), and app_widget_launch_settings_time().

static bool wtk_label_handler ( struct win_window win,
enum win_event_type  type,
void const *  data 
)
static

This function is the window event handler for label widgets.

It handles all events sent to the windows composing the widget.

Parameters
winWindow receiving the event.
typeThe event type.
dataCustom data, depending on event type.
Returns
True if the event was recognized and accepted.

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.

Return values
sizeSuggested size for the widget
Parameters
captionPointer 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(), app_widget_launch_audio(), app_widget_launch_info(), app_widget_launch_lpm(), app_widget_launch_lpm_backup(), app_widget_launch_lpm_sleep(), app_widget_launch_lpm_wait(), app_widget_launch_main(), app_widget_launch_settings(), app_widget_launch_settings_backlight(), app_widget_launch_settings_date(), and app_widget_launch_settings_time().