]>
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"
35 #include "wx/apptrait.h"
36 #include "wx/private/timer.h"
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 IMPLEMENT_ABSTRACT_CLASS(wxTimerEvent
, wxEvent
)
44 // ============================================================================
45 // wxTimerBase implementation
46 // ============================================================================
57 wxAppTraits
* const traits
= wxTheApp
? wxTheApp
->GetTraits() : NULL
;
58 m_impl
= traits
? traits
->CreateTimerImpl(this) : NULL
;
61 wxFAIL_MSG( _T("No timer implementation for this platform") );
66 // ============================================================================
67 // rest of wxTimer implementation forwarded to wxTimerImpl
68 // ============================================================================
70 void wxTimer::SetOwner(wxEvtHandler
*owner
, int timerid
)
72 wxCHECK_RET( m_impl
, _T("uninitialized timer") );
74 m_impl
->SetOwner(owner
, timerid
);
77 wxEvtHandler
*wxTimer::GetOwner() const
79 wxCHECK_MSG( m_impl
, NULL
, _T("uninitialized timer") );
81 return m_impl
->GetOwner();
84 bool wxTimer::Start(int milliseconds
, bool oneShot
)
86 wxCHECK_MSG( m_impl
, false, _T("uninitialized timer") );
88 return m_impl
->Start(milliseconds
, oneShot
);
93 wxCHECK_RET( m_impl
, _T("uninitialized timer") );
95 if ( m_impl
->IsRunning() )
99 void wxTimer::Notify()
101 // the base class version generates an event if it has owner - which it
102 // should because otherwise nobody can process timer events
103 wxCHECK_RET( GetOwner(), _T("wxTimer::Notify() should be overridden.") );
108 bool wxTimer::IsRunning() const
110 wxCHECK_MSG( m_impl
, false, _T("uninitialized timer") );
112 return m_impl
->IsRunning();
115 int wxTimer::GetId() const
117 wxCHECK_MSG( m_impl
, wxID_ANY
, _T("uninitialized timer") );
119 return m_impl
->GetId();
122 int wxTimer::GetInterval() const
124 wxCHECK_MSG( m_impl
, -1, _T("uninitialized timer") );
126 return m_impl
->GetInterval();
129 bool wxTimer::IsOneShot() const
131 wxCHECK_MSG( m_impl
, false, _T("uninitialized timer") );
133 return m_impl
->IsOneShot();
136 #endif // wxUSE_TIMER