gui/dialogs/popup.hpp

Go to the documentation of this file.
00001 /* $Id: popup.hpp 52869 2012-02-03 20:18:33Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2011 - 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_POPUP_HPP_INCLUDED
00017 #define GUI_DIALOGS_POPUP_HPP_INCLUDED
00018 
00019 #include <string>
00020 
00021 class CVideo;
00022 
00023 namespace gui2 {
00024 
00025 class twindow;
00026 
00027 /**
00028  * The popup class shows windows that are shown non-modal.
00029  *
00030  * At the moment these windows also don't capture the mouse and keyboard so can
00031  * only be used for things like tooltips. This behaviour might change later.
00032  */
00033 class tpopup
00034 {
00035     /**
00036      * Special helper function to get the id of the window.
00037      *
00038      * This is used in the unit tests, but these implementation details
00039      * shouldn't be used in the normal code.
00040      */
00041     friend std::string unit_test_mark_popup_as_tested(const tpopup& dialog);
00042 
00043     /**
00044      * Special helper function for the unit test to the the window.
00045      *
00046      * This is used in the unit tests, but these implementation details
00047      * shouldn't be used in the normal code.
00048      */
00049     friend twindow* unit_test_window(const tpopup& dialog);
00050 
00051 public:
00052     tpopup();
00053 
00054     virtual ~tpopup();
00055 
00056     /**
00057      * Shows the window.
00058      *
00059      * @param video               The video which contains the surface to draw
00060      *                            upon.
00061      * @param allow_interaction   Does the dialog allow interaction?
00062      *                            * true a non modal window is shown
00063      *                            * false a tooltip windw is shown
00064      * @param auto_close_time     The time in ms after which the dialog will
00065      *                            automatically close, if 0 it doesn't close.
00066      *                            @note the timeout is a minimum time and
00067      *                            there's no quarantee about how fast it closes
00068      *                            after the minimum.
00069      */
00070     void show(CVideo& video
00071             , const bool allow_interaction = false
00072             , const unsigned auto_close_time = 0);
00073 
00074 
00075     /**
00076      * Hides the window.
00077      *
00078      * The hiding also destroys the window. It is save to call the function
00079      * when the window is not shown.
00080      */
00081     void hide();
00082 
00083 private:
00084 
00085     /** The window, used in show. */
00086     twindow* window_;
00087 
00088     /** The id of the window to build. */
00089     virtual const std::string& window_id() const = 0;
00090 
00091     /**
00092      * Builds the window.
00093      *
00094      * Every dialog shows it's own kind of window, this function should return
00095      * the window to show.
00096      *
00097      * @param video               The video which contains the surface to draw
00098      *                            upon.
00099      * @returns                   The window to show.
00100      */
00101     twindow* build_window(CVideo& video) const;
00102 
00103     /**
00104      * Actions to be taken directly after the window is build.
00105      *
00106      * @param video               The video which contains the surface to draw
00107      *                            upon.
00108      * @param window              The window just created.
00109      */
00110     virtual void post_build(CVideo& /*video*/, twindow& /*window*/) {}
00111 
00112     /**
00113      * Actions to be taken before showing the window.
00114      *
00115      * @param video               The video which contains the surface to draw
00116      *                            upon.
00117      * @param window              The window to be shown.
00118      */
00119     virtual void pre_show(CVideo& /*video*/, twindow& /*window*/) {}
00120 };
00121 
00122 } // namespace gui2
00123 
00124 #endif
00125 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:58 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs