]> git.saurik.com Git - wxWidgets.git/blame - src/common/timercmn.cpp
Added mouse event handler invocations
[wxWidgets.git] / src / common / timercmn.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
0470b1e6 2// Name: common/timercmn.cpp
e2478fde
VZ
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)
c801d85f
KB
6// Created: 04/01/98
7// RCS-ID: $Id$
55d99c7a 8// Copyright: (c) Julian Smart
b704229e 9// (c) 1999 Guillermo Rodriguez <guille@iies.es>
65571936 10// Licence: wxWindows licence
c801d85f
KB
11/////////////////////////////////////////////////////////////////////////////
12
0470b1e6
VZ
13// ============================================================================
14// declarations
15// ============================================================================
16
17// ----------------------------------------------------------------------------
91ff98b7 18// wxWin headers
0470b1e6
VZ
19// ----------------------------------------------------------------------------
20
c801d85f
KB
21// For compilers that support precompilation, includes "wx.h".
22#include "wx/wxprec.h"
23
24#ifdef __BORLANDC__
0470b1e6 25 #pragma hdrstop
c801d85f
KB
26#endif
27
e2478fde 28#if wxUSE_TIMER
07cf98cb 29
e2478fde 30#ifndef WX_PRECOMP
46446cc2 31 #include "wx/timer.h"
c801d85f
KB
32#endif
33
ed791986
VZ
34// ----------------------------------------------------------------------------
35// wxWin macros
36// ----------------------------------------------------------------------------
37
e2478fde 38IMPLEMENT_DYNAMIC_CLASS(wxTimerEvent, wxEvent)
c801d85f 39
0470b1e6 40// ============================================================================
e2478fde 41// wxTimerBase implementation
0470b1e6 42// ============================================================================
c801d85f 43
799ea011
GD
44wxTimerBase::~wxTimerBase()
45{
46 // this destructor is required for Darwin
47}
48
ed791986
VZ
49void wxTimerBase::Notify()
50{
51 // the base class version generates an event if it has owner - which it
52 // should because otherwise nobody can process timer events
53 wxCHECK_RET( m_owner, _T("wxTimer::Notify() should be overridden.") );
54
55 wxTimerEvent event(m_idTimer, m_milli);
313feadc 56 event.SetEventObject(this);
ed791986
VZ
57 (void)m_owner->ProcessEvent(event);
58}
b8f04990 59
99646f7e
VZ
60bool wxTimerBase::Start(int milliseconds, bool oneShot)
61{
2b5f62a0
VZ
62 // under MSW timers only work when they're started from the main thread so
63 // let the caller know about it
64#if wxUSE_THREADS
65 wxASSERT_MSG( wxThread::IsMain(),
66 _T("timer can only be started from the main thread") );
67#endif // wxUSE_THREADS
68
99646f7e
VZ
69 if ( IsRunning() )
70 {
71 // not stopping the already running timer might work for some
72 // platforms (no problems under MSW) but leads to mysterious crashes
73 // on the others (GTK), so to be on the safe side do it here
74 Stop();
75 }
76
77 if ( milliseconds != -1 )
78 {
79 m_milli = milliseconds;
80 }
81
82 m_oneShot = oneShot;
83
cb719f2e 84 return true;
99646f7e
VZ
85}
86
e2478fde 87#endif // wxUSE_TIMER
1e6feb95 88