// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// (c) 1999 Guillermo Rodriguez <guille@iies.es>
-// Licence: wxWindows license
+// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
#include <sys/timeb.h>
#endif
+// ----------------------------------------------------------------------------
+// wxWin macros
+// ----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent, wxEvent)
+
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
#endif
#endif // HAVE_GETTIMEOFDAY
+// ----------------------------------------------------------------------------
+// prototypes
+// ----------------------------------------------------------------------------
+
+wxLongLong wxGetLocalTimeMillis();
+
// ============================================================================
// implementation
// ============================================================================
-wxLongLong wxGetLocalTimeMillis();
+// ----------------------------------------------------------------------------
+// wxTimerBase
+// ----------------------------------------------------------------------------
+
+void wxTimerBase::Notify()
+{
+ // the base class version generates an event if it has owner - which it
+ // should because otherwise nobody can process timer events
+ wxCHECK_RET( m_owner, _T("wxTimer::Notify() should be overridden.") );
+
+ wxTimerEvent event(m_idTimer, m_milli);
+ (void)m_owner->ProcessEvent(event);
+}
// ----------------------------------------------------------------------------
// wxStopWatch
m_pause = 0;
}
-long wxStopWatch::Time() const
+long wxStopWatch::GetElapsedTime() const
{
- return (m_pause ? m_pause : GetElapsedTime());
+ return (wxGetLocalTimeMillis() - m_t0).GetLo();
}
-long wxStopWatch::GetElapsedTime() const
+long wxStopWatch::Time() const
{
- return (wxGetLocalTimeMillis() - m_t0).GetLo();
+ return (m_pause ? m_pause : GetElapsedTime());
}
// ----------------------------------------------------------------------------
// old timer functions superceded by wxStopWatch
// ----------------------------------------------------------------------------
-static wxLongLong wxStartTime = 0;
+static wxLongLong wxStartTime = 0l;
// starts the global timer
void wxStartTimer()
// 00:00:00 Jan 1st 1970 and then whatever is available
// to get millisecond resolution.
//
- wxLongLong val = 1000 * wxGetLocalTime();
+ wxLongLong val = 1000l;
+ val *= wxGetLocalTime();
// If we got here, do not fail even if we can't get
// millisecond resolution.
SYSTEMTIME st;
::GetLocalTime(&st);
return (val + st.wMilliseconds);
+#elif defined(__VISAGECPP__)
+ DATETIME dt;
+ ::DosGetDateTime(&dt);
+ return (val + dt.hundredths*10);
#elif defined(HAVE_GETTIMEOFDAY)
struct timeval tp;
if ( wxGetTimeOfDay(&tp, (struct timezone *)NULL) != -1 )
{
return (val + tp.millitm);
}
+#else
+#if !defined(__BORLANDC__) && !(defined(__VISUALC__) && defined(__WIN16__))
+ #warning "wxStopWatch will be up to second resolution!"
+#endif
#endif
return val;