]>
git.saurik.com Git - wxWidgets.git/blob - src/common/timerimpl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/timerimpl.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"
30 #include "wx/private/timer.h"
31 #include "wx/utils.h" // for wxNewId()
32 #include "wx/thread.h"
34 wxTimerImpl::wxTimerImpl(wxTimer
*timer
)
43 void wxTimerImpl::SetOwner(wxEvtHandler
*owner
, int timerid
)
46 m_idTimer
= timerid
== wxID_ANY
? wxNewId() : timerid
;
49 void wxTimerImpl::SendEvent()
51 wxTimerEvent
event(*m_timer
);
52 (void)m_owner
->SafelyProcessEvent(event
);
55 bool wxTimerImpl::Start(int milliseconds
, bool oneShot
)
57 // under MSW timers only work when they're started from the main thread so
58 // let the caller know about it
60 wxASSERT_MSG( wxThread::IsMain(),
61 wxT("timer can only be started from the main thread") );
62 #endif // wxUSE_THREADS
66 // not stopping the already running timer might work for some
67 // platforms (no problems under MSW) but leads to mysterious crashes
68 // on the others (GTK), so to be on the safe side do it here
72 if ( milliseconds
!= -1 )
74 m_milli
= milliseconds
;