]> git.saurik.com Git - wxWidgets.git/blame - src/motif/timer.cpp
Fix recreating of wxBitmapComboBox using untyped client data.
[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
4bb6408c 7// Copyright: (c) Julian Smart
670f9935 8// Licence: wxWindows licence
4bb6408c
JS
9/////////////////////////////////////////////////////////////////////////////
10
1248b41f
MB
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
c2ca375c 14#include "wx/motif/private/timer.h"
670f9935
WS
15
16#ifndef WX_PRECOMP
17 #include "wx/app.h"
df69528b 18 #include "wx/hashmap.h"
670f9935
WS
19#endif
20
338dd992
JJ
21#ifdef __VMS__
22#pragma message disable nosimpint
23#endif
0d57be45 24#include <Xm/Xm.h>
338dd992
JJ
25#ifdef __VMS__
26#pragma message enable nosimpint
27#endif
0d57be45
JS
28
29#include "wx/motif/private.h"
4bb6408c 30
c2ca375c 31WX_DECLARE_VOIDPTR_HASH_MAP(wxMotifTimerImpl*, wxTimerHashMap);
4bb6408c 32
c2ca375c 33static wxTimerHashMap gs_timers;
4410d619 34
c2ca375c 35void wxTimerCallback (wxMotifTimerImpl *timer)
0d57be45 36{
c2ca375c
VZ
37 // Check to see if it's still on
38 if ( gs_timers.find(timer) == gs_timers.end() )
39 return;
40
41 if ( !timer->IsRunning() )
42 return; // Avoid to process spurious timer events
43
44 timer->Notify();
0d57be45
JS
45}
46
c2ca375c 47wxMotifTimerImpl::~wxMotifTimerImpl()
4bb6408c 48{
c2ca375c 49 gs_timers.erase(this);
4bb6408c
JS
50}
51
c2ca375c 52void wxMotifTimerImpl::DoStart()
4bb6408c 53{
c2ca375c
VZ
54 m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
55 m_milli,
56 (XtTimerCallbackProc) wxTimerCallback,
57 (XtPointer) this);
4bb6408c
JS
58}
59
c2ca375c 60bool wxMotifTimerImpl::Start(int milliseconds, bool mode)
4bb6408c 61{
c2ca375c
VZ
62 if ( !wxTimerImpl::Start(milliseconds, mode) )
63 return false;
0d57be45 64
c2ca375c
VZ
65 if ( gs_timers.find(this) == gs_timers.end() )
66 gs_timers[this] = this;
0d57be45 67
c2ca375c 68 DoStart();
4bb6408c 69
96be256b 70 return true;
4bb6408c
JS
71}
72
c2ca375c
VZ
73void wxMotifTimerImpl::Stop()
74{
75 XtRemoveTimeOut (m_id);
76 m_id = 0;
77}
78
79void wxMotifTimerImpl::Notify()
4bb6408c 80{
c2ca375c 81 if ( IsOneShot() )
0d57be45 82 {
c2ca375c 83 // nothing to do, timeout is removed automatically by X
0d57be45
JS
84 m_id = 0;
85 }
c2ca375c
VZ
86 else // rearm the timer
87 {
88 DoStart();
89 }
90
91 wxTimerImpl::Notify();
4bb6408c 92}
c2ca375c 93