]> git.saurik.com Git - wxWidgets.git/blame - include/wx/stopwatch.h
Moved Clear() implementation into wxDC using a new virtual CocoaGetBounds()
[wxWidgets.git] / include / wx / stopwatch.h
CommitLineData
5fb98c22
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/stopwatch.h
3// Purpose: wxStopWatch and global time-related functions
4// Author: Julian Smart (wxTimer), Sylvain Bougnoux (wxStopWatch)
5// Created: 26.06.03 (extracted from wx/timer.h)
6// RCS-ID: $Id$
77ffb593 7// Copyright: (c) 1998-2003 wxWidgets team
65571936 8// Licence: wxWindows licence
5fb98c22
VZ
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_STOPWATCH_H_
12#define _WX_STOPWATCH_H_
d5b12ad9
VS
13
14#include "wx/longlong.h"
15
5fb98c22
VZ
16// ----------------------------------------------------------------------------
17// wxStopWatch: measure time intervals with up to 1ms resolution
18// ----------------------------------------------------------------------------
19
20#if wxUSE_STOPWATCH
21
bddd7a8d 22class WXDLLIMPEXP_BASE wxStopWatch
5fb98c22
VZ
23{
24public:
25 // ctor starts the stop watch
26 wxStopWatch() { m_pauseCount = 0; Start(); }
27
28 // start the stop watch at the moment t0
29 void Start(long t0 = 0);
30
31 // pause the stop watch
32 void Pause()
33 {
34 if ( !m_pauseCount++ )
35 m_pause = GetElapsedTime();
36 }
37
38 // resume it
39 void Resume()
40 {
41 wxASSERT_MSG( m_pauseCount > 0,
42 _T("Resuming stop watch which is not paused") );
43
44 if ( !--m_pauseCount )
45 Start(m_pause);
46 }
47
48 // get elapsed time since the last Start() in milliseconds
49 long Time() const;
50
51protected:
52 // returns the elapsed time since t0
53 long GetElapsedTime() const;
54
55private:
56 // the time of the last Start()
57 wxLongLong m_t0;
58
59 // the time of the last Pause() (only valid if m_pauseCount > 0)
60 long m_pause;
61
62 // if > 0, the stop watch is paused, otherwise it is running
63 int m_pauseCount;
64};
65
66#endif // wxUSE_STOPWATCH
67
68#if wxUSE_LONGLONG
69
70// Starts a global timer
71// -- DEPRECATED: use wxStopWatch instead
bddd7a8d 72void WXDLLIMPEXP_BASE wxStartTimer();
5fb98c22
VZ
73
74// Gets elapsed milliseconds since last wxStartTimer or wxGetElapsedTime
75// -- DEPRECATED: use wxStopWatch instead
d775fa82 76long WXDLLIMPEXP_BASE wxGetElapsedTime(bool resetTimer = true);
5fb98c22
VZ
77
78#endif // wxUSE_LONGLONG
79
80// ----------------------------------------------------------------------------
81// global time functions
82// ----------------------------------------------------------------------------
83
84// Get number of seconds since local time 00:00:00 Jan 1st 1970.
bddd7a8d 85extern long WXDLLIMPEXP_BASE wxGetLocalTime();
5fb98c22
VZ
86
87// Get number of seconds since GMT 00:00:00, Jan 1st 1970.
bddd7a8d 88extern long WXDLLIMPEXP_BASE wxGetUTCTime();
5fb98c22
VZ
89
90#if wxUSE_LONGLONG
91// Get number of milliseconds since local time 00:00:00 Jan 1st 1970
bddd7a8d 92extern wxLongLong WXDLLIMPEXP_BASE wxGetLocalTimeMillis();
5fb98c22
VZ
93#endif // wxUSE_LONGLONG
94
95#define wxGetCurrentTime() wxGetLocalTime()
96
97#endif // _WX_STOPWATCH_H_
98