15 #define GETTEXT_DOMAIN "wesnoth-lib"
53 static std::map<std::string, std::function<tbuilder_widget_ptr(config)> >&
56 static std::map<std::string, std::function<tbuilder_widget_ptr(config)> >
100 symbols[
"id"] =
lg.id;
102 "Linked '$id' group has multiple definitions.", symbols);
131 std::vector<twindow_builder::tresolution>::const_iterator definition
140 , linked_group(cfg[
"linked_group"])
142 , debug_border_mode(cfg[
"debug_border_mode"])
143 , debug_border_color(
decode_color(cfg[
"debug_border_color"]))
158 size_t nb_children = std::distance(children.first, children.second);
159 VALIDATE(nb_children == 1,
"Grid cell does not have exactly 1 child.");
163 if(item.first ==
"window" || item.first ==
"tooltip") {
167 return item.second(
c);
175 if(
const config& instance = cfg.
child(
"instance")) {
183 if(
const config& viewport = cfg.
child(
"viewport")) {
206 if(const config& c = cfg.child(#name)) { \
207 tbuilder_widget_ptr p = new implementation::tbuilder_##name(c); \
213 TRY(scrollbar_panel);
214 TRY(horizontal_scrollbar);
215 TRY(repeating_button);
216 TRY(vertical_scrollbar);
228 TRY(unit_preview_pane);
260 id_ = cfg[
"id"].str();
267 DBG_GUI_P <<
"Window builder: reading data for window " <<
id_ <<
".\n";
270 VALIDATE(cfgs.first != cfgs.second,
_(
"No resolution defined."));
271 for(
const auto &
i : cfgs)
384 : window_width(cfg[
"window_width"])
385 , window_height(cfg[
"window_height"])
386 , automatic_placement(cfg[
"automatic_placement"].to_bool(true))
389 ,
width(cfg[
"width"])
391 , reevaluate_best_size(cfg[
"reevaluate_best_size"])
394 , horizontal_placement(
396 , maximum_width(cfg[
"maximum_width"])
397 , maximum_height(cfg[
"maximum_height"])
398 , click_dismiss(cfg[
"click_dismiss"].to_bool())
399 , definition(cfg[
"definition"])
401 , tooltip(cfg.child_or_empty(
"tooltip"),
"tooltip")
402 , helptip(cfg.child_or_empty(
"helptip"),
"helptip")
405 if(!cfg[
"functions"].empty()) {
432 linked_group.
id =
lg[
"id"].str();
441 symbols[
"id"] = linked_group.
id;
443 =
vgettext(
"Linked '$id' group needs a 'fixed_width' or "
444 "'fixed_height' key.",
540 for(
const auto &
c :
row.child_range(
"column"))
557 VALIDATE(col,
_(
"A row must have a column."));
574 build(*result, replacements);
586 DBG_GUI_G <<
"Window builder: grid '" <<
id <<
"' has " <<
rows
587 <<
" rows and " <<
cols <<
" columns.\n";
589 for(
unsigned x = 0;
x <
rows; ++
x) {
591 for(
unsigned y = 0;
y <
cols; ++
y) {
597 DBG_GUI_G <<
"Window builder: adding child at " << x <<
',' <<
y
620 DBG_GUI_G <<
"Window builder: grid '" <<
id <<
"' has " <<
rows
621 <<
" rows and " <<
cols <<
" columns.\n";
623 for(
unsigned x = 0;
x <
rows; ++
x) {
625 for(
unsigned y = 0;
y <
cols; ++
y) {
631 DBG_GUI_G <<
"Window builder: adding child at " << x <<
',' <<
y
Define the common log macros for the gui toolkit.
child_itors child_range(const std::string &key)
std::vector< unsigned > col_grow_factor
void set_row_grow_factor(const unsigned row, const unsigned factor)
Sets the grow factor for a row.
unsigned read_flags(const config &cfg)
Returns the placement/resize flags.
tformula< unsigned > height
twindow * build(CVideo &video, const twindow_builder::tresolution *definition)
Builds a window.
tformula< unsigned > width
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
GLuint GLuint GLsizei GLenum type
itor second functor(surf, f[1])
tresolution_definition_ptr config()
void add_to_keyboard_chain(twidget *widget)
Adds the widget to the keyboard chain.
std::vector< tbuilder_widget_ptr > widgets
The widgets per grid cell.
GLint GLint GLint GLint GLint GLint y
tresolution(const config &cfg)
std::pair< const_child_iterator, const_child_iterator > const_child_itors
std::vector< unsigned > row_grow_factor
The grow factor for the rows / columns.
std::string missing_mandatory_wml_key(const std::string §ion, const std::string &key, const std::string &primary_key, const std::string &primary_value)
Returns a standard message for a missing wml key.
base class of top level items, the only item which needs to store the final canvases to draw on ...
A class inherited from ttext_box that displays its input as stars.
const std::string & read(const config &cfg)
static std::map< std::string, std::function< tbuilder_widget_ptr(config)> > & builder_widget_lookup()
void finalize(const boost::intrusive_ptr< tbuilder_grid > &content_grid)
Finishes the initialization of the grid.
static UNUSEDNOWARN std::string _(const char *str)
std::map< std::string, t_string > string_map
lg::log_domain log_gui_parse("gui/parse")
#define VALIDATE(cond, message)
The macro to use for the validation of WML.
void set_column_grow_factor(const unsigned column, const unsigned factor)
Sets the grow factor for a column.
unsigned horizontal_placement
all_children_itors all_children_range() const
In-order iteration over all children.
std::vector< tresolution > resolutions
std::pair< all_children_iterator, all_children_iterator > all_children_itors
std::vector< twindow_builder::tresolution >::const_iterator get_window_builder(const std::string &type)
Returns an interator to the requested builder.
tformula< bool > reevaluate_best_size
void init_grid(const boost::intrusive_ptr< tbuilder_grid > &grid_builder)
Initializes and builds the grid.
#define log_scope2(domain, description)
void init_linked_size_group(const std::string &id, const bool fixed_width, const bool fixed_height)
Initializes a linked size group.
ttip(const config &cfg, const std::string &tagname)
cl_event GLbitfield flags
tbuilder_grid(const config &cfg)
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
GLint GLint GLint GLint GLint x
std::vector< unsigned > border_size
The border size per grid cell.
void set_click_dismiss(const bool click_dismiss)
boost::uint32_t decode_color(const std::string &color)
Converts a color string to a color.
unsigned get_v_align(const std::string &v_align)
Returns the vertical alignment.
tbuilder_widget_ptr create_builder_widget(const config &cfg)
Create a widget builder.
lg::log_domain log_gui_general("gui/general")
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
void register_builder_widget(const std::string &id, std::function< tbuilder_widget_ptr(config)> functor)
Registers a widget to be build.
void set_rows_cols(const unsigned rows, const unsigned cols)
Wrapper to set_rows and set_cols.
bool has_linked_size_group(const std::string &id)
Is the linked size group defined for this window?
GLenum GLenum GLvoid * row
boost::intrusive_ptr< tbuilder_widget > tbuilder_widget_ptr
std::vector< tlinked_group > linked_groups
config & child(const std::string &key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
this module manages the cache of images.
GLint GLint GLint GLint GLint GLint GLsizei width
void set_child(twidget *widget, const unsigned row, const unsigned col, const unsigned flags, const unsigned border_size)
Sets a child in the grid.
A config object defines a single node in a WML file, with access to child nodes.
unsigned vertical_placement
unsigned get_h_align(const std::string &h_align)
Returns the horizontal alignment.
game_logic::function_symbol_table functions
GLsizei const GLcharARB ** string
Contains the implementation details for lexical_cast and shouldn't be used directly.