41 #define REGISTER_WINDOW(id) \
46 struct register_helper \
50 register_window(#id); \
54 struct register_helper register_helper; \
76 #define REGISTER_DIALOG2(type, id) \
78 const std::string& type::window_id() const \
80 static const std::string result(#id); \
89 #define REGISTER_DIALOG(window_id) REGISTER_DIALOG2(window_id, window_id)
98 #define DEFINE_SIMPLE_DISPLAY_WRAPPER(dialog) \
99 template<typename... T> \
100 static void display(T&&... args) \
102 dialog(std::forward<T>(args)...).show(); \
112 #define DEFINE_SIMPLE_EXECUTE_WRAPPER(dialog) \
113 template<typename... T> \
114 static bool execute(T&&... args) \
116 return dialog(std::forward<T>(args)...).show(); \
171 bool show(
const unsigned auto_close_time = 0);
199 template<
typename T,
typename... Args>
224 const bool mandatory,
225 const std::function<
bool()>& callback_load_value =
nullptr,
226 const std::function<
void(
bool)>& callback_save_value =
nullptr,
227 const std::function<
void(
widget&)>& callback_change =
nullptr,
228 const bool initial_fire =
false);
248 const bool mandatory,
249 bool& linked_variable,
250 const std::function<
void(
widget&)>& callback_change =
nullptr,
251 const bool initial_fire =
false);
260 const bool mandatory,
261 const std::function<
int()>& callback_load_value =
nullptr,
262 const std::function<
void(
int)>& callback_save_value =
nullptr);
270 const bool mandatory,
271 int& linked_variable);
278 const std::string&
id,
279 const bool mandatory,
280 const std::function<std::string()>& callback_load_value =
nullptr,
281 const std::function<
void(
const std::string&)>& callback_save_value =
nullptr,
282 const bool capture_focus =
false);
290 const bool mandatory,
291 std::string& linked_variable,
292 const bool capture_focus =
false);
312 const bool mandatory,
313 const std::string& text,
314 const bool use_markup =
false);
318 const bool mandatory,
342 std::vector<std::unique_ptr<class field_base>>
fields_;
Abstract base class for all modal dialogs.
bool always_save_fields_
Always save the fields upon closing.
void init_fields()
Initializes all fields in the dialog and set the keyboard focus.
void set_show_even_without_video(const bool show_even_without_video)
field_bool * register_bool(const std::string &id, const bool mandatory, const std::function< bool()> &callback_load_value=nullptr, const std::function< void(bool)> &callback_save_value=nullptr, const std::function< void(widget &)> &callback_change=nullptr, const bool initial_fire=false)
Creates a new boolean field.
virtual void post_show()
Actions to be taken after the window has been shown.
void set_allow_plugin_skip(const bool allow_plugin_skip)
field_label * register_image(const std::string &id, const bool mandatory, const std::string &filename)
Registers a new styled_widget as image.
field_text * register_text(const std::string &id, const bool mandatory, const std::function< std::string()> &callback_load_value=nullptr, const std::function< void(const std::string &)> &callback_save_value=nullptr, const bool capture_focus=false)
Creates a new text field.
std::string focus_
Contains the widget that should get the focus when the window is shown.
std::vector< std::unique_ptr< class field_base > > fields_
Contains the automatically managed fields.
virtual const std::string & window_id() const =0
The ID of the window to build.
field_label * register_label(const std::string &id, const bool mandatory, const std::string &text, const bool use_markup=false)
Registers a new styled_widget as a label.
modal_dialog(const std::string &window_id)
friend std::string get_modal_dialog_id(const modal_dialog &dialog)
Special helper function to get the id of the window.
virtual void pre_show()
Actions to be taken before showing the window.
bool allow_plugin_skip_
Allow plugins to skip through the dialog? Most dialogs install a plugins context to allow plugins to ...
void set_always_save_fields(const bool always_save_fields)
field_integer * register_integer(const std::string &id, const bool mandatory, const std::function< int()> &callback_load_value=nullptr, const std::function< void(int)> &callback_save_value=nullptr)
Creates a new integer field.
T * register_field(Args &&... args)
Creates a new field of given type with given arguments.
void finalize_fields(const bool save_fields)
When the dialog is closed with the OK status saves all fields.
bool show_even_without_video_
Show the dialog even with –nogui? Some dialogs need to be shown even when –nogui is specified if the ...
bool show(const unsigned auto_close_time=0)
Shows the window.
Specialized field class for boolean.
Specialized field class for a styled_widget, used for labels and images.
Specialized field class for text.
Template class to implement the generic field implementation.
base class of top level items, the only item which needs to store the final canvases to draw on.
dialogs::modal_dialog * dialog()
Inherited from widget.
Contains all forward declarations for field.hpp.
std::string filename
Filename.