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();
67 listbox& list = find_widget<listbox>(&window,
"list",
true);
74 if(
toggle_button* checkbox = find_widget<toggle_button>(row_grid,
"checkbox",
false,
false)) {
75 checkbox->set_value_bool(!checkbox->get_value_bool(),
true);
79 void resize_callback(window& window)
88 , items_(items.begin(), items.end())
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)
131 if(dynamic_cast<toggle_button*>(
get_window()->
find_at(coordinate,
true)) !=
nullptr) {
168 for(
const auto& entry :
items_) {
176 if(!entry.checkbox) {
177 item[
"label"] = entry.icon;
178 data.emplace(
"icon", item);
182 item[
"label"] = entry.label;
183 data.emplace(
"label", item);
187 item[
"label"] = *entry.details;
188 data.emplace(
"details", item);
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>();
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);
224 window.keyboard_capture(&list);
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);
window(const builder_window::window_resolution &definition)
< Needs to be initialized in show.
Dialog was closed with the CANCEL button.
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
virtual widget * find_at(const point &coordinate, const bool must_be_active) override
See widget::find_at.
const std::vector< std::string > items
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.
A label displays a text, the text can be wrapped but no scrollbars are provided.
int get_selected_row() const
Returns the first selected row.
bool select_row(const unsigned row, const bool select=true)
Selects a row.
bool contains(const Container &container, const Value &value)
Returns true iff value is found in container.
std::map< std::string, t_string > widget_item
This file contains the settings handling of the widget library.
unsigned get_item_count() const
Returns the number of items in the listbox.
window * get_window()
Returns a pointer to the dialog's window.
std::string bool_string(const bool value)
Converts a bool value to 'true' or 'false'.
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
const grid * get_row_grid(const unsigned row) const
Returns the grid of the wanted row.
Contains the SDL_Rect helper code.
Abstract base class for all modal dialogs.
Functions to load and save images from/to disk.
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
std::map< std::string, widget_item > widget_data
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.
Dialog was closed with the OK button.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
A config object defines a single node in a WML file, with access to child nodes.
base class of top level items, the only item which needs to store the final canvases to draw on...
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
std::pair< std::string, unsigned > item
void set_variable(const std::string &key, const wfl::variant &value)