]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/timercmn.cpp
fix typo in r57455 which totally broke modal dialogs display (close #10291)
[wxWidgets.git] / src / common / timercmn.cpp
... / ...
CommitLineData
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)
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// (c) 1999 Guillermo Rodriguez <guille@iies.es>
10// Licence: wxWindows licence
11/////////////////////////////////////////////////////////////////////////////
12
13// ============================================================================
14// declarations
15// ============================================================================
16
17// ----------------------------------------------------------------------------
18// wxWin headers
19// ----------------------------------------------------------------------------
20
21// For compilers that support precompilation, includes "wx.h".
22#include "wx/wxprec.h"
23
24#ifdef __BORLANDC__
25 #pragma hdrstop
26#endif
27
28#if wxUSE_TIMER
29
30#ifndef WX_PRECOMP
31 #include "wx/app.h"
32#endif
33
34#include "wx/timer.h"
35#include "wx/apptrait.h"
36#include "wx/private/timer.h"
37
38// ----------------------------------------------------------------------------
39// wxWin macros
40// ----------------------------------------------------------------------------
41
42IMPLEMENT_ABSTRACT_CLASS(wxTimerEvent, wxEvent)
43
44// ============================================================================
45// wxTimerBase implementation
46// ============================================================================
47
48wxTimer::~wxTimer()
49{
50 Stop();
51
52 delete m_impl;
53}
54
55void wxTimer::Init()
56{
57 wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
58 m_impl = traits ? traits->CreateTimerImpl(this) : NULL;
59 if ( !m_impl )
60 {
61 wxFAIL_MSG( _T("No timer implementation for this platform") );
62
63 }
64}
65
66// ============================================================================
67// rest of wxTimer implementation forwarded to wxTimerImpl
68// ============================================================================
69
70void wxTimer::SetOwner(wxEvtHandler *owner, int timerid)
71{
72 wxCHECK_RET( m_impl, _T("uninitialized timer") );
73
74 m_impl->SetOwner(owner, timerid);
75}
76
77wxEvtHandler *wxTimer::GetOwner() const
78{
79 wxCHECK_MSG( m_impl, NULL, _T("uninitialized timer") );
80
81 return m_impl->GetOwner();
82}
83
84bool wxTimer::Start(int milliseconds, bool oneShot)
85{
86 wxCHECK_MSG( m_impl, false, _T("uninitialized timer") );
87
88 return m_impl->Start(milliseconds, oneShot);
89}
90
91void wxTimer::Stop()
92{
93 wxCHECK_RET( m_impl, _T("uninitialized timer") );
94
95 if ( m_impl->IsRunning() )
96 m_impl->Stop();
97}
98
99void wxTimer::Notify()
100{
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.") );
104
105 m_impl->SendEvent();
106}
107
108bool wxTimer::IsRunning() const
109{
110 wxCHECK_MSG( m_impl, false, _T("uninitialized timer") );
111
112 return m_impl->IsRunning();
113}
114
115int wxTimer::GetId() const
116{
117 wxCHECK_MSG( m_impl, wxID_ANY, _T("uninitialized timer") );
118
119 return m_impl->GetId();
120}
121
122int wxTimer::GetInterval() const
123{
124 wxCHECK_MSG( m_impl, -1, _T("uninitialized timer") );
125
126 return m_impl->GetInterval();
127}
128
129bool wxTimer::IsOneShot() const
130{
131 wxCHECK_MSG( m_impl, false, _T("uninitialized timer") );
132
133 return m_impl->IsOneShot();
134}
135
136#endif // wxUSE_TIMER
137