]>
git.saurik.com Git - wxWidgets.git/blob - src/common/timercmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/timercmn.cpp
3 // Purpose: wxTimerBase implementation
4 // Author: Julian Smart, Guillermo Rodriguez, Vadim Zeitlin
5 // Modified by: VZ: extracted all non-wxTimer stuff in stopwatch.cpp (20.06.03)
8 // Copyright: (c) Julian Smart
9 // (c) 1999 Guillermo Rodriguez <guille@iies.es>
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 // ============================================================================
15 // ============================================================================
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
21 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
22 #pragma implementation "timerbase.h"
25 // For compilers that support precompilation, includes "wx.h".
26 #include "wx/wxprec.h"
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent
, wxEvent
)
44 // ============================================================================
45 // wxTimerBase implementation
46 // ============================================================================
48 wxTimerBase::~wxTimerBase()
50 // this destructor is required for Darwin
53 void wxTimerBase::Notify()
55 // the base class version generates an event if it has owner - which it
56 // should because otherwise nobody can process timer events
57 wxCHECK_RET( m_owner
, _T("wxTimer::Notify() should be overridden.") );
59 wxTimerEvent
event(m_idTimer
, m_milli
);
60 event
.SetEventObject(this);
61 (void)m_owner
->ProcessEvent(event
);
64 bool wxTimerBase::Start(int milliseconds
, bool oneShot
)
66 // under MSW timers only work when they're started from the main thread so
67 // let the caller know about it
69 wxASSERT_MSG( wxThread::IsMain(),
70 _T("timer can only be started from the main thread") );
71 #endif // wxUSE_THREADS
75 // not stopping the already running timer might work for some
76 // platforms (no problems under MSW) but leads to mysterious crashes
77 // on the others (GTK), so to be on the safe side do it here
81 if ( milliseconds
!= -1 )
83 m_milli
= milliseconds
;