]> git.saurik.com Git - wxWidgets.git/blame - src/motif/timer.cpp
mask fixes for non-core graphics case (this build uses CopyDeepMask for painting...
[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
65571936 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"
0d57be45 16#include "wx/app.h"
4410d619 17#include "wx/hashmap.h"
0d57be45 18
338dd992
JJ
19#ifdef __VMS__
20#pragma message disable nosimpint
21#endif
0d57be45 22#include <Xm/Xm.h>
338dd992
JJ
23#ifdef __VMS__
24#pragma message enable nosimpint
25#endif
0d57be45
JS
26
27#include "wx/motif/private.h"
4bb6408c 28
e933b5bc 29IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxEvtHandler)
4bb6408c 30
4410d619
MB
31WX_DECLARE_VOIDPTR_HASH_MAP(wxTimer*, wxTimerHashMap);
32
33static wxTimerHashMap s_timers;
0d57be45
JS
34
35void wxTimerCallback (wxTimer * timer)
36{
37 // Check to see if it's still on
4410d619 38 if (s_timers.find(timer) == s_timers.end())
0d57be45
JS
39 return;
40
41 if (timer->m_id == 0)
42 return; // Avoid to process spurious timer events
43
44 if (!timer->m_oneShot)
0470b1e6
VZ
45 timer->m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
46 timer->m_milli,
47 (XtTimerCallbackProc) wxTimerCallback,
48 (XtPointer) timer);
0d57be45
JS
49 else
50 timer->m_id = 0;
0470b1e6
VZ
51
52 timer->Notify();
0d57be45
JS
53}
54
b3ddc4c2 55void wxTimer::Init()
4bb6408c 56{
0d57be45 57 m_id = 0;
b3ddc4c2 58 m_milli = 1000;
4bb6408c
JS
59}
60
61wxTimer::~wxTimer()
62{
4410d619
MB
63 Stop();
64 s_timers.erase(this);
4bb6408c
JS
65}
66
0d57be45 67bool wxTimer::Start(int milliseconds, bool mode)
4bb6408c 68{
0d57be45
JS
69 Stop();
70
0470b1e6 71 (void)wxTimerBase::Start(milliseconds, mode);
0d57be45 72
4410d619
MB
73 if (s_timers.find(this) == s_timers.end())
74 s_timers[this] = this;
4bb6408c 75
0470b1e6
VZ
76 m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
77 m_milli,
78 (XtTimerCallbackProc) wxTimerCallback,
79 (XtPointer) this);
96be256b 80 return true;
4bb6408c
JS
81}
82
83void wxTimer::Stop()
84{
0d57be45
JS
85 if (m_id > 0)
86 {
87 XtRemoveTimeOut (m_id);
88 m_id = 0;
89 }
4bb6408c
JS
90 m_milli = 0 ;
91}
92
93