The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
debug_clock.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef GUI_DIALOGS_DEBUG_CLOCK_HPP_INCLUDED
16 #define GUI_DIALOGS_DEBUG_CLOCK_HPP_INCLUDED
17 
18 #include "gui/dialogs/popup.hpp"
19 
21 
22 namespace gui2
23 {
24 
25 class tcontrol;
26 class tpane;
27 class tprogress_bar;
28 class tinteger_selector_;
29 
30 /** Clock to test the draw events. */
31 class tdebug_clock : public tpopup
32 {
33 public:
35  : tpopup()
36  , hour_percentage_(nullptr)
37  , minute_percentage_(nullptr)
38  , second_percentage_(nullptr)
39  , hour_(nullptr)
40  , minute_(nullptr)
41  , second_(nullptr)
42  , pane_(nullptr)
43  , clock_(nullptr)
44  , window_(nullptr)
45  , signal_()
46  , time_()
47  {
48  }
49 
50 private:
51  /** Progress bar for displaying the hours as a percentage. */
53 
54  /** Progress bar for displaying the minutes as a percentage. */
56 
57  /** Progress bar for displaying the seconds as a percentage. */
59 
60  /** An integer selector to display the total seconds. */
62 
63  /** An integer selector to display the total seconds this hour. */
65 
66  /** An integer selector to display the seconds this minute. */
68 
70 
71  /** A widget that can display the time. */
73 
74  /** The window being shown. */
76 
77  /** The signal patched in the drawing routine. */
79 
80  /** Helper struct to keep track of the time. */
81  struct ttime
82  {
83  ttime();
84 
85  /**
86  * Sets the fields to the current time.
87  *
88  * @note The milliseconds aren't queried and set to zero.
89  */
90  void set_current_time();
91 
92  /**
93  * Moves the clock x milliseconds forward.
94  *
95  * @note The default value of @p milliseconds is the same as the
96  * interval for the drawing routine.
97  *
98  * @pre @p milliseconds < 1000.
99  *
100  * @param milliseconds The number of milliseconds to move ahead.
101  *
102  * @returns Did the number of seconds alter?
103  */
104  bool step(const unsigned milliseconds = 30);
105 
106  /** The number of hours. */
107  unsigned hour;
108 
109  /** The number of minutes. */
110  unsigned minute;
111 
112  /** The number of seconds. */
113  unsigned second;
114 
115  /** The number of milliseconds. */
116  unsigned millisecond;
117  };
118 
119  /**
120  * The `current' time.
121  *
122  * @note Since the dialog is used to test the drawing routine by keeping
123  * track of the calls to the drawing routine, the clock might be off.
124  */
126 
127  /** Inherited from tdialog, implemented by REGISTER_DIALOG. */
128  virtual const std::string& window_id() const;
129 
130  /** Inherited from tdialog. */
131  void pre_show(twindow& window);
132 
133  /** Inherited from tdialog. */
134  void post_show(CVideo& video);
135 
136  /**
137  * The callback for the drawing routine.
138  *
139  * It updates the `time' in the various controls.
140  *
141  * @param force Force an update even it the time didn't
142  * change? (This is used to set the clock
143  * initially.)
144  */
145  void update_time(const bool force);
146 };
147 
148 } // namespace gui2
149 
150 #endif
tcontrol * clock_
A widget that can display the time.
Definition: debug_clock.hpp:72
void post_show(CVideo &video)
Inherited from tdialog.
tprogress_bar * second_percentage_
Progress bar for displaying the seconds as a percentage.
Definition: debug_clock.hpp:58
Small abstract helper class.
virtual const std::string & window_id() const
Inherited from tdialog, implemented by REGISTER_DIALOG.
Definition: video.hpp:58
Clock to test the draw events.
Definition: debug_clock.hpp:31
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
unsigned minute
The number of minutes.
Helper struct to keep track of the time.
Definition: debug_clock.hpp:81
twindow * window_
The window being shown.
Definition: debug_clock.hpp:75
void update_time(const bool force)
The callback for the drawing routine.
void set_current_time()
Sets the fields to the current time.
The popup class shows windows that are shown non-modal.
Definition: popup.hpp:33
bool step(const unsigned milliseconds=30)
Moves the clock x milliseconds forward.
std::function< void(tdispatcher &dispatcher, const tevent event, bool &handled, bool &halt)> tsignal_function
Callback function signature.
Definition: dispatcher.hpp:40
tinteger_selector_ * hour_
An integer selector to display the total seconds.
Definition: debug_clock.hpp:61
tinteger_selector_ * second_
An integer selector to display the seconds this minute.
Definition: debug_clock.hpp:67
tinteger_selector_ * minute_
An integer selector to display the total seconds this hour.
Definition: debug_clock.hpp:64
unsigned millisecond
The number of milliseconds.
tprogress_bar * minute_percentage_
Progress bar for displaying the minutes as a percentage.
Definition: debug_clock.hpp:55
unsigned hour
The number of hours.
unsigned second
The number of seconds.
ttime time_
The `current' time.
void pre_show(twindow &window)
Inherited from tdialog.
Definition: debug_clock.cpp:78
Base class for all visible items.
Definition: control.hpp:34
GLsizei const GLcharARB ** string
Definition: glew.h:4503
tprogress_bar * hour_percentage_
Progress bar for displaying the hours as a percentage.
Definition: debug_clock.hpp:52
event::tsignal_function signal_
The signal patched in the drawing routine.
Definition: debug_clock.hpp:78