Label widget
[Widget toolkit]

Collaboration diagram for Label widget:

Data Structures

struct  wtk_label

Functions

struct wtk_labelwtk_label_create (struct win_window *parent, struct win_area const *area, char const *caption, bool align_right)
struct win_windowwtk_label_as_child (struct wtk_label *label)
bool wtk_label_change (struct wtk_label *label, const char *caption)
 Set new caption for label, return false if out of mem.
void wtk_label_size_hint (struct win_point *size, const char *caption)
 Get minimum widget size.



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



#define WTK_STATICTEXT_CAPTION_COLOR   GFX_COLOR(255, 255, 255)
 Static text caption text color.

Define Documentation

#define WTK_STATICTEXT_CAPTION_COLOR   GFX_COLOR(255, 255, 255)

Static text caption text color.

Definition at line 351 of file wtk.h.

Referenced by wtk_label_handler().


Function Documentation

struct win_window* wtk_label_as_child ( struct wtk_label label  )  [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:
label Label widget to manage.
Returns:
Window to be used for managing the label.

Definition at line 74 of file wtk_label.c.

References assert, and wtk_label::container.

bool wtk_label_change ( struct wtk_label label,
const char *  caption 
)

Set new caption for label, return false if out of mem.

Definition at line 81 of file wtk_label.c.

References assert, wtk_label::caption, wtk_label::container, membag_alloc(), membag_free(), strlen(), win_redraw(), and wtk_copy_string().

struct wtk_label* wtk_label_create ( struct win_window parent,
struct win_area const *  area,
char const *  caption,
bool  align_right 
) [read]

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:
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.
align_right True if caption is to be aligned to the right, false otherwise
Returns:
Pointer to label, or NULL if failed.

Definition at line 235 of file wtk_label.c.

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(), strlen(), WIN_BEHAVIOR_REDRAW_PARENT, win_create(), wtk_copy_string(), and wtk_label_handler().

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:
win Window receiving the event.
type The event type.
data Custom data, depending on event type.
Returns:
True if the event was recognized and accepted.

Definition at line 131 of file wtk_label.c.

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, WIN_EVENT_DESTROY, WIN_EVENT_DRAW, win_get_area(), win_get_custom_data(), and WTK_STATICTEXT_CAPTION_COLOR.

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:
size Suggested size for the widget
Parameters:
caption Pointer to caption string to use for widget.

Definition at line 209 of file wtk_label.c.

References assert, gfx_get_string_bounding_box(), and sysfont.

Generated on Thu Apr 29 15:18:23 2010 for display-training by  doxygen 1.6.3