16 #define GETTEXT_DOMAIN "wesnoth-lib"
39 , page_builders_(builder.builders)
41 const auto conf = cast_config_to<multi_page_definition>();
44 init_grid(*conf->grid);
102 for(; count; --count) {
122 throw std::invalid_argument(
"invalid page index");
174 load_resolutions<resolution>(cfg);
183 grid = std::make_shared<builder_grid>(*child);
191 builder_multi_page::builder_multi_page(
const config& cfg)
196 auto builder = std::make_shared<builder_grid>(page);
208 auto builder =
builders.begin()->second;
209 for(
const auto & row :
d->child_range(
"row"))
213 for(
const auto & column : row.child_range(
"column"))
216 for(
const auto& [key, value] : column.attribute_range())
218 data.back()[key] = value;
224 _(
"‘list_data’ must have "
225 "the same number of columns as the ‘list_definition’."));
231 auto widget = std::make_unique<multi_page>(*
this);
232 DBG_GUI_G <<
"Window builder: placed multi_page '" <<
id <<
"' with definition '" <<
definition <<
"'.";
A config object defines a single node in a WML file, with access to child nodes.
child_itors child_range(config_key_type key)
optional_config_impl< config > optional_child(config_key_type key, int n=0)
Equivalent to mandatory_child, but returns an empty optional if the nth child was not found.
A generic container base class.
virtual void delete_item(const unsigned index)=0
Deletes an item.
virtual grid & create_item(const int index, const builder_grid &list_builder, const widget_item &item_data, const std::function< void(widget &)> &callback)=0
Creates a new item.
virtual void select_item(const unsigned index, const bool select)=0
(De)selects an item.
virtual grid & item(const unsigned index)=0
Gets the grid of an item.
virtual unsigned get_item_count() const =0
Returns the number of items.
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 clear()=0
Deletes all items.
virtual int get_selected_item() const =0
Returns the selected item.
Basic template class to generate new items.
virtual void create_items(const int index, const builder_grid &list_builder, const std::vector< widget_data > &data, const std::function< void(widget &)> &callback) override
Inherited from generator_base.
const grid & page_grid(const unsigned page) const
Returns the grid for the page.
virtual unsigned get_state() const override
See styled_widget::get_state.
generator_base * generator_
Contains a pointer to the generator.
void remove_page(const unsigned page, unsigned count=1)
Removes a page in the multi page.
grid & add_page(const widget_item &item)
Adds single page to the grid.
builder_grid_map page_builders_
Contains the builder for the new items.
virtual bool get_active() const override
See styled_widget::get_active.
unsigned get_page_count() const
Returns the number of pages.
int get_selected_page() const
Returns the selected page.
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
virtual bool impl_draw_background() override
See widget::impl_draw_background.
virtual void set_self_active(const bool active) override
See container_base::set_self_active.
void select_page(const unsigned page, const bool select=true)
Selects a page.
void clear()
Removes all pages in the multi page, clearing it.
static std::string _(const char *str)
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
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.
Contains the implementation details for lexical_cast and shouldn't be used directly.
virtual std::unique_ptr< widget > build() const override
builder_grid_map builders
std::vector< widget_item > data
Multi page data.
resolution(const config &cfg)
multi_page_definition(const config &cfg)
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
#define VALIDATE(cond, message)
The macro to use for the validation of WML.