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)
87 , items_(items.begin(), items.end())
88 , button_pos_(parent->get_rectangle())
89 , selected_item_(selected_item)
90 , use_markup_(parent->get_use_markup())
91 , keep_open_(keep_open)
92 , mouse_down_happened_(false)
99 ,
items_(items.begin(), items.end())
131 if(dynamic_cast<toggle_button*>(
get_window()->find_at(coordinate,
true)) !=
nullptr) {
167 listbox& list = find_widget<listbox>(&window,
"list",
true);
169 for(
const auto& entry :
items_) {
170 std::map<std::string, string_map> data;
177 if(!entry.checkbox) {
178 item[
"label"] = entry.icon;
179 data.emplace(
"icon", item);
183 item[
"label"] = entry.label;
184 data.emplace(
"label", item);
188 item[
"label"] = *entry.details;
189 data.emplace(
"details", item);
193 grid& mi_grid = find_widget<grid>(&new_row,
"menu_item",
false);
196 find_widget<toggle_panel>(&new_row,
"panel",
false).set_tooltip(entry.tooltip);
199 auto checkbox = build_single_widget_instance<toggle_button>();
200 checkbox->set_id(
"checkbox");
201 checkbox->set_value_bool(*entry.checkbox);
210 mi_grid.
swap_child(
"icon", std::move(checkbox),
false);
214 auto img = build_single_widget_instance<image>();
215 img->set_label(*entry.image);
217 mi_grid.
swap_child(
"label", std::move(img),
false);
225 window.keyboard_capture(&list);
243 std::bind(&callback_flip_embedded_toggle, std::ref(window)));
248 selected_item_ = find_widget<listbox>(&window,
"list",
true).get_selected_row();
255 boost::dynamic_bitset<> states;
260 if(
const toggle_button* checkbox = find_widget<const toggle_button>(row_grid,
"checkbox",
false,
false)) {
261 states.push_back(checkbox->get_value_bool());
263 states.push_back(
false);
Dialog was closed with the CANCEL button.
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
const std::vector< std::string > items
window * get_window() const
Returns a pointer to the dialog's window.
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.
This file contains the settings handling of the widget library.
unsigned get_item_count() const
Returns the number of items in the listbox.
bool point_in_rect(int x, int y, const SDL_Rect &rect)
Tests whether a point is inside a rectangle.
std::string bool_string(const bool value)
Converts a bool value to 'true' or 'false'.
grid & add_row(const string_map &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
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.
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::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.
void set_retval(int retval)
Convenience wrapper to set the window's exit code.
base class of top level items, the only item which needs to store the final canvases to draw on...
void set_restore(const bool restore)
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)