16 #define GETTEXT_DOMAIN "wesnoth-lib"
35 }
else if(style ==
"italic") {
37 }
else if(style ==
"underline") {
41 if(!style.empty() && style !=
"normal") {
42 ERR_GUI_G <<
"Unknown style '" << style <<
"', using 'normal' instead.";
55 if(weight ==
"thin") {
56 return PANGO_WEIGHT_THIN;
57 }
else if (weight ==
"light") {
58 return PANGO_WEIGHT_LIGHT;
59 }
else if (weight ==
"semibold") {
60 return PANGO_WEIGHT_SEMIBOLD;
61 }
else if (weight ==
"bold") {
62 return PANGO_WEIGHT_BOLD;
63 }
else if (weight ==
"heavy") {
64 return PANGO_WEIGHT_HEAVY;
67 if(!weight.empty() && weight !=
"normal") {
68 ERR_GUI_E <<
"Invalid text weight '" << weight <<
"', falling back to 'normal'.";
71 return PANGO_WEIGHT_NORMAL;
76 if(style ==
"italic") {
77 return PANGO_STYLE_ITALIC;
78 }
else if(style ==
"oblique") {
79 return PANGO_STYLE_OBLIQUE;
82 if(!style.empty() && style !=
"normal") {
83 ERR_GUI_E <<
"Invalid text style '" << style <<
"', falling back to 'normal'.";
86 return PANGO_STYLE_NORMAL;
91 if(alignment ==
"center") {
92 return PANGO_ALIGN_CENTER;
93 }
else if(alignment ==
"right") {
94 return PANGO_ALIGN_RIGHT;
97 if(!alignment.empty() && alignment !=
"left") {
98 ERR_GUI_E <<
"Invalid text alignment '" << alignment <<
"', falling back to 'left'.";
101 return PANGO_ALIGN_LEFT;
106 if(ellipsize_mode ==
"start") {
107 return PANGO_ELLIPSIZE_START;
108 }
else if(ellipsize_mode ==
"middle") {
109 return PANGO_ELLIPSIZE_MIDDLE;
110 }
else if(ellipsize_mode ==
"end") {
111 return PANGO_ELLIPSIZE_END;
114 if(!ellipsize_mode.empty() && ellipsize_mode !=
"none") {
115 ERR_GUI_E <<
"Invalid text ellipsization mode '" << ellipsize_mode <<
"', falling back to 'none'.";
118 return PANGO_ELLIPSIZE_NONE;
123 switch(ellipsize_mode) {
124 case PANGO_ELLIPSIZE_START:
126 case PANGO_ELLIPSIZE_MIDDLE:
128 case PANGO_ELLIPSIZE_END:
138 case PANGO_ALIGN_LEFT:
140 case PANGO_ALIGN_RIGHT:
142 case PANGO_ALIGN_CENTER:
148 throw "Control should not reach this point.";
153 return t_string(
VGETTEXT(
"Mandatory widget ‘$id’ hasn't been defined.", {{
"id",
id}}));
180 return text.substr(0, 15);
Define the common log macros for the gui toolkit.
unsigned screen_width
The screen resolution and pixel pitch should be available for all widgets since their drawing method ...
unsigned gamemap_x_offset
The offset between the left edge of the screen and the gamemap.
unsigned gamemap_width
The size of the map area, if not available equal to the screen size.
void get_screen_size_variables(wfl::map_formula_callable &variable)
Gets a formula object with the screen size.
color_t decode_color(const std::string &color)
Converts a color string to a color.
t_string missing_widget(const std::string &id)
Returns a default error message if a mandatory widget is omitted.
std::string encode_ellipsize_mode(const PangoEllipsizeMode ellipsize_mode)
Converts a PangoEllipsizeMode to its string representation.
point get_mouse_position()
Returns the current mouse position.
std::string_view debug_truncate(std::string_view text)
Returns a truncated version of the text.
PangoWeight decode_text_weight(const std::string &weight)
Converts a text weight string to a PangoWeight.
font::pango_text::FONT_STYLE decode_font_style(const std::string &style)
Converts a font style string to a font style.
PangoAlignment decode_text_alignment(const std::string &alignment)
Converts a text alignment string to a text alignment.
PangoStyle decode_text_style(const std::string &style)
Converts a text style string to a PangoStyle.
std::string encode_text_alignment(const PangoAlignment alignment)
Converts a PangoAlignment to its string representation.
PangoEllipsizeMode decode_ellipsize_mode(const std::string &ellipsize_mode)
Converts a text ellipsize mode string to a PangoEllipsizeMode.
point get_mouse_location()
Returns the current mouse location in draw space.
This file contains the settings handling of the widget library.
The basic class for representing 8-bit RGB or RGBA colour values.
static color_t from_rgba_string(std::string_view c)
Creates a new color_t object from a string variable in "R,G,B,A" format.