]>
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 // For compilers that support precompilation, includes "wx.h".
22 #include "wx/wxprec.h"
34 // ----------------------------------------------------------------------------
36 // ----------------------------------------------------------------------------
38 IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent
, wxEvent
)
40 // ============================================================================
41 // wxTimerBase implementation
42 // ============================================================================
44 wxTimerBase::~wxTimerBase()
46 // this destructor is required for Darwin
49 void wxTimerBase::Notify()
51 // the base class version generates an event if it has owner - which it
52 // should because otherwise nobody can process timer events
53 wxCHECK_RET( m_owner
, _T("wxTimer::Notify() should be overridden.") );
55 wxTimerEvent
event(m_idTimer
, m_milli
);
56 event
.SetEventObject(this);
57 (void)m_owner
->ProcessEvent(event
);
60 bool wxTimerBase::Start(int milliseconds
, bool oneShot
)
62 // under MSW timers only work when they're started from the main thread so
63 // let the caller know about it
65 wxASSERT_MSG( wxThread::IsMain(),
66 _T("timer can only be started from the main thread") );
67 #endif // wxUSE_THREADS
71 // not stopping the already running timer might work for some
72 // platforms (no problems under MSW) but leads to mysterious crashes
73 // on the others (GTK), so to be on the safe side do it here
77 if ( milliseconds
!= -1 )
79 m_milli
= milliseconds
;