]> git.saurik.com Git - wxWidgets.git/blame - include/wx/timer.h
optimized wxHtmlContainerCell - now proceeds layouting only when neccessary (will...
[wxWidgets.git] / include / wx / timer.h
CommitLineData
0470b1e6
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/timer.h
3// Purpose: wxTimer class and global time-related functions
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_TIMER_H_BASE_
13#define _WX_TIMER_H_BASE_
c801d85f 14
0470b1e6
VZ
15#ifdef __GNUG__
16 #pragma interface "timerbase.h"
17#endif
18
d895ad7c 19#include "wx/setup.h"
0470b1e6 20#include "wx/object.h"
d895ad7c 21#include "wx/longlong.h"
0470b1e6
VZ
22
23// ----------------------------------------------------------------------------
24// wxTimer
25// ----------------------------------------------------------------------------
26
27// the interface of wxTimer class
28class WXDLLEXPORT wxTimerBase : public wxObject
29{
30public:
31 wxTimerBase() { m_oneShot = FALSE; m_milli = 0; }
32
33 // working with the timer
34 // ----------------------
35
36 // start the timer: if milliseconds == -1, use the same value as for the
37 // last Start()
38 virtual bool Start(int milliseconds = -1, bool oneShot = FALSE)
39 {
40 if ( milliseconds != -1 )
41 {
42 m_milli = milliseconds;
43 }
44
45 m_oneShot = oneShot;
46
47 return TRUE;
48 }
49
50
51 // stop the timer
52 virtual void Stop() = 0;
53
54 // override this in your wxTimer-derived class
55 virtual void Notify() = 0;
56
57 // getting info
58 // ------------
59
60 // return TRUE if the timer is running
61 virtual bool IsRunning() const = 0;
62
63 // get the (last) timer interval in the milliseconds
64 int GetInterval() const { return m_milli; }
65
66 // return TRUE if the timer is one shot
67 bool IsOneShot() const { return m_oneShot; }
68
69#if WXWIN_COMPATIBILITY_2
70 // deprecated functions
71 int Interval() const { return GetInterval(); };
72 bool OneShot() const { return IsOneShot(); }
73#endif // WXWIN_COMPATIBILITY_2
74
75protected:
76 int m_milli; // the timer interval
77 bool m_oneShot; // TRUE if one shot
78};
79
2049ba38 80#if defined(__WXMSW__)
0470b1e6 81 #include "wx/msw/timer.h"
2049ba38 82#elif defined(__WXMOTIF__)
0470b1e6 83 #include "wx/motif/timer.h"
2049ba38 84#elif defined(__WXGTK__)
0470b1e6 85 #include "wx/gtk/timer.h"
b4e76e0d 86#elif defined(__WXQT__)
0470b1e6 87 #include "wx/qt/timer.h"
34138703 88#elif defined(__WXMAC__)
0470b1e6 89 #include "wx/mac/timer.h"
1777b9bb 90#elif defined(__WXPM__)
0470b1e6 91 #include "wx/os2/timer.h"
34138703 92#elif defined(__WXSTUBS__)
0470b1e6 93 #include "wx/stubs/timer.h"
c801d85f
KB
94#endif
95
0470b1e6
VZ
96// ----------------------------------------------------------------------------
97// wxStopWatch
98// ----------------------------------------------------------------------------
99
100class WXDLLEXPORT wxStopWatch
f0599ea9
SB
101{
102public:
0470b1e6 103 // ctor starts the stop watch
d895ad7c
GRG
104 wxStopWatch() { Start(); }
105 void Start(long t = 0);
106 inline void Pause() { m_pause = GetElapsedTime(); }
107 inline void Resume() { Start(m_pause); }
0470b1e6 108
d895ad7c 109 // get elapsed time since the last Start() or Pause() in milliseconds
0470b1e6 110 long Time() const;
f0599ea9 111
0470b1e6
VZ
112protected:
113 // returns the elapsed time since t0
d895ad7c 114 long GetElapsedTime() const;
0470b1e6 115
f0599ea9 116private:
d895ad7c
GRG
117 wxLongLong m_t0; // the time of the last Start()
118 long m_pause; // the time of the last Pause() or 0
f0599ea9
SB
119};
120
0470b1e6 121
d895ad7c
GRG
122// Starts a global timer
123// -- DEPRECATED: use wxStopWatch instead
f0599ea9
SB
124void WXDLLEXPORT wxStartTimer();
125
d895ad7c
GRG
126// Gets elapsed milliseconds since last wxStartTimer or wxGetElapsedTime
127// -- DEPRECATED: use wxStopWatch instead
f0599ea9
SB
128long WXDLLEXPORT wxGetElapsedTime(bool resetTimer = TRUE);
129
f0599ea9 130
0470b1e6 131// ----------------------------------------------------------------------------
d895ad7c 132// global time functions
0470b1e6
VZ
133// ----------------------------------------------------------------------------
134
d895ad7c
GRG
135// Get number of seconds since local time 00:00:00 Jan 1st 1970.
136long WXDLLEXPORT wxGetLocalTime();
137
138// Get number of seconds since GMT 00:00:00, Jan 1st 1970.
139long WXDLLEXPORT wxGetUTCTime();
140
df0c3226 141#define wxGetCurrentTime() wxGetLocalTime()
0470b1e6 142
c801d85f 143#endif
34138703 144 // _WX_TIMER_H_BASE_