]> git.saurik.com Git - wxWidgets.git/blame - src/motif/timer.cpp
use jast major.minor, not major.minor.micro, in the DLL names
[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
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "timer.h"
14#endif
15
16#include "wx/timer.h"
0d57be45
JS
17#include "wx/app.h"
18#include "wx/list.h"
19
338dd992
JJ
20#ifdef __VMS__
21#pragma message disable nosimpint
22#endif
0d57be45 23#include <Xm/Xm.h>
338dd992
JJ
24#ifdef __VMS__
25#pragma message enable nosimpint
26#endif
0d57be45
JS
27
28#include "wx/motif/private.h"
4bb6408c 29
4bb6408c 30IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
4bb6408c 31
0d57be45
JS
32static wxList wxTimerList(wxKEY_INTEGER);
33
34void wxTimerCallback (wxTimer * timer)
35{
36 // Check to see if it's still on
37 if (!wxTimerList.Find((long)timer))
38 return;
39
40 if (timer->m_id == 0)
41 return; // Avoid to process spurious timer events
42
43 if (!timer->m_oneShot)
0470b1e6
VZ
44 timer->m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
45 timer->m_milli,
46 (XtTimerCallbackProc) wxTimerCallback,
47 (XtPointer) timer);
0d57be45
JS
48 else
49 timer->m_id = 0;
0470b1e6
VZ
50
51 timer->Notify();
0d57be45
JS
52}
53
b3ddc4c2 54void wxTimer::Init()
4bb6408c 55{
0d57be45 56 m_id = 0;
b3ddc4c2 57 m_milli = 1000;
4bb6408c
JS
58}
59
60wxTimer::~wxTimer()
61{
0470b1e6 62 wxTimer::Stop();
1a3ac83f 63 wxTimerList.DeleteObject(this);
4bb6408c
JS
64}
65
0d57be45 66bool wxTimer::Start(int milliseconds, bool mode)
4bb6408c 67{
0d57be45
JS
68 Stop();
69
0470b1e6 70 (void)wxTimerBase::Start(milliseconds, mode);
0d57be45
JS
71
72 if (!wxTimerList.Find((long)this))
73 wxTimerList.Append((long)this, this);
4bb6408c 74
0470b1e6
VZ
75 m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
76 m_milli,
77 (XtTimerCallbackProc) wxTimerCallback,
78 (XtPointer) this);
0d57be45 79 return TRUE;
4bb6408c
JS
80}
81
82void wxTimer::Stop()
83{
0d57be45
JS
84 if (m_id > 0)
85 {
86 XtRemoveTimeOut (m_id);
87 m_id = 0;
88 }
4bb6408c
JS
89 m_milli = 0 ;
90}
91
92