00001 /* $Id: debug_clock.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2010 - 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_DEBUG_CLOCK_HPP_INCLUDED 00017 #define GUI_DIALOGS_DEBUG_CLOCK_HPP_INCLUDED 00018 00019 #include "gui/dialogs/popup.hpp" 00020 00021 #include "gui/auxiliary/event/dispatcher.hpp" 00022 00023 namespace gui2 { 00024 00025 class tcontrol; 00026 class tprogress_bar; 00027 class tinteger_selector_; 00028 00029 /** Clock to test the draw events. */ 00030 class tdebug_clock 00031 : public tpopup 00032 { 00033 public: 00034 tdebug_clock() 00035 : tpopup() 00036 , hour_percentage_(NULL) 00037 , minute_percentage_(NULL) 00038 , second_percentage_(NULL) 00039 , hour_(NULL) 00040 , minute_(NULL) 00041 , second_(NULL) 00042 , clock_(NULL) 00043 , window_(NULL) 00044 , signal_() 00045 , time_() 00046 { 00047 } 00048 00049 private: 00050 00051 /** Progress bar for displaying the hours as a percentage. */ 00052 tprogress_bar* hour_percentage_; 00053 00054 /** Progress bar for displaying the minutes as a percentage. */ 00055 tprogress_bar* minute_percentage_; 00056 00057 /** Progress bar for displaying the seconds as a percentage. */ 00058 tprogress_bar* second_percentage_; 00059 00060 /** An integer selector to display the total seconds. */ 00061 tinteger_selector_* hour_; 00062 00063 /** An integer selector to display the total seconds this hour. */ 00064 tinteger_selector_* minute_; 00065 00066 /** An integer selector to display the seconds this minute. */ 00067 tinteger_selector_* second_; 00068 00069 /** A widget that can display the time. */ 00070 tcontrol* clock_; 00071 00072 /** The window being shown. */ 00073 twindow* window_; 00074 00075 /** The signal patched in the drawing routine. */ 00076 event::tsignal_function signal_; 00077 00078 /** Helper struct to keep track of the time. */ 00079 struct ttime 00080 { 00081 ttime(); 00082 00083 /** 00084 * Sets the fields to the current time. 00085 * 00086 * @note The milliseconds aren't queried and set to zero. 00087 */ 00088 void set_current_time(); 00089 00090 /** 00091 * Moves the clock x milliseconds forward. 00092 * 00093 * @note The default value of @p milliseconds is the same as the 00094 * interval for the drawing routine. 00095 * 00096 * @pre @p milliseconds < 1000. 00097 * 00098 * @param milliseconds The number of milliseconds to move ahead. 00099 * 00100 * @returns Did the number of seconds alter? 00101 */ 00102 bool step(const unsigned milliseconds = 30); 00103 00104 /** The number of hours. */ 00105 unsigned hour; 00106 00107 /** The number of minutes. */ 00108 unsigned minute; 00109 00110 /** The number of seconds. */ 00111 unsigned second; 00112 00113 /** The number of milliseconds. */ 00114 unsigned millisecond; 00115 }; 00116 00117 /** 00118 * The `current' time. 00119 * 00120 * @note Since the dialog is used to test the drawing routine by keeping 00121 * track of the calls to the drawing routine, the clock might be off. 00122 */ 00123 ttime time_; 00124 00125 /** Inherited from tdialog, implemented by REGISTER_DIALOG. */ 00126 virtual const std::string& window_id() const; 00127 00128 /** Inherited from tdialog. */ 00129 void pre_show(CVideo& video, twindow& window); 00130 00131 /** Inherited from tdialog. */ 00132 void post_show(CVideo& video); 00133 00134 /** 00135 * The callback for the drawing routine. 00136 * 00137 * It updates the `time' in the various controls. 00138 * 00139 * @param force Force an update even it the time didn't 00140 * change? (This is used to set the clock 00141 * initially.) 00142 */ 00143 void update_time(const bool force); 00144 }; 00145 00146 } // namespace gui2 00147 00148 #endif 00149
| Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:42 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |