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-2024 Cyril Hrubis <metan@ucw.cz>
5
6 */
7
46#ifndef GP_WIDGET_LABEL_H
47#define GP_WIDGET_LABEL_H
48
49#include <stdlib.h>
50#include <core/gp_compiler.h>
51
52struct gp_widget_label {
53 /* Text buffer */
54 char *text;
55 /* Text format */
56 char *text_fmt;
57 /* widget size hints */
58 const char *set;
59 uint8_t width;
60 /* attributes */
61 uint8_t padd;
62 uint16_t frame:1;
63 /* colors */
64 uint8_t text_color;
65 uint8_t bg_color;
66 /* text attributes */
67 gp_widget_tattr tattr;
68};
69
76void gp_widget_label_set(gp_widget *self, const char *text);
77
84const char *gp_widget_label_get(gp_widget *self);
85
94void gp_widget_labe_fmt_set(gp_widget *self, const char *text_fmt);
95
103void gp_widget_label_fmt_var_set(gp_widget *self, const char *fmt, ...)
104 GP_FMT_PRINTF(2, 3);
105
112void gp_widget_label_append(gp_widget *self, const char *text);
113
122int gp_widget_label_printf(gp_widget *self, const char *fmt, ...)
123 __attribute__((format (printf, 2, 3)));
124
132void gp_widget_label_vprintf(gp_widget *self, const char *fmt, va_list ap);
133
141{
143
144 self->label->tattr = tattr;
145
146 gp_widget_redraw(self);
147}
148
155static inline void gp_widget_label_width_set(gp_widget *self, unsigned int width)
156{
157 self->label->width = width;
158 gp_widget_resize(self);
159}
160
187gp_widget *gp_widget_label_new(const char *text, gp_widget_tattr tattr, unsigned int width);
188
198 __attribute__((format (printf, 2, 3)));
199
200#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:31
#define GP_WIDGET_TYPE_ASSERT(self, wtype, ret)
Asserts a widget type.
Definition gp_widget.h:449
@ GP_WIDGET_LABEL
A label widget.
Definition gp_widget.h:207
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.
const char * gp_widget_label_get(gp_widget *self)
Gets the label text.
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.
void gp_widget_redraw(gp_widget *self)
Requests widget repaint.
void gp_widget_resize(gp_widget *self)
Requests widget resize.
gp_widget_tattr
Text attribute flags.
A widget base.
Definition gp_widget.h:28