00001 /* $Id: helper.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2008 - 2012 by Mark de Wever <koraq@xs4all.nl> 00004 Part of the Battle for Wesnoth Project http://www.wesnoth.org/ 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY. 00012 00013 See the COPYING file for more details. 00014 */ 00015 00016 #ifndef GUI_DIALOGS_HELPER_HPP_INCLUDED 00017 #define GUI_DIALOGS_HELPER_HPP_INCLUDED 00018 00019 #include "gui/widgets/window.hpp" 00020 00021 namespace gui2 { 00022 00023 /** 00024 * Template for dialog callbacks. Example usage: 00025 * widget->set_callback(dialog_callback<my_dialog_class, &my_dialog_class::member_function>); 00026 */ 00027 template <class D, void (D::*fptr)(twindow&)> 00028 void dialog_callback(twidget* caller) 00029 { 00030 D* dialog = dynamic_cast<D*>(caller->dialog()); 00031 assert(dialog); 00032 twindow* window = dynamic_cast<twindow*>(caller->get_window()); 00033 assert(window); 00034 (dialog->*fptr)(*window); 00035 } 00036 00037 } // namespace gui2 00038 00039 #endif 00040
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:42 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |