16 #define GETTEXT_DOMAIN "wesnoth-lib"
87 for(; count; --count) {
107 throw std::invalid_argument(
"invalid page index");
169 load_resolutions<resolution>(cfg);
178 grid = std::make_shared<builder_grid>(*child);
186 builder_multi_page::builder_multi_page(
const config& cfg)
191 auto builder = std::make_shared<builder_grid>(page);
203 auto builder =
builders.begin()->second;
204 for(
const auto & row :
d->child_range(
"row"))
208 for(
const auto & column : row.child_range(
"column"))
211 for(
const auto& [key, value] : column.attribute_range())
213 data.back()[key] = value;
219 _(
"‘list_data’ must have "
220 "the same number of columns as the ‘list_definition’."));
226 auto widget = std::make_unique<multi_page>(*
this);
230 DBG_GUI_G <<
"Window builder: placed multi_page '" <<
id
231 <<
"' with definition '" <<
definition <<
"'.";
236 widget->init_grid(*conf->grid);
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.
const grid & get_grid() const
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 finalize(std::unique_ptr< generator_base > generator, const std::vector< widget_item > &page_data)
Finishes the building initialization of the widget.
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.