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);
216 template<
typename T,
typename... Args>
241 const bool mandatory,
242 const std::function<
bool()> callback_load_value =
nullptr,
243 const std::function<
void(
bool)> callback_save_value =
nullptr,
244 const std::function<
void(
widget&)> callback_change =
nullptr,
245 const bool initial_fire =
false);
265 const bool mandatory,
266 bool& linked_variable,
267 const std::function<
void(
widget&)> callback_change =
nullptr,
268 const bool initial_fire =
false);
277 const bool mandatory,
278 const std::function<
int()> callback_load_value =
nullptr,
279 const std::function<
void(
int)> callback_save_value =
nullptr);
287 const bool mandatory,
288 int& linked_variable);
295 const std::string&
id,
296 const bool mandatory,
297 const std::function<std::string()> callback_load_value =
nullptr,
298 const std::function<
void(
const std::string&)> callback_save_value =
nullptr,
299 const bool capture_focus =
false);
307 const bool mandatory,
308 std::string& linked_variable,
309 const bool capture_focus =
false);
329 const bool mandatory,
330 const std::string& text,
331 const bool use_markup =
false);
335 const bool mandatory,
336 const std::string& filename)
371 std::vector<std::unique_ptr<class field_base>>
fields_;
394 virtual const std::string&
window_id()
const = 0;
T * register_field(Args &&... args)
Creates a new field of given type with given arguments.
bool show_even_without_video_
Show the dialog even with –nogui? Some dialogs need to be shown even when –nogui is specified if th...
Specialized field class for boolean.
virtual void init_fields()
Initializes all fields in the dialog and set the keyboard focus.
bool allow_plugin_skip_
Allow plugins to skip through the dialog? Most dialogs install a plugins context to allow plugins to ...
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.
bool always_save_fields_
Always save the fields upon closing.
bool show(const unsigned auto_close_time=0)
Shows the window.
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::vector< std::unique_ptr< class field_base > > fields_
Contains the automatically managed fields.
friend std::string get_modal_dialog_id(const modal_dialog &dialog)
Special helper function to get the id of the window.
void set_show_even_without_video(const bool show_even_without_video)
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.
Contains all forward declarations for field.hpp.
window * get_window()
Returns a pointer to the dialog's window.
virtual void finalize_fields(const bool save_fields)
When the dialog is closed with the OK status saves all fields.
Specialized field class for a styled_widget, used for labels and images.
modal_dialog(const std::string &window_id)
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.
virtual const std::string & window_id() const =0
The ID of the window to build.
const window * get_window() const
int get_retval() const
Returns the cached window exit code.
int retval_
The window's exit code (return value).
void set_allow_plugin_skip(const bool allow_plugin_skip)
virtual void pre_show(window &window)
Actions to be taken before showing the window.
Abstract base class for all modal dialogs.
dialogs::modal_dialog * dialog()
Inherited from widget.
virtual void post_show(window &window)
Actions to be taken after the window has been shown.
std::string focus_
Contains the widget that should get the focus when the window is shown.
field_label * register_image(const std::string &id, const bool mandatory, const std::string &filename)
Registers a new styled_widget as image.
Specialized field class for text.
base class of top level items, the only item which needs to store the final canvases to draw on...
Template class to implement the generic field implementation.
void set_always_save_fields(const bool always_save_fields)