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.";
50 if(weight ==
"thin") {
51 return PANGO_WEIGHT_THIN;
52 }
else if (weight ==
"light") {
53 return PANGO_WEIGHT_LIGHT;
54 }
else if (weight ==
"semibold") {
55 return PANGO_WEIGHT_SEMIBOLD;
56 }
else if (weight ==
"bold") {
57 return PANGO_WEIGHT_BOLD;
58 }
else if (weight ==
"heavy") {
59 return PANGO_WEIGHT_HEAVY;
62 if(!weight.empty() && weight !=
"normal") {
63 ERR_GUI_E <<
"Invalid text weight '" << weight <<
"', falling back to 'normal'.";
66 return PANGO_WEIGHT_NORMAL;
71 if(style ==
"italic") {
72 return PANGO_STYLE_ITALIC;
73 }
else if(style ==
"oblique") {
74 return PANGO_STYLE_OBLIQUE;
77 if(!style.empty() && style !=
"normal") {
78 ERR_GUI_E <<
"Invalid text style '" << style <<
"', falling back to 'normal'.";
81 return PANGO_STYLE_NORMAL;
86 if(alignment ==
"center") {
87 return PANGO_ALIGN_CENTER;
88 }
else if(alignment ==
"right") {
89 return PANGO_ALIGN_RIGHT;
92 if(!alignment.empty() && alignment !=
"left") {
93 ERR_GUI_E <<
"Invalid text alignment '" << alignment <<
"', falling back to 'left'.";
96 return PANGO_ALIGN_LEFT;
101 if(ellipsize_mode ==
"start") {
102 return PANGO_ELLIPSIZE_START;
103 }
else if(ellipsize_mode ==
"middle") {
104 return PANGO_ELLIPSIZE_MIDDLE;
105 }
else if(ellipsize_mode ==
"end") {
106 return PANGO_ELLIPSIZE_END;
109 if(!ellipsize_mode.empty() && ellipsize_mode !=
"none") {
110 ERR_GUI_E <<
"Invalid text ellipsization mode '" << ellipsize_mode <<
"', falling back to 'none'.";
113 return PANGO_ELLIPSIZE_NONE;
118 switch(ellipsize_mode) {
119 case PANGO_ELLIPSIZE_START:
121 case PANGO_ELLIPSIZE_MIDDLE:
123 case PANGO_ELLIPSIZE_END:
133 case PANGO_ALIGN_LEFT:
135 case PANGO_ALIGN_RIGHT:
137 case PANGO_ALIGN_CENTER:
143 throw "Control should not reach this point.";
148 return t_string(
VGETTEXT(
"Mandatory widget ‘$id’ hasn't been defined.", {{
"id",
id}}));
175 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.
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.