Add a seperate macro to register a window.

The code for the tooltips can use one dialog for several windows. This
means the current register window macros won't work so split the main
macro in two parts:

- register the window

- 'write' the code for the dialog
This commit is contained in:
Mark de Wever 2011-02-07 20:57:31 +00:00
parent 6bb642890b
commit 0d0b685661
65 changed files with 117 additions and 96 deletions

View file

@ -71,7 +71,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(addon_description)
REGISTER_DIALOG(addon_description)
void taddon_description::pre_show(CVideo& /*video*/, twindow& window)
{

View file

@ -50,7 +50,7 @@ public:
taddon_description(const addon_info& ainfo)
: ainfo_(ainfo) {}
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -45,7 +45,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(addon_connect)
REGISTER_DIALOG(addon_connect)
void taddon_connect::pre_show(CVideo& /*video*/, twindow& window)
{

View file

@ -59,7 +59,7 @@ private:
bool allow_updates_;
bool allow_remove_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -60,7 +60,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(addon_list)
REGISTER_DIALOG(addon_list)
void taddon_list::pre_show(CVideo& /*video*/, twindow& window)
{

View file

@ -34,7 +34,7 @@ public:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -60,7 +60,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(campaign_difficulty)
REGISTER_DIALOG(campaign_difficulty)
tcampaign_difficulty::tcampaign_difficulty(const std::vector<std::string>& items)
: index_(-1), items_()

View file

@ -38,7 +38,7 @@ private:
int index_;
std::vector<legacy_menu_item> items_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -74,7 +74,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(campaign_selection)
REGISTER_DIALOG(campaign_selection)
void tcampaign_selection::campaign_selected(twindow& window)
{

View file

@ -42,7 +42,7 @@ private:
/** Called when another campaign is selected. */
void campaign_selected(twindow& window);
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -47,7 +47,7 @@
namespace gui2 {
REGISTER_WINDOW(data_manage)
REGISTER_DIALOG(data_manage)
tdata_manage::tdata_manage(const config& cache_config)
: txtFilter_(register_text("txtFilter", false))

View file

@ -40,7 +40,7 @@ protected:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
bool filter_text_changed(ttext_* textbox, const std::string& text);

View file

@ -70,7 +70,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(debug_clock)
REGISTER_DIALOG(debug_clock)
void tdebug_clock::pre_show(CVideo& /*video*/, twindow& window)
{

View file

@ -122,7 +122,7 @@ private:
*/
ttime time_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -28,53 +28,74 @@ namespace gui2 {
/**
* Registers a window.
*
* Call this function to register a window. In the header of the class add the
* following code:
* 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 @ref REGISTER_DIALOG instead of this
* function. It also directly adds the code for the dialog's id function.
*
* @todo Rename the function to its full name once the old name has been unused
* for a while.
*
* @param id Id of the window, multiple dialogs can use
* the same window so the id doesn't need to be
* unique.
*/
#define REGISTER_WND( \
id) \
namespace { \
\
namespace ns_##id { \
\
struct tregister_helper { \
tregister_helper() \
{ \
register_window(#id); \
} \
}; \
\
tregister_helper register_helper; \
} \
}
/**
* Registers a window for a dialog.
*
* Call this function to register a window. In the header of the class it adds
* the following code:
*@code
* // Inherited from tdialog, implemented by REGISTER_WINDOW.
* // Inherited from tdialog, implemented by REGISTER_DIALOG.
* virtual const std::string& id() const;
*@endcode
* Then use this macro in the implementation, inside the gui2 namespace.
*
* @note When the @ref id is "foo" and the type tfoo it's easier to use
* REGISTER_WINDOW(foo).
* REGISTER_DIALOG(foo).
*
* @param type Class type of the window to register.
* @param id Id of the window, multiple dialogs can use
* the same window so the id doesn't need to be
* unique.
*/
#define REGISTER_WINDOW2( \
#define REGISTER_DIALOG2( \
type \
, id) \
namespace { \
\
namespace ns_##type { \
\
struct tregister_helper { \
tregister_helper() \
{ \
register_window(id); \
} \
}; \
\
tregister_helper register_helper; \
} \
} \
REGISTER_WND(id) \
\
const std::string& \
type::window_id() const \
{ \
static const std::string result(id); \
static const std::string result(#id); \
return result; \
}
/**
* Wrapper for REGISTER_WINDOW2.
* Wrapper for REGISTER_DIALOG2.
*
* "Calls" REGISTER_WINDOW2(twindow_id, "window_id")
* "Calls" REGISTER_DIALOG2(twindow_id, window_id)
*/
#define REGISTER_WINDOW(window_id) REGISTER_WINDOW2(t##window_id, #window_id)
#define REGISTER_DIALOG(window_id) REGISTER_DIALOG2(t##window_id, window_id)
/**
* Abstract base class for all dialogs.

View file

@ -46,7 +46,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(edit_label)
REGISTER_DIALOG(edit_label)
tedit_label::tedit_label(const std::string& label, bool team_only)
: team_only_(team_only)

View file

@ -51,7 +51,7 @@ private:
tfield_text* label_field_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -52,7 +52,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(editor_generate_map)
REGISTER_DIALOG(editor_generate_map)
teditor_generate_map::teditor_generate_map()
: map_generators_()

View file

@ -54,7 +54,7 @@ public:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -40,7 +40,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(editor_new_map)
REGISTER_DIALOG(editor_new_map)
teditor_new_map::teditor_new_map() :
map_width_(register_integer("width", false)),

View file

@ -38,7 +38,7 @@ private:
tfield_integer* map_width_;
tfield_integer* map_height_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
};

View file

@ -87,7 +87,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(editor_resize_map)
REGISTER_DIALOG(editor_resize_map)
/**
* @todo Test whether the slider can be changed to an interger selector.

View file

@ -73,7 +73,7 @@ private:
EXPAND_DIRECTION expand_direction_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
void pre_show(CVideo& video, twindow& window);

View file

@ -74,7 +74,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(editor_settings)
REGISTER_DIALOG(editor_settings)
teditor_settings::teditor_settings()
: redraw_callback_()

View file

@ -61,7 +61,7 @@ public:
void set_use_mdi(bool value);
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -62,7 +62,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(formula_debugger)
REGISTER_DIALOG(formula_debugger)
void tformula_debugger::pre_show(CVideo& /*video*/, twindow& window)
{

View file

@ -37,7 +37,7 @@ private:
/** Inherited from tdialog. */
void pre_show(CVideo& video, twindow& window);
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/***** ***** button callbacks ***** *****/

View file

@ -35,7 +35,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(game_delete)
REGISTER_DIALOG(game_delete)
tgame_delete::tgame_delete()
: chk_dont_ask_again_(register_bool("dont_ask_again"))

View file

@ -33,7 +33,7 @@ private:
/** Inherited from tdialog. */
void post_show(twindow& window);
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
tfield_bool* chk_dont_ask_again_;

View file

@ -88,7 +88,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(game_load)
REGISTER_DIALOG(game_load)
tgame_load::tgame_load(const config& cache_config)
: txtFilter_(register_text("txtFilter", false))

View file

@ -42,7 +42,7 @@ protected:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
bool filter_text_changed(ttext_* textbox, const std::string& text);

View file

@ -45,7 +45,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(game_save)
REGISTER_DIALOG(game_save)
tgame_save::tgame_save(const std::string& title, const std::string& filename) :
txtFilename_(register_text("txtFilename", false)),
@ -70,7 +70,7 @@ void tgame_save::post_show(twindow& window)
}
REGISTER_WINDOW(game_save_message)
REGISTER_DIALOG(game_save_message)
tgame_save_message::tgame_save_message(const std::string& title, const std::string& filename, const std::string& message)
: tgame_save(title, filename),
@ -84,7 +84,7 @@ void tgame_save_message::pre_show(CVideo& video, twindow& window)
tgame_save::pre_show(video, window);
}
REGISTER_WINDOW(game_save_oos)
REGISTER_DIALOG(game_save_oos)
tgame_save_oos::tgame_save_oos(const std::string& title, const std::string& filename, const std::string& message)
: tgame_save_message(title, filename, message),

View file

@ -37,7 +37,7 @@ protected:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
tfield_text* txtFilename_;
@ -51,7 +51,7 @@ public:
tgame_save_message(const std::string& title, const std::string& filename="", const std::string& message="");
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tgame_save. */
@ -68,7 +68,7 @@ public:
bool ignore_all() const { return ignore_all_; }
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -554,7 +554,7 @@ private:
};
REGISTER_WINDOW(gamestate_inspector)
REGISTER_DIALOG(gamestate_inspector)
tgamestate_inspector::tgamestate_inspector(const vconfig &cfg)
: view_()

View file

@ -36,7 +36,7 @@ public:
boost::shared_ptr<view> get_view();
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
boost::shared_ptr<view> view_;

View file

@ -49,7 +49,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(language_selection)
REGISTER_DIALOG(language_selection)
void tlanguage_selection::pre_show(CVideo& /*video*/, twindow& window)
{

View file

@ -27,7 +27,7 @@ public:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -72,7 +72,7 @@ static lg::log_domain log_lobby("lobby");
namespace gui2 {
REGISTER_WINDOW(lobby_main)
REGISTER_DIALOG(lobby_main)
void tsub_player_list::init(gui2::twindow &w, const std::string &id)
{

View file

@ -325,7 +325,7 @@ private:
void skip_replay_changed_callback(twidget* w);
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -27,7 +27,7 @@
namespace gui2 {
REGISTER_WINDOW(lobby_player_info)
REGISTER_DIALOG(lobby_player_info)
tlobby_player_info::tlobby_player_info(events::chat_handler& chat, user_info& info, const lobby_info& li)
: chat_(chat), info_(info), reason_(NULL), time_(NULL), relation_(NULL),

View file

@ -38,7 +38,7 @@ public:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -28,7 +28,7 @@
namespace gui2 {
REGISTER_WINDOW(message)
REGISTER_DIALOG(message)
/**
* Helper to implement private functions without modifying the header.

View file

@ -125,7 +125,7 @@ private:
/** Holds a pointer to the buttons. */
std::vector<tbutton_status> buttons_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
};

View file

@ -70,7 +70,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(mp_cmd_wrapper)
REGISTER_DIALOG(mp_cmd_wrapper)
tmp_cmd_wrapper::tmp_cmd_wrapper(const t_string& user) :
message_(), reason_(), time_(), user_(user) { }

View file

@ -32,7 +32,7 @@ public:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -72,7 +72,7 @@ public:
private:
std::string host_name_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */
@ -82,7 +82,7 @@ private:
void post_show(twindow& window);
};
REGISTER_WINDOW(mp_server_list)
REGISTER_DIALOG(mp_server_list)
void tmp_server_list::pre_show(CVideo& /*video*/, twindow& window)
{
@ -143,7 +143,7 @@ void tmp_server_list::post_show(twindow& window)
* @end{table}
*/
REGISTER_WINDOW(mp_connect)
REGISTER_DIALOG(mp_connect)
tmp_connect::tmp_connect() :
video_(0),
@ -218,7 +218,7 @@ void tmp_connect::show_server_list(twindow& window)
* @end{table}
*/
REGISTER_WINDOW(mp_login)
REGISTER_DIALOG(mp_login)
tmp_login::tmp_login(const t_string& label, const bool focus_password) :
label_(label), focus_password_(focus_password) { }

View file

@ -31,7 +31,7 @@ private:
/** Used in show in order to show list. */
CVideo* video_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */
@ -54,7 +54,7 @@ public:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -37,7 +37,7 @@
#endif
namespace gui2 {
REGISTER_WINDOW(mp_create_game)
REGISTER_DIALOG(mp_create_game)
tmp_create_game::tmp_create_game(const config& cfg) :
cfg_(cfg),

View file

@ -32,7 +32,7 @@ public:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -39,7 +39,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(mp_create_game_set_password)
REGISTER_DIALOG(mp_create_game_set_password)
tmp_create_game_set_password::tmp_create_game_set_password(const std::string& password)
: password_(password)

View file

@ -38,7 +38,7 @@ private:
std::string password_;
tfield_text* password_field_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -51,7 +51,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(mp_method_selection)
REGISTER_DIALOG(mp_method_selection)
void tmp_method_selection::pre_show(CVideo& /*video*/, twindow& window)
{

View file

@ -37,7 +37,7 @@ private:
int choice_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -61,7 +61,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(simple_item_selector)
REGISTER_DIALOG(simple_item_selector)
tsimple_item_selector::tsimple_item_selector(const std::string& title, const std::string& message, list_type const& items, bool title_uses_markup, bool message_uses_markup)
: index_(-1)

View file

@ -65,7 +65,7 @@ private:
std::string ok_label_, cancel_label_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -85,7 +85,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(title_screen)
REGISTER_DIALOG(title_screen)
bool show_debug_clock_button = false;

View file

@ -65,7 +65,7 @@ public:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -26,7 +26,7 @@
namespace gui2 {
REGISTER_WINDOW(transient_message)
REGISTER_DIALOG(transient_message)
void ttransient_message::pre_show(CVideo& /*video*/, twindow& window)
{

View file

@ -58,7 +58,7 @@ private:
/** An optional image to show at the left of the text. */
std::string image_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
};

View file

@ -54,7 +54,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(unit_attack)
REGISTER_DIALOG(unit_attack)
tunit_attack::tunit_attack(
const unit_map::iterator& attacker_itor

View file

@ -38,7 +38,7 @@ public:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -77,7 +77,7 @@ namespace gui2 {
* @end{table}
*/
REGISTER_WINDOW(unit_create)
REGISTER_DIALOG(unit_create)
tunit_create::tunit_create()
: gender_(last_gender)

View file

@ -44,7 +44,7 @@ private:
std::string choice_;
std::vector<std::string> type_ids_;
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */

View file

@ -156,9 +156,9 @@ void twml_message_::post_show(twindow& window)
}
}
REGISTER_WINDOW(wml_message_left)
REGISTER_DIALOG(wml_message_left)
REGISTER_WINDOW(wml_message_right)
REGISTER_DIALOG(wml_message_right)
int show_wml_message(const bool left_side
, CVideo& video

View file

@ -116,7 +116,7 @@ public:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
};
@ -132,7 +132,7 @@ public:
private:
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
};