A label widget.
More...
#include <stdlib.h>
#include <core/gp_compiler.h>
Go to the source code of this file.
|
void | gp_widget_label_set (gp_widget *self, const char *text) |
| Sets 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.
|
|
static void | gp_widget_label_tattr_set (gp_widget *self, gp_widget_tattr tattr) |
| Changes text attributes.
|
|
static void | gp_widget_label_width_set (gp_widget *self, unsigned int width) |
| Changes widget minimal width.
|
|
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.
Definition in file gp_widget_label.h.
◆ gp_widget_labe_fmt_set()
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.
- Parameters
-
self | A label widget. |
text_fmt | A text format. |
◆ gp_widget_label_append()
void gp_widget_label_append |
( |
gp_widget * |
self, |
|
|
const char * |
text |
|
) |
| |
Appends text to the label.
- Parameters
-
self | A label widget. |
text | Text to be appended. |
◆ gp_widget_label_fmt_var_set()
void gp_widget_label_fmt_var_set |
( |
gp_widget * |
self, |
|
|
const char * |
fmt, |
|
|
|
... |
|
) |
| |
Sets label accordingly to text format string.
- Parameters
-
self | A label widget. |
fmt | Printf-like format |
... | Printf-like parameters. |
◆ gp_widget_label_new()
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.
- If width is set, the size is set to stone so that the label can hold width characters. The main problem is that for proprotional fonts the allocated space is huge because we account for maximal character width. To accomodate for that you can also pass a string with subset of characters that are expected to appear in the label to make that computation more precise.
- If width is not set, i.e. set to zero, the size is computed accordintly to the current label text, however by default the widget does not shrink, e.g. if the new string width is shorter than the last one we do not trigger resize, which avoids for the layout to size to jump on label text changes. You can manually trigger shrinking by calling gp_widget_resize().
- Parameters
-
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. |
- Returns
- Newly allocated label widget.
◆ gp_widget_label_printf()
int gp_widget_label_printf |
( |
gp_widget * |
self, |
|
|
const char * |
fmt, |
|
|
|
... |
|
) |
| |
Printf-like function to set label text.
- Parameters
-
self | A label widget. |
fmt | Printf formatting string. |
... | Printf parameters. |
- Returns
- Number of characters printed.
◆ gp_widget_label_printf_new()
gp_widget * gp_widget_label_printf_new |
( |
gp_widget_tattr |
tattr, |
|
|
const char * |
fmt, |
|
|
|
... |
|
) |
| |
Printf-like function to create a label widget.
- Parameters
-
tattr | Text attributes, e.g. bold. |
fmt | Printf formatting string. |
... | Printf parameters. |
- Returns
- Newly allocated label widget.
◆ gp_widget_label_set()
void gp_widget_label_set |
( |
gp_widget * |
self, |
|
|
const char * |
text |
|
) |
| |
Sets the label text.
- Parameters
-
self | A label widget. |
text | New widget label text. |
◆ gp_widget_label_tattr_set()
static void gp_widget_label_tattr_set |
( |
gp_widget * |
self, |
|
|
gp_widget_tattr |
tattr |
|
) |
| |
|
inlinestatic |
Changes text attributes.
- Parameters
-
self | A label widget. |
tattr | New text attributes. |
Definition at line 101 of file gp_widget_label.h.
◆ gp_widget_label_vprintf()
int void gp_widget_label_vprintf |
( |
gp_widget * |
self, |
|
|
const char * |
fmt, |
|
|
va_list |
ap |
|
) |
| |
VPrintf-like function to set label text.
- Parameters
-
self | A label widget. |
fmt | Printf formatting string. |
ap | Printf parameters. |
◆ gp_widget_label_width_set()
static void gp_widget_label_width_set |
( |
gp_widget * |
self, |
|
|
unsigned int |
width |
|
) |
| |
|
inlinestatic |
Changes widget minimal width.
- Parameters
-
self | Pointer to a label widget. |
width | New label width, the unit for the width is font characters. |
Definition at line 116 of file gp_widget_label.h.