]>
git.saurik.com Git - wxWidgets.git/blob - src/common/timercmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/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)
7 // Copyright: (c) Julian Smart
8 // (c) 1999 Guillermo Rodriguez <guille@iies.es>
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
34 #include "wx/apptrait.h"
35 #include "wx/private/timer.h"
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent
, wxEvent
)
43 wxDEFINE_EVENT(wxEVT_TIMER
, wxTimerEvent
);
45 // ============================================================================
46 // wxTimerBase implementation
47 // ============================================================================
58 wxAppTraits
* const traits
= wxTheApp
? wxTheApp
->GetTraits() : NULL
;
59 m_impl
= traits
? traits
->CreateTimerImpl(this) : NULL
;
62 wxFAIL_MSG( wxT("No timer implementation for this platform") );
67 // ============================================================================
68 // rest of wxTimer implementation forwarded to wxTimerImpl
69 // ============================================================================
71 void wxTimer::SetOwner(wxEvtHandler
*owner
, int timerid
)
73 wxCHECK_RET( m_impl
, wxT("uninitialized timer") );
75 m_impl
->SetOwner(owner
, timerid
);
78 wxEvtHandler
*wxTimer::GetOwner() const
80 wxCHECK_MSG( m_impl
, NULL
, wxT("uninitialized timer") );
82 return m_impl
->GetOwner();
85 bool wxTimer::Start(int milliseconds
, bool oneShot
)
87 wxCHECK_MSG( m_impl
, false, wxT("uninitialized timer") );
89 return m_impl
->Start(milliseconds
, oneShot
);
94 wxCHECK_RET( m_impl
, wxT("uninitialized timer") );
96 if ( m_impl
->IsRunning() )
100 void wxTimer::Notify()
102 // the base class version generates an event if it has owner - which it
103 // should because otherwise nobody can process timer events
104 wxCHECK_RET( GetOwner(), wxT("wxTimer::Notify() should be overridden.") );
109 bool wxTimer::IsRunning() const
111 wxCHECK_MSG( m_impl
, false, wxT("uninitialized timer") );
113 return m_impl
->IsRunning();
116 int wxTimer::GetId() const
118 wxCHECK_MSG( m_impl
, wxID_ANY
, wxT("uninitialized timer") );
120 return m_impl
->GetId();
123 int wxTimer::GetInterval() const
125 wxCHECK_MSG( m_impl
, -1, wxT("uninitialized timer") );
127 return m_impl
->GetInterval();
130 bool wxTimer::IsOneShot() const
132 wxCHECK_MSG( m_impl
, false, wxT("uninitialized timer") );
134 return m_impl
->IsOneShot();
137 #endif // wxUSE_TIMER