GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_widget_label.h
Go to the documentation of this file.
1//SPDX-License-Identifier: LGPL-2.0-or-later
2/*
3
4 Copyright (c) 2014-2020 Cyril Hrubis <metan@ucw.cz>
5
6 */
7
15#ifndef GP_WIDGET_LABEL_H
16#define GP_WIDGET_LABEL_H
17
18#include <stdlib.h>
19#include <core/gp_compiler.h>
20
21struct gp_widget_label {
22 /* Text buffer */
23 char *text;
24 /* Text format */
25 char *text_fmt;
26 /* widget size hints */
27 const char *set;
28 uint8_t width;
29 /* attributes */
30 uint8_t padd;
31 uint16_t frame:1;
32 /* colors */
33 uint8_t text_color;
34 uint8_t bg_color;
35 /* text attributes */
36 gp_widget_tattr tattr;
37};
38
45void gp_widget_label_set(gp_widget *self, const char *text);
46
55void gp_widget_labe_fmt_set(gp_widget *self, const char *text_fmt);
56
64void gp_widget_label_fmt_var_set(gp_widget *self, const char *fmt, ...)
65 GP_FMT_PRINTF(2, 3);
66
73void gp_widget_label_append(gp_widget *self, const char *text);
74
83int gp_widget_label_printf(gp_widget *self, const char *fmt, ...)
84 __attribute__((format (printf, 2, 3)));
85
93void gp_widget_label_vprintf(gp_widget *self, const char *fmt, va_list ap);
94
101static inline void gp_widget_label_tattr_set(gp_widget *self, gp_widget_tattr tattr)
102{
103 GP_WIDGET_ASSERT(self, GP_WIDGET_LABEL, );
104
105 self->label->tattr = tattr;
106
107 gp_widget_redraw(self);
108}
109
116static inline void gp_widget_label_width_set(gp_widget *self, unsigned int width)
117{
118 self->label->width = width;
119 gp_widget_resize(self);
120}
121
148gp_widget *gp_widget_label_new(const char *text, gp_widget_tattr tattr, unsigned int width);
149
158gp_widget *gp_widget_label_printf_new(gp_widget_tattr tattr, const char *fmt, ...)
159 __attribute__((format (printf, 2, 3)));
160
161#endif /* GP_WIDGET_LABEL_H */
A compiler dependent macros.
#define GP_FMT_PRINTF(fmt, list)
Expands to format printf attribute when supported by the compiler.
Definition gp_compiler.h:30
static void gp_widget_label_width_set(gp_widget *self, unsigned int width)
Changes widget minimal width.
void gp_widget_label_fmt_var_set(gp_widget *self, const char *fmt,...)
Sets label accordingly to text format string.
int void gp_widget_label_vprintf(gp_widget *self, const char *fmt, va_list ap)
VPrintf-like function to set label text.
gp_widget * gp_widget_label_new(const char *text, gp_widget_tattr tattr, unsigned int width)
Allocates a label widget.
void gp_widget_labe_fmt_set(gp_widget *self, const char *text_fmt)
Sets the label text format.
void gp_widget_label_set(gp_widget *self, const char *text)
Sets the label text.
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.
int gp_widget_label_printf(gp_widget *self, const char *fmt,...) __attribute__((format(printf
Printf-like function to set label text.
void gp_widget_label_append(gp_widget *self, const char *text)
Appends text to the label.
static void gp_widget_label_tattr_set(gp_widget *self, gp_widget_tattr tattr)
Changes text attributes.