The Battle for Wesnoth  1.15.1+dev
Classes | Namespaces | Macros
modal_dialog.hpp File Reference
#include "gui/auxiliary/field-fwd.hpp"
#include "gui/core/static_registry.hpp"
#include "utils/functional.hpp"
#include <string>
#include <vector>
Include dependency graph for modal_dialog.hpp:

Go to the source code of this file.

Classes

class  gui2::dialogs::modal_dialog
 Abstract base class for all modal dialogs. More...
 

Namespaces

 gui2
 Generic file dialog.
 
 gui2::dialogs
 

Macros

#define REGISTER_WINDOW(id)
 Registers a window. More...
 
#define REGISTER_DIALOG2(type, id)
 Registers a window for a dialog. More...
 
#define REGISTER_DIALOG(window_id)   REGISTER_DIALOG2(window_id, window_id)
 Wrapper for REGISTER_DIALOG2. More...
 
#define DEFINE_SIMPLE_DISPLAY_WRAPPER(dialog)
 Adds a bare-bones static display function to a dialog class that immediately invokes the dialogs's modal_dialog::show function. More...
 
#define DEFINE_SIMPLE_EXECUTE_WRAPPER(dialog)
 Adds a bare-bonesstatic execute function to a dialog class that immediately invokes and return the result of the dialogs's modal_dialog::show function. More...
 

Macro Definition Documentation

◆ DEFINE_SIMPLE_DISPLAY_WRAPPER

#define DEFINE_SIMPLE_DISPLAY_WRAPPER (   dialog)
Value:
template<typename... T> \
static void display(T&&... args) \
{ \
dialog(std::forward<T>(args)...).show(); \
}

Adds a bare-bones static display function to a dialog class that immediately invokes the dialogs's modal_dialog::show function.

If more complex behavior is desired, the function should be defined manually.

See the modal_dialog documentation (below) for more info.

Definition at line 98 of file modal_dialog.hpp.

◆ DEFINE_SIMPLE_EXECUTE_WRAPPER

#define DEFINE_SIMPLE_EXECUTE_WRAPPER (   dialog)
Value:
template<typename... T> \
static bool execute(T&&... args) \
{ \
return dialog(std::forward<T>(args)...).show(); \
}

Adds a bare-bonesstatic execute function to a dialog class that immediately invokes and return the result of the dialogs's modal_dialog::show function.

If more complex behavior is desired, the function should be defined manually.

See the modal_dialog documentation (below) for more info.

Definition at line 112 of file modal_dialog.hpp.

Referenced by gui2::dialogs::language_selection::language_selection().

◆ REGISTER_DIALOG

#define REGISTER_DIALOG (   window_id)    REGISTER_DIALOG2(window_id, window_id)

◆ REGISTER_DIALOG2

#define REGISTER_DIALOG2 (   type,
  id 
)
Value:
REGISTER_WINDOW(id) const std::string& type::window_id() const \
{ \
static const std::string result(#id); \
return result; \
}

Registers a window for a dialog.

Call this function to register a window. In the header of the class it adds the following code:

// Inherited from modal_dialog, implemented by REGISTER_DIALOG.
virtual const std::string& id() const;

Then use this macro in the implementation, inside the gui2 namespace.

Note
When the id is "foo" and the type tfoo it's easier to use REGISTER_DIALOG(foo).
Parameters
typeClass type of the window to register.
idId of the window, multiple dialogs can use the same window so the id doesn't need to be unique.

Definition at line 77 of file modal_dialog.hpp.

◆ REGISTER_WINDOW

#define REGISTER_WINDOW (   id)
Value:
namespace \
{ \
namespace ns_##id \
{ \
struct register_helper \
{ \
register_helper() \
{ \
register_window(#id); \
} \
}; \
\
struct register_helper register_helper; \
} \
}

Registers a window.

This function registers a window. The registration is used to validate whether the config for the window exists when starting Wesnoth.

Note
Most of the time you want to call REGISTER_DIALOG instead of this function. It also directly adds the code for the dialog's id function.
Parameters
idId of the window, multiple dialogs can use the same window so the id doesn't need to be unique.

Definition at line 41 of file modal_dialog.hpp.