GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
A label widget. More...
Go to the source code of this file.
Enumerations | |
enum | gp_widget_label_flags { GP_WIDGET_LABEL_FRAME =0x01 } |
A label flags. More... | |
Functions | |
void | gp_widget_label_set (gp_widget *self, const char *text) |
Sets the label text. | |
const char * | gp_widget_label_get (gp_widget *self) |
Gets the label text. | |
void | gp_widget_labe_fmt_set (gp_widget *self, const char *text_fmt) |
Sets the label text format. | |
void | gp_widget_label_fmt_var_set (gp_widget *self, const char *fmt,...) |
Sets label accordingly to text format string. | |
void | gp_widget_label_append (gp_widget *self, const char *text) |
Appends text to the label. | |
int | gp_widget_label_printf (gp_widget *self, const char *fmt,...) __attribute__((format(printf |
Printf-like function to set label text. | |
int void | gp_widget_label_vprintf (gp_widget *self, const char *fmt, va_list ap) |
VPrintf-like function to set label text. | |
void | gp_widget_label_tattr_set (gp_widget *self, gp_widget_tattr tattr) |
Changes text attributes. | |
gp_widget_tattr | gp_widget_label_tattr_get (gp_widget *self) |
Gets text attributes. | |
void | gp_widget_label_width_set (gp_widget *self, unsigned int width) |
Changes widget minimal width. | |
unsigned int | gp_widget_label_width_get (gp_widget *self) |
Returns widget minimal width. | |
void | gp_widget_label_flags_set (gp_widget *self, enum gp_widget_label_flags flags) |
Sets frame flags. | |
enum gp_widget_label_flags | gp_widget_label_flags_get (gp_widget *self) |
Gets frame flags. | |
gp_widget * | gp_widget_label_new (const char *text, gp_widget_tattr tattr, unsigned int width) |
Allocates a label widget. | |
gp_widget * | gp_widget_label_printf_new (gp_widget_tattr tattr, const char *fmt,...) __attribute__((format(printf |
Printf-like function to create a label widget. | |
A label widget.
A label widget is a single line of a text.
Unless widget 'size' is set the widget grows its size to fit the content without any limitations, which is only useful for cases where the label text is under your control and all possible values are known in advance.
If you have a label whose text is outside of your control, e.g. the value is a result of some system call, RPC call, etc, it's important to set the label size so that the label will not grow undefinitelly. The most useful combination is to set both label 'size' along with 'hfill' alignment in which case the label will fill all available horizontal space and the 'size' will function as a minimal widget size. The text inside of the label widget can be aligned with gp_widget_tattr text attributes.
Attribute | Type | Default | Description |
---|---|---|---|
text | string | A label text. | |
tattr | string | normal | Text attributes gp_widget_tattr, e.g. bold. |
width | uint | 0 | Label text size in characters. |
frame | bool | false | Draw frame around label, implies min padd = 1 |
padd | uint | 0 | Padd inside label on left and right. |
bg_color | string | "bg" | Background gp_widgets_color. |
text_color | string | "text" | Text gp_widgets_color. |
reverse_colors | bool | false | Reverse background and text color. |
Definition in file gp_widget_label.h.
A label flags.
Enumerator | |
---|---|
GP_WIDGET_LABEL_FRAME | Draws a frame around the label. |
Definition at line 53 of file gp_widget_label.h.
void gp_widget_labe_fmt_set | ( | gp_widget * | self, |
const char * | text_fmt | ||
) |
Sets the label text format.
The text format may include a variable that can be then set.
self | A label widget. |
text_fmt | A text format. |
void gp_widget_label_append | ( | gp_widget * | self, |
const char * | text | ||
) |
Appends text to the label.
self | A label widget. |
text | Text to be appended. |
enum gp_widget_label_flags gp_widget_label_flags_get | ( | gp_widget * | self | ) |
Gets frame flags.
self | A label widget. |
void gp_widget_label_flags_set | ( | gp_widget * | self, |
enum gp_widget_label_flags | flags | ||
) |
Sets frame flags.
self | A label widget. |
flags | A new label flags. |
void gp_widget_label_fmt_var_set | ( | gp_widget * | self, |
const char * | fmt, | ||
... | |||
) |
Sets label accordingly to text format string.
self | A label widget. |
fmt | Printf-like format |
... | Printf-like parameters. |
const char * gp_widget_label_get | ( | gp_widget * | self | ) |
Gets the label text.
self | A label widget. |
gp_widget * gp_widget_label_new | ( | const char * | text, |
gp_widget_tattr | tattr, | ||
unsigned int | width | ||
) |
Allocates a label widget.
Label minimal width is a bit more complicated topic since labels can change content and hence size dynamically. There are two different modes of operation.
text | A label text. |
tattr | Text attributes, e.g. bold. |
width | Maximal expected text width, if set to non-zero it's used to callculate the label size. |
int gp_widget_label_printf | ( | gp_widget * | self, |
const char * | fmt, | ||
... | |||
) |
Printf-like function to set label text.
self | A label widget. |
fmt | Printf formatting string. |
... | Printf parameters. |
gp_widget * gp_widget_label_printf_new | ( | gp_widget_tattr | tattr, |
const char * | fmt, | ||
... | |||
) |
Printf-like function to create a label widget.
tattr | Text attributes, e.g. bold. |
fmt | Printf formatting string. |
... | Printf parameters. |
void gp_widget_label_set | ( | gp_widget * | self, |
const char * | text | ||
) |
Sets the label text.
self | A label widget. |
text | New widget label text. |
gp_widget_tattr gp_widget_label_tattr_get | ( | gp_widget * | self | ) |
Gets text attributes.
self | A label widget. |
void gp_widget_label_tattr_set | ( | gp_widget * | self, |
gp_widget_tattr | tattr | ||
) |
Changes text attributes.
self | A label widget. |
tattr | New text attributes. |
int void gp_widget_label_vprintf | ( | gp_widget * | self, |
const char * | fmt, | ||
va_list | ap | ||
) |
VPrintf-like function to set label text.
self | A label widget. |
fmt | Printf formatting string. |
ap | Printf parameters. |
unsigned int gp_widget_label_width_get | ( | gp_widget * | self | ) |
Returns widget minimal width.
self | Pointer to a label widget. |
void gp_widget_label_width_set | ( | gp_widget * | self, |
unsigned int | width | ||
) |
Changes widget minimal width.
self | Pointer to a label widget. |
width | New label width, the unit for the width is font average characters. |