]> git.saurik.com Git - wxWidgets.git/blame - src/motif/timer.cpp
restored wxPluginLibrary::ms_classes handling code that was removed by mistake
[wxWidgets.git] / src / motif / timer.cpp
CommitLineData
4bb6408c
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: timer.cpp
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
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
14f355c2 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
4bb6408c
JS
13#pragma implementation "timer.h"
14#endif
15
16#include "wx/timer.h"
0d57be45 17#include "wx/app.h"
4410d619 18#include "wx/hashmap.h"
0d57be45 19
338dd992
JJ
20#ifdef __VMS__
21#pragma message disable nosimpint
22#endif
0d57be45 23#include <Xm/Xm.h>
338dd992
JJ
24#ifdef __VMS__
25#pragma message enable nosimpint
26#endif
0d57be45
JS
27
28#include "wx/motif/private.h"
4bb6408c 29
4410d619 30IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject);
4bb6408c 31
4410d619
MB
32WX_DECLARE_VOIDPTR_HASH_MAP(wxTimer*, wxTimerHashMap);
33
34static wxTimerHashMap s_timers;
0d57be45
JS
35
36void wxTimerCallback (wxTimer * timer)
37{
38 // Check to see if it's still on
4410d619 39 if (s_timers.find(timer) == s_timers.end())
0d57be45
JS
40 return;
41
42 if (timer->m_id == 0)
43 return; // Avoid to process spurious timer events
44
45 if (!timer->m_oneShot)
0470b1e6
VZ
46 timer->m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
47 timer->m_milli,
48 (XtTimerCallbackProc) wxTimerCallback,
49 (XtPointer) timer);
0d57be45
JS
50 else
51 timer->m_id = 0;
0470b1e6
VZ
52
53 timer->Notify();
0d57be45
JS
54}
55
b3ddc4c2 56void wxTimer::Init()
4bb6408c 57{
0d57be45 58 m_id = 0;
b3ddc4c2 59 m_milli = 1000;
4bb6408c
JS
60}
61
62wxTimer::~wxTimer()
63{
4410d619
MB
64 Stop();
65 s_timers.erase(this);
4bb6408c
JS
66}
67
0d57be45 68bool wxTimer::Start(int milliseconds, bool mode)
4bb6408c 69{
0d57be45
JS
70 Stop();
71
0470b1e6 72 (void)wxTimerBase::Start(milliseconds, mode);
0d57be45 73
4410d619
MB
74 if (s_timers.find(this) == s_timers.end())
75 s_timers[this] = this;
4bb6408c 76
0470b1e6
VZ
77 m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
78 m_milli,
79 (XtTimerCallbackProc) wxTimerCallback,
80 (XtPointer) this);
0d57be45 81 return TRUE;
4bb6408c
JS
82}
83
84void wxTimer::Stop()
85{
0d57be45
JS
86 if (m_id > 0)
87 {
88 XtRemoveTimeOut (m_id);
89 m_id = 0;
90 }
4bb6408c
JS
91 m_milli = 0 ;
92}
93
94