timercmn rewritten from scratch

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5009 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guillermo Rodriguez Garcia
1999-12-17 01:28:44 +00:00
parent b8f0499040
commit d895ad7c54

View File

@@ -16,7 +16,9 @@
#pragma interface "timerbase.h" #pragma interface "timerbase.h"
#endif #endif
#include "wx/setup.h"
#include "wx/object.h" #include "wx/object.h"
#include "wx/longlong.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTimer // wxTimer
@@ -99,62 +101,44 @@ class WXDLLEXPORT wxStopWatch
{ {
public: public:
// ctor starts the stop watch // ctor starts the stop watch
wxStopWatch() { Start(); } wxStopWatch() { Start(); }
void Start(long t = 0);
inline void Pause() { m_pause = GetElapsedTime(); }
inline void Resume() { Start(m_pause); }
void Start(long t = 0); // (re)start it t milliseconds ago // get elapsed time since the last Start() or Pause() in milliseconds
inline void Pause();
void Resume() { Start(m_pause); }
// get the elapsed time since the last Start() or Pause() in milliseconds
long Time() const; long Time() const;
protected: protected:
// returns the elapsed time since t0 // returns the elapsed time since t0
inline long GetElapsedTime() const; long GetElapsedTime() const;
private: private:
long m_t0; // the time of the last Start() wxLongLong m_t0; // the time of the last Start()
long m_pause; // the time of the last Pause() or 0 long m_pause; // the time of the last Pause() or 0
}; };
// the old name
#ifdef WXWIN_COMPATIBILITY_2 // Starts a global timer
typedef wxStopWatch wxChrono; // -- DEPRECATED: use wxStopWatch instead
#endif // WXWIN_COMPATIBILITY_2 void WXDLLEXPORT wxStartTimer();
// Gets elapsed milliseconds since last wxStartTimer or wxGetElapsedTime
// -- DEPRECATED: use wxStopWatch instead
long WXDLLEXPORT wxGetElapsedTime(bool resetTimer = TRUE);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global time functions // global time functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Timer functions (milliseconds) -- use wxStopWatch instead // Get number of seconds since local time 00:00:00 Jan 1st 1970.
void WXDLLEXPORT wxStartTimer(); long WXDLLEXPORT wxGetLocalTime();
// Gets time since last wxStartTimer or wxGetElapsedTime -- use wxStopWatch // Get number of seconds since GMT 00:00:00, Jan 1st 1970.
// instead long WXDLLEXPORT wxGetUTCTime();
long WXDLLEXPORT wxGetElapsedTime(bool resetTimer = TRUE);
// Get the local time
bool WXDLLEXPORT wxGetLocalTime(long *timeZone, int *dstObserved);
// Get number of seconds since 00:00:00 GMT, Jan 1st 1970.
long WXDLLEXPORT wxGetCurrentTime();
// Get number of milliseconds since 00:00:00 GMT, Jan 1st 1970.
long WXDLLEXPORT wxGetCurrentMTime();
// ----------------------------------------------------------------------------
// inline functions
// ----------------------------------------------------------------------------
inline long wxStopWatch::GetElapsedTime() const
{
return wxGetCurrentMTime() - m_t0;
}
inline void wxStopWatch::Pause()
{
m_pause = GetElapsedTime();
}
#endif #endif
// _WX_TIMER_H_BASE_ // _WX_TIMER_H_BASE_