16 #define GETTEXT_DOMAIN "wesnoth-lib"
31 #define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
32 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
44 , builders_(builder.builders)
45 , list_items_(builder.list_items)
80 for(
const auto& builder_entry :
builders_) {
84 grid* parent_grid = find_widget<grid>(
"_content_grid",
false,
true);
130 load_resolutions<resolution>(cfg);
140 auto child =
VALIDATE_WML_CHILD(cfg,
"grid",
_(
"No grid defined for tab container control"));
141 grid = std::make_shared<builder_grid>(child);
149 builder_tab_container::builder_tab_container(
const config& cfg)
158 item[
"label"] = tab[
"image"];
159 list_row.emplace(
"image", item);
160 item[
"label"] = tab[
"name"];
161 list_row.emplace(
"name", item);
165 if (tab.has_child(
"data")) {
166 auto builder = std::make_shared<builder_grid>(tab.mandatory_child(
"data"));
175 auto widget = std::make_unique<tab_container>(*
this);
180 widget->init_grid(*conf->grid);
185 DBG_GUI_G <<
"Window builder: placed tab_container '" <<
id
186 <<
"' with definition '" <<
definition <<
"'.";
A config object defines a single node in a WML file, with access to child nodes.
bool has_child(config_key_type key) const
Determine whether a config has a child or not.
child_itors child_range(config_key_type key)
A generic container base class.
const grid & get_grid() const
virtual void place(const point &origin, const point &size) override
See widget::place.
void connect_signal(const F &func, const queue_position position=back_child)
Adds a callback to the appropriate queue based on event type.
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
virtual void select_item(const unsigned index, const bool select)=0
(De)selects an item.
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.
Basic template class to generate new items.
grid & create_item(const int index, const builder_grid &list_builder, const widget_item &item_data, const std::function< void(widget &)> &callback) override
Inherited from generator_base.
std::unique_ptr< widget > swap_child(const std::string &id, std::unique_ptr< widget > w, const bool recurse, widget *new_parent=nullptr)
Exchanges a child in the grid.
grid & add_row(const widget_item &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
bool select_row(const unsigned row, const bool select=true)
Selects a row.
A container widget that shows one of its pages of widgets depending on which tab the user clicked.
state_t state_
Current state of the widget.
virtual unsigned get_state() const override
Returns the id of the state.
void finalize(std::unique_ptr< generator_base > generator)
Finishes the building initialization of the widget.
generator_base * generator_
Contains a pointer to the generator.
virtual bool get_active() const override
Gets the active state of the styled_widget.
unsigned get_tab_count() const
virtual void set_self_active(const bool active) override
Helper for set_active.
bool can_wrap() const override
See widget::can_wrap.
std::vector< std::shared_ptr< builder_grid > > builders_
void add_tab_entry(const widget_data row)
void select_tab(unsigned index)
std::vector< widget_data > list_items_
listbox & get_internal_list()
Get the listbox inside which the tabs are shown.
unsigned get_active_tab_index()
static std::string _(const char *str)
Define the common log macros for the gui toolkit.
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
Contains the implementation details for lexical_cast and shouldn't be used directly.
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
This file contains the settings handling of the widget library.
virtual std::unique_ptr< widget > build() const override
std::vector< widget_data > list_items
std::vector< std::shared_ptr< builder_grid > > builders
std::vector< state_definition > state
resolution(const config &cfg)
tab_container_definition(const config &cfg)
std::string missing_mandatory_wml_tag(const std::string §ion, const std::string &tag)
Returns a standard message for a missing wml child (tag).
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
#define VALIDATE_WML_CHILD(cfg, key, message)