16 #define GETTEXT_DOMAIN "wesnoth-lib" 31 #define ERR_WML LOG_STREAM(err, log_wml) 44 const std::string&
id,
45 const bool must_be_active)
48 if(!stack.find_in_all_layers_) {
49 return stack.container_base::find(
id, must_be_active);
52 for(
unsigned i = 0;
i < stack.get_layer_count(); ++
i) {
53 if(W* res = stack.get_layer_grid(
i)->find(
id, must_be_active)) {
58 return stack.container_base::find(
id, must_be_active);
66 , find_in_all_layers_(false)
95 for(
const auto & builder : widget_builders) {
96 generator->create_item(-1, builder, empty_data,
nullptr);
113 for(
unsigned int i = 0; i < num_layers; ++
i) {
114 const bool selected = display_condition(i);
136 for(
unsigned int i = 0; i < num_layers; ++
i) {
199 return stacked_widget_implementation::find<widget>(*
this,
id, must_be_active);
204 return stacked_widget_implementation::find<const widget>(*
this,
id, must_be_active);
214 load_resolutions<resolution>(cfg);
221 static config dummy(
"draw");
222 state.emplace_back(dummy);
227 grid = std::make_shared<builder_grid>(child);
235 builder_stacked_widget::builder_stacked_widget(
const config& real_cfg)
239 if(&cfg != &real_cfg) {
240 lg::log_to_chat() <<
"Stacked widgets no longer require a [stack] tag. Instead, place [layer] tags directly in the widget definition.\n";
241 ERR_WML <<
"Stacked widgets no longer require a [stack] tag. Instead, place [layer] tags directly in the widget definition.";
246 stack.emplace_back(layer);
252 auto widget = std::make_unique<stacked_widget>(*this);
254 DBG_GUI_G <<
"Window builder: placed stacked widget '" <<
id 255 <<
"' with definition '" <<
definition <<
"'.";
260 widget->init_grid(*conf->grid);
Base class of a resolution, contains the common keys for a resolution.
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
std::vector< state_definition > state
virtual unsigned get_item_count() const =0
Returns the number of items.
const grid & get_grid() const
bool has_child(config_key_type key) const
Determine whether a config has a child or not.
virtual bool is_selected(const unsigned index) const =0
Returns whether the item is selected.
child_itors child_range(config_key_type key)
virtual grid & item(const unsigned index)=0
Gets the grid of an item.
static std::string _(const char *str)
typename const_clone< D, S >::reference const_clone_ref
std::map< std::string, t_string > widget_item
#define VALIDATE(cond, message)
The macro to use for the validation of WML.
This file contains the settings handling of the widget library.
Basic template class to generate new items.
void swap_grid(grid *g, grid *content_grid, std::unique_ptr< widget > widget, const std::string &id)
Swaps an item in a grid for another one.
A generic container base class.
static std::unique_ptr< generator_base > build(const bool has_minimum, const bool has_maximum, const placement placement, const bool select)
Create a new generator.
virtual void layout_children() override
See widget::layout_children.
virtual void select_item(const unsigned index, const bool select)=0
(De)selects an item.
A config object defines a single node in a WML file, with access to child nodes.
Contains the implementation details for lexical_cast and shouldn't be used directly.
std::stringstream & log_to_chat()
Use this to show WML errors in the ingame chat.