16 #define GETTEXT_DOMAIN "wesnoth-lib" 88 for(; count; --count) {
108 throw std::invalid_argument(
"invalid page index");
148 generator->create_items(-1, *
page_builders_.begin()->second, page_data,
nullptr);
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 &
i : column.attribute_range())
213 data.back()[
i.first] =
i.second;
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);
Base class of a resolution, contains the common keys for a resolution.
std::vector< widget_item > data
Multi page data.
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...
builder_grid_map builders
virtual unsigned get_item_count() const =0
Returns the number of items.
const grid & get_grid() const
void finalize(std::unique_ptr< generator_base > generator, const std::vector< widget_item > &page_data)
Finishes the building initialization of the widget.
builder_grid_map page_builders_
Contains the builder for the new items.
child_itors child_range(config_key_type key)
void clear()
Removes all pages in the multi page, clearing it.
virtual void set_self_active(const bool active) override
See container_base::set_self_active.
void remove_page(const unsigned page, unsigned count=1)
Removes a page in the multi page.
virtual grid & item(const unsigned index)=0
Gets the grid of an item.
int get_selected_page() const
Returns the selected page.
static std::string _(const char *str)
resolution(const config &cfg)
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.
const grid & page_grid(const unsigned page) const
Returns the grid for the page.
Basic template class to generate new items.
virtual std::unique_ptr< widget > build() const override
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.
virtual int get_selected_item() const =0
Returns the selected item.
generator_base * generator_
Contains a pointer to the generator.
virtual void clear()=0
Deletes all items.
void select_page(const unsigned page, const bool select=true)
Selects a page.
grid & add_page(const widget_item &item)
Adds single page to the grid.
virtual bool get_active() const override
See styled_widget::get_active.
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.
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 impl_draw_background() override
See widget::impl_draw_background.
multi_page_definition(const config &cfg)
unsigned get_page_count() const
Returns the number of pages.
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
virtual void delete_item(const unsigned index)=0
Deletes an item.
A multi page is a control that contains several 'pages' of which only one is visible.
virtual void select_item(const unsigned index, const bool select)=0
(De)selects an item.
std::map< std::string, widget_item > widget_data
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::pair< std::string, unsigned > item
virtual unsigned get_state() const override
See styled_widget::get_state.