]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/timer.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/timer.cpp
3 // Purpose: wxTimer implementation
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
14 #include "wx/motif/private/timer.h"
18 #include "wx/hashmap.h"
22 #pragma message disable nosimpint
26 #pragma message enable nosimpint
29 #include "wx/motif/private.h"
31 WX_DECLARE_VOIDPTR_HASH_MAP(wxMotifTimerImpl
*, wxTimerHashMap
);
33 static wxTimerHashMap gs_timers
;
35 void wxTimerCallback (wxMotifTimerImpl
*timer
)
37 // Check to see if it's still on
38 if ( gs_timers
.find(timer
) == gs_timers
.end() )
41 if ( !timer
->IsRunning() )
42 return; // Avoid to process spurious timer events
47 wxMotifTimerImpl::~wxMotifTimerImpl()
49 gs_timers
.erase(this);
52 void wxMotifTimerImpl::DoStart()
54 m_id
= XtAppAddTimeOut((XtAppContext
) wxTheApp
->GetAppContext(),
56 (XtTimerCallbackProc
) wxTimerCallback
,
60 bool wxMotifTimerImpl::Start(int milliseconds
, bool mode
)
62 if ( !wxTimerImpl::Start(milliseconds
, mode
) )
65 if ( gs_timers
.find(this) == gs_timers
.end() )
66 gs_timers
[this] = this;
73 void wxMotifTimerImpl::Stop()
75 XtRemoveTimeOut (m_id
);
79 void wxMotifTimerImpl::Notify()
83 // nothing to do, timeout is removed automatically by X
86 else // rearm the timer
91 wxTimerImpl::Notify();