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