]> git.saurik.com Git - wxWidgets.git/blame - src/motif/timer.cpp
removed extra membersections (patch 1702329)
[wxWidgets.git] / src / motif / timer.cpp
CommitLineData
4bb6408c 1/////////////////////////////////////////////////////////////////////////////
670f9935 2// Name: src/motif/timer.cpp
4bb6408c
JS
3// Purpose: wxTimer implementation
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
670f9935 9// Licence: wxWindows licence
4bb6408c
JS
10/////////////////////////////////////////////////////////////////////////////
11
1248b41f
MB
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
4bb6408c 15#include "wx/timer.h"
670f9935
WS
16
17#ifndef WX_PRECOMP
18 #include "wx/app.h"
df69528b 19 #include "wx/hashmap.h"
670f9935
WS
20#endif
21
338dd992
JJ
22#ifdef __VMS__
23#pragma message disable nosimpint
24#endif
0d57be45 25#include <Xm/Xm.h>
338dd992
JJ
26#ifdef __VMS__
27#pragma message enable nosimpint
28#endif
0d57be45
JS
29
30#include "wx/motif/private.h"
4bb6408c 31
e933b5bc 32IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler)
4bb6408c 33
4410d619
MB
34WX_DECLARE_VOIDPTR_HASH_MAP(wxTimer*, wxTimerHashMap);
35
36static wxTimerHashMap s_timers;
0d57be45
JS
37
38void wxTimerCallback (wxTimer * timer)
39{
40 // Check to see if it's still on
4410d619 41 if (s_timers.find(timer) == s_timers.end())
0d57be45
JS
42 return;
43
44 if (timer->m_id == 0)
670f9935 45 return; // Avoid to process spurious timer events
0d57be45
JS
46
47 if (!timer->m_oneShot)
0470b1e6
VZ
48 timer->m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
49 timer->m_milli,
50 (XtTimerCallbackProc) wxTimerCallback,
51 (XtPointer) timer);
0d57be45
JS
52 else
53 timer->m_id = 0;
0470b1e6
VZ
54
55 timer->Notify();
0d57be45
JS
56}
57
b3ddc4c2 58void wxTimer::Init()
4bb6408c 59{
0d57be45 60 m_id = 0;
b3ddc4c2 61 m_milli = 1000;
4bb6408c
JS
62}
63
64wxTimer::~wxTimer()
65{
4410d619
MB
66 Stop();
67 s_timers.erase(this);
4bb6408c
JS
68}
69
0d57be45 70bool wxTimer::Start(int milliseconds, bool mode)
4bb6408c 71{
0d57be45
JS
72 Stop();
73
0470b1e6 74 (void)wxTimerBase::Start(milliseconds, mode);
0d57be45 75
4410d619
MB
76 if (s_timers.find(this) == s_timers.end())
77 s_timers[this] = this;
4bb6408c 78
0470b1e6
VZ
79 m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
80 m_milli,
81 (XtTimerCallbackProc) wxTimerCallback,
82 (XtPointer) this);
96be256b 83 return true;
4bb6408c
JS
84}
85
86void wxTimer::Stop()
87{
0d57be45
JS
88 if (m_id > 0)
89 {
90 XtRemoveTimeOut (m_id);
91 m_id = 0;
92 }
4bb6408c
JS
93 m_milli = 0 ;
94}