The Battle for Wesnoth  1.19.0-dev
Classes | Namespaces | Macros
modal_dialog.hpp File Reference
#include "gui/auxiliary/field-fwd.hpp"
#include "gui/core/static_registry.hpp"
#include "gui/widgets/window.hpp"
#include <functional>
#include <string>
#include <vector>
Include dependency graph for modal_dialog.hpp:
This graph shows which files directly or indirectly include this file:

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(); \
}
Sort-of-Singleton that many classes, both GUI and non-GUI, use to access the game data.
Definition: display.hpp:88

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.

◆ REGISTER_DIALOG

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

Wrapper for REGISTER_DIALOG2.

"Calls" REGISTER_DIALOG2(window_id, window_id)

Definition at line 89 of file modal_dialog.hpp.

◆ REGISTER_DIALOG2

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

Registers a window for a dialog.

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

virtual const std::string& id() const;
std::string id
Text to match against addon_info.tags()
Definition: manager.cpp:207

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 76 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.