16 #define GETTEXT_DOMAIN "wesnoth-lib"
37 #define LOG_SCOPE_HEADER \
38 "styled_widget(" + get_control_type() + ") [" + id() + "] " + __func__
39 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
47 const std::string& control_type)
49 , definition_(builder.definition)
50 , label_(builder.label_string)
51 , use_markup_(builder.use_markup)
52 , use_tooltip_on_label_overflow_(builder.use_tooltip_on_label_overflow)
54 , help_message_(builder.
help)
56 , canvases_(config_->state.
size())
58 , text_maximum_width_(0)
59 , text_alignment_(PANGO_ALIGN_LEFT)
60 , text_ellipse_mode_(PANGO_ELLIPSIZE_END)
69 for(
unsigned i = 0;
i <
config_->state.size(); ++
i) {
79 connect_signal<event::SHOW_TOOLTIP>(std::bind(
82 connect_signal<event::SHOW_HELPTIP>(std::bind(
85 connect_signal<event::NOTIFY_REMOVE_TOOLTIP>(std::bind(
93 widget_item::const_iterator itor =
data.find(
"id");
94 if(itor !=
data.end()) {
98 itor =
data.find(
"linked_group");
99 if(itor !=
data.end()) {
103 itor =
data.find(
"label");
104 if(itor !=
data.end()) {
108 itor =
data.find(
"tooltip");
109 if(itor !=
data.end()) {
113 itor =
data.find(
"help");
114 if(itor !=
data.end()) {
118 itor =
data.find(
"use_markup");
119 if(itor !=
data.end()) {
123 itor =
data.find(
"text_alignment");
124 if(itor !=
data.end()) {
136 return std::make_unique<iteration::walker::widget>(*
this);
189 if(full_initialization) {
209 <<
"' maximum_width " << maximum_width <<
" result " <<
size
219 <<
" maximum_width " << maximum_width <<
" result " <<
size
223 <<
"' failed; either no label or wrapping not allowed.";
238 <<
" maximum_height " << maximum_height <<
" result " <<
size
260 <<
"' result " << result <<
".";
296 const bool must_be_active)
const
389 std::vector<wfl::variant> link_color_as_list {
480 <<
" Limited the number of characters per line, "
481 <<
"but wrapping is not set, output may not be as expected.";
488 <<
"minimum_size: " << minimum_size <<
"\n"
489 <<
"maximum_size: " << maximum_size <<
"\n"
491 <<
"can_wrap: " <<
can_wrap() <<
"\n"
513 if(
size.x < minimum_size.x) {
514 size.x = minimum_size.x;
517 if(
size.y < minimum_size.y) {
518 size.y = minimum_size.y;
522 <<
"' result " <<
size <<
".";
528 const point& location)
551 const point& location)
593 , definition(cfg[
"definition"])
594 , label_string(cfg[
"label"].t_str())
595 ,
tooltip(cfg[
"tooltip"].t_str())
596 ,
help(cfg[
"help"].t_str())
597 , use_tooltip_on_label_overflow(true)
598 , use_markup(cfg[
"use_markup"].to_bool(false))
606 _(
"Found a widget with a helptip and without a tooltip."),
608 <<
"' helptip '" <<
help <<
"'.");
611 DBG_GUI_P <<
"Window builder: found styled_widget with id '" <<
id
612 <<
"' and definition '" <<
definition <<
"'.";
A config object defines a single node in a WML file, with access to child nodes.
pango_text & set_font_style(const FONT_STYLE font_style)
point get_size()
Returns the size of the text, in drawing coordinates.
pango_text & set_characters_per_line(const unsigned characters_per_line)
pango_text & set_family_class(font::family_class fclass)
pango_text & set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
pango_text & set_alignment(const PangoAlignment alignment)
pango_text & set_font_size(unsigned font_size)
pango_text & set_link_aware(bool b)
std::string get_token(const point &position, const char *delimiters=" \n\r\t") const
Gets the largest collection of characters, including the token at position, and not including any cha...
bool set_text(const std::string &text, const bool markedup)
Sets the text to render.
bool is_truncated() const
Has the text been truncated? This happens if it exceeds max width or height.
pango_text & set_maximum_width(int width)
pango_text & set_link_color(const color_t &color)
std::string get_link(const point &position) const
Checks if position points to a character in a link in the text, returns it if so, empty string otherw...
A simple canvas which can be drawn upon.
void set_variable(const std::string &key, wfl::variant &&value)
void draw()
Draw the canvas' shapes onto the screen.
void set_size(const point &size)
Main class to show messages to the user.
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
void set_wants_mouse_hover(const bool hover=true)
const std::string & str() const
This file contains the definitions for the gui2::event::message class.
@ border
The border of the map.
static std::string _(const char *str)
Define the common log macros for the gui toolkit.
std::string label
What to show in the filter's drop-down list.
#define log_scope2(domain, description)
void point(int x, int y)
Draw a single point.
void remove()
Removes a tip.
static std::unique_ptr< tooltip > tip
ui_event
The event sent to the dispatcher.
std::unique_ptr< class walker_base > walker_ptr
t_string has_helptip_message
void get_screen_size_variables(wfl::map_formula_callable &variable)
Gets a formula object with the screen size.
std::string_view debug_truncate(std::string_view text)
Returns a truncated version of the text.
std::map< std::string, t_string > widget_item
PangoAlignment decode_text_alignment(const std::string &alignment)
Converts a text alignment string to a text alignment.
lg::log_domain log_gui_layout("gui/layout")
resolution_definition_ptr get_control(const std::string &control_type, const std::string &definition)
Returns the appropriate config data for a widget instance fom the active GUI definition.
std::string encode_text_alignment(const PangoAlignment alignment)
Converts a text alignment to its string representation.
std::string get_names(const std::string &id)
Returns a comma-separated string of hotkey names.
Contains the implementation details for lexical_cast and shouldn't be used directly.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
std::string interpolate_variables_into_string(const std::string &str, const string_map *const symbols)
Function which will interpolate variables, starting with '$' in the string 'str' with the equivalent ...
bool string_bool(const std::string &str, bool def)
Convert no, false, off, 0, 0.0 to false, empty to def, and others to true.
std::map< std::string, t_string > string_map
Contains the SDL_Rect helper code.
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_hex_string(std::string_view c)
Creates a new color_t object from a string variable in hex format.
The message for MESSAGE_SHOW_HELPTIP.
static const hotkey_command & get_command_by_command(HOTKEY_COMMAND command)
the execute_command argument was changed from HOTKEY_COMMAND to hotkey_command, to be able to call it...
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
#define VALIDATE_WITH_DEV_MESSAGE(cond, message, dev_message)