]> git.saurik.com Git - wxWidgets.git/blame - src/common/timerimpl.cpp
Somehow, setting a tint color makes gauge work :/.
[wxWidgets.git] / src / common / timerimpl.cpp
CommitLineData
c2ca375c 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/common/timerimpl.cpp
c2ca375c
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)
6// Created: 04/01/98
c2ca375c
VZ
7// Copyright: (c) Julian Smart
8// (c) 1999 Guillermo Rodriguez <guille@iies.es>
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// wxWin headers
18// ----------------------------------------------------------------------------
19
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
27#if wxUSE_TIMER
28
29#include "wx/private/timer.h"
30#include "wx/utils.h" // for wxNewId()
204abcd4 31#include "wx/thread.h"
c2ca375c
VZ
32
33wxTimerImpl::wxTimerImpl(wxTimer *timer)
34{
35 m_timer = timer;
36 m_owner = NULL;
37 m_idTimer = wxID_ANY;
38 m_milli = 0;
39 m_oneShot = false;
40}
41
42void wxTimerImpl::SetOwner(wxEvtHandler *owner, int timerid)
43{
44 m_owner = owner;
45 m_idTimer = timerid == wxID_ANY ? wxNewId() : timerid;
46}
47
48void wxTimerImpl::SendEvent()
49{
2cd78b2a 50 wxTimerEvent event(*m_timer);
85716ec3 51 (void)m_owner->SafelyProcessEvent(event);
c2ca375c
VZ
52}
53
54bool wxTimerImpl::Start(int milliseconds, bool oneShot)
55{
56 // under MSW timers only work when they're started from the main thread so
57 // let the caller know about it
58#if wxUSE_THREADS
59 wxASSERT_MSG( wxThread::IsMain(),
9a83f860 60 wxT("timer can only be started from the main thread") );
c2ca375c
VZ
61#endif // wxUSE_THREADS
62
63 if ( IsRunning() )
64 {
65 // not stopping the already running timer might work for some
66 // platforms (no problems under MSW) but leads to mysterious crashes
67 // on the others (GTK), so to be on the safe side do it here
68 Stop();
69 }
70
71 if ( milliseconds != -1 )
72 {
73 m_milli = milliseconds;
74 }
75
76 m_oneShot = oneShot;
77
78 return true;
79}
80
81
82#endif // wxUSE_TIMER
83