16 #define GETTEXT_DOMAIN "wesnoth-lib"
42 , icon(cfg["icon"].str())
49 if(cfg.has_attribute(
"checkbox")) {
50 checkbox = cfg[
"checkbox"].to_bool(
false);
54 if(cfg.has_attribute(
"image")) {
55 image = cfg[
"image"].str();
58 if(cfg.has_attribute(
"details")) {
59 details = cfg[
"details"].t_str();
74 if(
toggle_button* checkbox = find_widget<toggle_button>(row_grid,
"checkbox",
false,
false)) {
75 checkbox->set_value_bool(!checkbox->get_value_bool(),
true);
89 , button_pos_(parent->get_rectangle())
90 , selected_item_(selected_item)
91 , use_markup_(parent->get_use_markup())
92 , keep_open_(keep_open)
93 , mouse_down_happened_(false)
101 , button_pos_(button_pos)
102 , selected_item_(selected_item)
103 , use_markup_(use_markup)
104 , keep_open_(keep_open)
105 , mouse_down_happened_(false)
168 for(
const auto& entry :
items_) {
176 if(!entry.checkbox) {
177 item[
"label"] = entry.icon;
182 item[
"label"] = entry.label;
187 item[
"label"] = *entry.details;
192 grid& mi_grid = find_widget<grid>(&new_row,
"menu_item",
false);
195 find_widget<toggle_panel>(&new_row,
"panel",
false).set_tooltip(entry.tooltip);
198 auto checkbox = build_single_widget_instance<toggle_button>(
config{
"definition",
"no_label"});
199 checkbox->set_id(
"checkbox");
200 checkbox->set_value_bool(*entry.checkbox);
209 mi_grid.
swap_child(
"icon", std::move(checkbox),
false);
213 auto img = build_single_widget_instance<image>();
214 img->set_label(*entry.image);
216 mi_grid.
swap_child(
"label", std::move(img),
false);
242 std::bind(&callback_flip_embedded_toggle, std::ref(
window)));
254 boost::dynamic_bitset<> states;
259 if(
const toggle_button* checkbox = find_widget<const toggle_button>(row_grid,
"checkbox",
false,
false)) {
260 states.push_back(checkbox->get_value_bool());
262 states.push_back(
false);
A config object defines a single node in a WML file, with access to child nodes.
Abstract base class for all modal dialogs.
window * get_window()
Returns a pointer to the dialog's window.
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.
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.
A label displays text that can be wrapped but no scrollbars are provided.
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.
const grid * get_row_grid(const unsigned row) const
Returns the grid of the wanted row.
bool select_row(const unsigned row, const bool select=true)
Selects a row.
int get_selected_row() const
Returns the first selected row.
unsigned get_item_count() const
Returns the number of items in the listbox.
base class of top level items, the only item which needs to store the final canvases to draw on.
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
void keyboard_capture(widget *widget)
void set_variable(const std::string &key, const wfl::variant &value)
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
std::map< std::string, widget_item > widget_data
std::map< std::string, t_string > widget_item
@ OK
Dialog was closed with the OK button.
@ CANCEL
Dialog was closed with the CANCEL button.
std::pair< std::string, unsigned > item
Functions to load and save images from/to disk.
const std::vector< std::string > items
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
std::string bool_string(const bool value)
Converts a bool value to 'true' or 'false'.
Contains the SDL_Rect helper code.
This file contains the settings handling of the widget library.