]> git.saurik.com Git - wxWidgets.git/blame - src/motif/timer.cpp
bitmap and image updates
[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
JS
29
30#if !USE_SHARED_LIBRARY
31IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
32#endif
33
0d57be45
JS
34static wxList wxTimerList(wxKEY_INTEGER);
35
36void wxTimerCallback (wxTimer * timer)
37{
38 // Check to see if it's still on
39 if (!wxTimerList.Find((long)timer))
40 return;
41
42 if (timer->m_id == 0)
43 return; // Avoid to process spurious timer events
44
45 if (!timer->m_oneShot)
0470b1e6
VZ
46 timer->m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
47 timer->m_milli,
48 (XtTimerCallbackProc) wxTimerCallback,
49 (XtPointer) timer);
0d57be45
JS
50 else
51 timer->m_id = 0;
0470b1e6
VZ
52
53 timer->Notify();
0d57be45
JS
54}
55
4bb6408c
JS
56wxTimer::wxTimer()
57{
0d57be45 58 m_id = 0;
4bb6408c
JS
59}
60
61wxTimer::~wxTimer()
62{
0470b1e6 63 wxTimer::Stop();
1a3ac83f 64 wxTimerList.DeleteObject(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
JS
72
73 if (!wxTimerList.Find((long)this))
74 wxTimerList.Append((long)this, this);
4bb6408c 75
0470b1e6
VZ
76 m_id = XtAppAddTimeOut((XtAppContext) wxTheApp->GetAppContext(),
77 m_milli,
78 (XtTimerCallbackProc) wxTimerCallback,
79 (XtPointer) this);
0d57be45 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