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);
205 template<
typename T,
typename... Args>
230 const bool mandatory,
231 const std::function<
bool()>& callback_load_value =
nullptr,
232 const std::function<
void(
bool)>& callback_save_value =
nullptr,
233 const std::function<
void(
widget&)>& callback_change =
nullptr,
234 const bool initial_fire =
false);
254 const bool mandatory,
255 bool& linked_variable,
256 const std::function<
void(
widget&)>& callback_change =
nullptr,
257 const bool initial_fire =
false);
266 const bool mandatory,
267 const std::function<
int()>& callback_load_value =
nullptr,
268 const std::function<
void(
int)>& callback_save_value =
nullptr);
276 const bool mandatory,
277 int& linked_variable);
284 const std::string&
id,
285 const bool mandatory,
286 const std::function<std::string()>& callback_load_value =
nullptr,
287 const std::function<
void(
const std::string&)>& callback_save_value =
nullptr,
288 const bool capture_focus =
false);
296 const bool mandatory,
297 std::string& linked_variable,
298 const bool capture_focus =
false);
318 const bool mandatory,
319 const std::string& text,
320 const bool use_markup =
false);
324 const bool mandatory,
360 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.
int get_retval() const
Returns the cached window exit code.
int retval_
The window's exit code (return value).
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.