The Battle for Wesnoth  1.19.7+dev
Macros
register_widget.hpp File Reference
#include "gui/core/static_registry.hpp"
Include dependency graph for register_widget.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define REGISTER_WIDGET3(type, id, key)
 Registers a widget. More...
 
#define REGISTER_WIDGET(id)
 Wrapper for REGISTER_WIDGET3. More...
 

Macro Definition Documentation

◆ REGISTER_WIDGET

#define REGISTER_WIDGET (   id)
Value:
REGISTER_WIDGET3(id##_definition, id, nullptr) \
\
const std::string& id::type() \
{ \
static const std::string result(#id); \
return result; \
} \
\
const std::string& id::get_control_type() const \
{ \
return id::type(); \
}
#define REGISTER_WIDGET3(type, id, key)
Registers a widget.

Wrapper for REGISTER_WIDGET3.

"Calls" REGISTER_WIDGET3(id_definition, id, nullptr)

Definition at line 61 of file register_widget.hpp.

◆ REGISTER_WIDGET3

#define REGISTER_WIDGET3 (   type,
  id,
  key 
)
Value:
namespace \
{ \
namespace ns_##type##id \
{ \
struct register_helper \
{ \
register_helper() \
{ \
register_widget(#id, \
[](const config& cfg) { return std::make_shared<type>(cfg); }, key); \
[](const config& cfg) { return std::make_shared<implementation::builder_##id>(cfg); }); \
} \
}; \
\
static struct register_helper register_helper; \
} \
}
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
void register_widget_builder(const std::string &type, widget_builder_func_t functor)
Registers a widget builder.

Registers a widget.

Call this function to register a widget. Use this macro in the implementation, inside the gui2 namespace.

See gui2::register_widget for more information.

Note
When the type is foo_definition, the id "foo" and no special key best use RESISTER_WIDGET(foo) instead.
Parameters
typeClass type of the window to register.
idId of the widget
keyThe id to load if differs from id.

Definition at line 35 of file register_widget.hpp.