GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_widget_tattr.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
19#ifndef GP_WIDGET_TATTR_H
20#define GP_WIDGET_TATTR_H
21
22#include <text/gp_text.h>
25
46
55{
56 if (attr & GP_TATTR_MONO) {
57 if (attr & GP_TATTR_BOLD)
58 return ctx->font_mono_bold;
59 else
60 return ctx->font_mono;
61 }
62
63 if (attr & GP_TATTR_BOLD) {
64 if (attr & GP_TATTR_LARGE)
65 return ctx->font_big_bold;
66 else
67 return ctx->font_bold;
68 }
69
70 if (attr & GP_TATTR_LARGE)
71 return ctx->font_big;
72
73 return ctx->font;
74}
75
83{
84 return attr & GP_TATTR_HALIGN;
85}
86
98int gp_widget_tattr_parse(const char *attrs, gp_widget_tattr *tattr, int flags);
99
100#endif /* GP_WIDGET_TATTR_H */
A text drawing functions.
Widget rendering.
static int gp_widget_tattr_halign(gp_widget_tattr attr)
Returns the alignment part of the text attributes.
static const gp_text_style * gp_widget_tattr_font(gp_widget_tattr attr, const gp_widget_render_ctx *ctx)
Returns text font based on text attributes and render context.
gp_widget_tattr
Text attribute flags.
@ GP_TATTR_CENTER
Center horizontal alignment.
@ GP_TATTR_HALIGN
Alignment attribute mask.
@ GP_TATTR_FONT
Font attribute mask.
@ GP_TATTR_MONO
Monospace font, can't be combined with large.
@ GP_TATTR_BOLD
Bold font.
@ GP_TATTR_RIGHT
Right horizontal alignment.
@ GP_TATTR_LEFT
Left horizontal alignment.
@ GP_TATTR_LARGE
Large font.
int gp_widget_tattr_parse(const char *attrs, gp_widget_tattr *tattr, int flags)
Parses text attributes encoded in a string into attribute bitflags.
Common widget types.
A text style.
Global widget (rendering) context.
gp_text_style * font_bold
Default bold font.
gp_text_style * font
Default font.
gp_text_style * font_mono_bold
Default monospace bold font.
gp_text_style * font_big
Default big font.
gp_text_style * font_big_bold
Default big bold font.
gp_text_style * font_mono
Default monospace font.