GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
include
widgets
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
>
23
#include <
widgets/gp_widget_types.h
>
24
#include <
widgets/gp_widget_render.h
>
25
27
enum
gp_widget_tattr
{
29
GP_TATTR_BOLD
= 0x10,
31
GP_TATTR_LARGE
= 0x20,
33
GP_TATTR_MONO
= 0x40,
35
GP_TATTR_FONT
= 0x70,
36
38
GP_TATTR_LEFT
= 0x01,
40
GP_TATTR_CENTER
= 0x02,
42
GP_TATTR_RIGHT
= 0x03,
44
GP_TATTR_HALIGN
= 0x03,
45
};
46
54
static
inline
const
gp_text_style
*
gp_widget_tattr_font
(
gp_widget_tattr
attr,
const
gp_widget_render_ctx
*ctx)
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
82
static
inline
int
gp_widget_tattr_halign
(
gp_widget_tattr
attr)
83
{
84
return
attr &
GP_TATTR_HALIGN
;
85
}
86
98
int
gp_widget_tattr_parse
(
const
char
*attrs,
gp_widget_tattr
*tattr,
int
flags);
99
100
#endif
/* GP_WIDGET_TATTR_H */
gp_text.h
A text drawing functions.
gp_widget_render.h
Widget rendering.
gp_widget_tattr_halign
static int gp_widget_tattr_halign(gp_widget_tattr attr)
Returns the alignment part of the text attributes.
Definition
gp_widget_tattr.h:82
gp_widget_tattr_font
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.
Definition
gp_widget_tattr.h:54
gp_widget_tattr
gp_widget_tattr
Text attribute flags.
Definition
gp_widget_tattr.h:27
GP_TATTR_CENTER
@ GP_TATTR_CENTER
Center horizontal alignment.
Definition
gp_widget_tattr.h:40
GP_TATTR_HALIGN
@ GP_TATTR_HALIGN
Alignment attribute mask.
Definition
gp_widget_tattr.h:44
GP_TATTR_FONT
@ GP_TATTR_FONT
Font attribute mask.
Definition
gp_widget_tattr.h:35
GP_TATTR_MONO
@ GP_TATTR_MONO
Monospace font, can't be combined with large.
Definition
gp_widget_tattr.h:33
GP_TATTR_BOLD
@ GP_TATTR_BOLD
Bold font.
Definition
gp_widget_tattr.h:29
GP_TATTR_RIGHT
@ GP_TATTR_RIGHT
Right horizontal alignment.
Definition
gp_widget_tattr.h:42
GP_TATTR_LEFT
@ GP_TATTR_LEFT
Left horizontal alignment.
Definition
gp_widget_tattr.h:38
GP_TATTR_LARGE
@ GP_TATTR_LARGE
Large font.
Definition
gp_widget_tattr.h:31
gp_widget_tattr_parse
int gp_widget_tattr_parse(const char *attrs, gp_widget_tattr *tattr, int flags)
Parses text attributes encoded in a string into attribute bitflags.
gp_widget_types.h
Common widget types.
gp_text_style
A text style.
Definition
gp_text_style.h:39
gp_widget_render_ctx
Global widget (rendering) context.
Definition
gp_widget_render.h:29
gp_widget_render_ctx::font_bold
gp_text_style * font_bold
Default bold font.
Definition
gp_widget_render.h:89
gp_widget_render_ctx::font
gp_text_style * font
Default font.
Definition
gp_widget_render.h:87
gp_widget_render_ctx::font_mono_bold
gp_text_style * font_mono_bold
Default monospace bold font.
Definition
gp_widget_render.h:97
gp_widget_render_ctx::font_big
gp_text_style * font_big
Default big font.
Definition
gp_widget_render.h:91
gp_widget_render_ctx::font_big_bold
gp_text_style * font_big_bold
Default big bold font.
Definition
gp_widget_render.h:93
gp_widget_render_ctx::font_mono
gp_text_style * font_mono
Default monospace font.
Definition
gp_widget_render.h:95
Generated by
1.9.8