]>
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
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #include "wx/motif/private/timer.h"
19 #include "wx/hashmap.h"
23 #pragma message disable nosimpint
27 #pragma message enable nosimpint
30 #include "wx/motif/private.h"
32 WX_DECLARE_VOIDPTR_HASH_MAP(wxMotifTimerImpl
*, wxTimerHashMap
);
34 static wxTimerHashMap gs_timers
;
36 void wxTimerCallback (wxMotifTimerImpl
*timer
)
38 // Check to see if it's still on
39 if ( gs_timers
.find(timer
) == gs_timers
.end() )
42 if ( !timer
->IsRunning() )
43 return; // Avoid to process spurious timer events
48 wxMotifTimerImpl::~wxMotifTimerImpl()
50 gs_timers
.erase(this);
53 void wxMotifTimerImpl::DoStart()
55 m_id
= XtAppAddTimeOut((XtAppContext
) wxTheApp
->GetAppContext(),
57 (XtTimerCallbackProc
) wxTimerCallback
,
61 bool wxMotifTimerImpl::Start(int milliseconds
, bool mode
)
63 if ( !wxTimerImpl::Start(milliseconds
, mode
) )
66 if ( gs_timers
.find(this) == gs_timers
.end() )
67 gs_timers
[this] = this;
74 void wxMotifTimerImpl::Stop()
76 XtRemoveTimeOut (m_id
);
80 void wxMotifTimerImpl::Notify()
84 // nothing to do, timeout is removed automatically by X
87 else // rearm the timer
92 wxTimerImpl::Notify();