16 #define GETTEXT_DOMAIN "wesnoth-lib"
39 , icon(cfg["icon"].str())
46 if(cfg.has_attribute(
"checkbox")) {
47 checkbox = cfg[
"checkbox"].to_bool(
false);
51 if(cfg.has_attribute(
"image")) {
52 image = cfg[
"image"].str();
55 if(cfg.has_attribute(
"details")) {
56 details = cfg[
"details"].t_str();
72 checkbox->set_value_bool(!checkbox->get_value_bool(),
true);
85 , items_(items.begin(), items.end())
86 , button_pos_(parent->get_rectangle())
87 , selected_item_(selected_item)
88 , use_markup_(parent->get_use_markup())
89 , keep_open_(keep_open)
90 , mouse_down_happened_(false)
97 , items_(items.begin(), items.end())
98 , button_pos_(button_pos)
99 , selected_item_(selected_item)
100 , use_markup_(use_markup)
101 , keep_open_(keep_open)
102 , mouse_down_happened_(false)
112 listbox& list = find_widget<listbox>(
"list",
true);
163 listbox& list = find_widget<listbox>(
"list",
true);
165 for(
const auto& entry :
items_) {
173 if(!entry.checkbox) {
174 item[
"label"] = entry.icon;
175 data.emplace(
"icon", item);
179 item[
"label"] = entry.label;
180 data.emplace(
"label", item);
184 item[
"label"] = *entry.details;
185 data.emplace(
"details", item);
195 auto checkbox = build_single_widget_instance<toggle_button>(
config{
"definition",
"no_label"});
196 checkbox->set_id(
"checkbox");
197 checkbox->set_value_bool(*entry.checkbox);
206 mi_grid.
swap_child(
"icon", std::move(checkbox),
false);
210 auto img = build_single_widget_instance<image>();
211 img->set_label(*entry.image);
224 connect_signal<event::SDL_LEFT_BUTTON_UP>(
227 connect_signal<event::SDL_RIGHT_BUTTON_UP>(
230 connect_signal<event::SDL_LEFT_BUTTON_DOWN>(
234 connect_signal<event::SDL_VIDEO_RESIZE>(
239 std::bind([
this](){ callback_flip_embedded_toggle(*
this); }));
244 selected_item_ = find_widget<listbox>(
"list",
true).get_selected_row();
249 const listbox& list = find_widget<const listbox>(
"list",
true);
251 boost::dynamic_bitset<> states;
257 states.push_back(checkbox->get_value_bool());
259 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.
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.
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.
REGISTER_DIALOG(editor_edit_unit)
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.
Functions to load and save images from/to disk.
std::string img(const std::string &src, const std::string &align, const bool floating)
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.