]>
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_DYNAMIC_CLASS(wxTimerEvent
, wxEvent
)
44 wxDEFINE_EVENT(wxEVT_TIMER
, wxTimerEvent
);
46 // ============================================================================
47 // wxTimerBase implementation
48 // ============================================================================
59 wxAppTraits
* const traits
= wxTheApp
? wxTheApp
->GetTraits() : NULL
;
60 m_impl
= traits
? traits
->CreateTimerImpl(this) : NULL
;
63 wxFAIL_MSG( wxT("No timer implementation for this platform") );
68 // ============================================================================
69 // rest of wxTimer implementation forwarded to wxTimerImpl
70 // ============================================================================
72 void wxTimer::SetOwner(wxEvtHandler
*owner
, int timerid
)
74 wxCHECK_RET( m_impl
, wxT("uninitialized timer") );
76 m_impl
->SetOwner(owner
, timerid
);
79 wxEvtHandler
*wxTimer::GetOwner() const
81 wxCHECK_MSG( m_impl
, NULL
, wxT("uninitialized timer") );
83 return m_impl
->GetOwner();
86 bool wxTimer::Start(int milliseconds
, bool oneShot
)
88 wxCHECK_MSG( m_impl
, false, wxT("uninitialized timer") );
90 return m_impl
->Start(milliseconds
, oneShot
);
95 wxCHECK_RET( m_impl
, wxT("uninitialized timer") );
97 if ( m_impl
->IsRunning() )
101 void wxTimer::Notify()
103 // the base class version generates an event if it has owner - which it
104 // should because otherwise nobody can process timer events
105 wxCHECK_RET( GetOwner(), wxT("wxTimer::Notify() should be overridden.") );
110 bool wxTimer::IsRunning() const
112 wxCHECK_MSG( m_impl
, false, wxT("uninitialized timer") );
114 return m_impl
->IsRunning();
117 int wxTimer::GetId() const
119 wxCHECK_MSG( m_impl
, wxID_ANY
, wxT("uninitialized timer") );
121 return m_impl
->GetId();
124 int wxTimer::GetInterval() const
126 wxCHECK_MSG( m_impl
, -1, wxT("uninitialized timer") );
128 return m_impl
->GetInterval();
131 bool wxTimer::IsOneShot() const
133 wxCHECK_MSG( m_impl
, false, wxT("uninitialized timer") );
135 return m_impl
->IsOneShot();
138 #endif // wxUSE_TIMER