]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/timer.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTimer implementation
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #include "wx/window.h"
16 #include "wx/os2/private.h"
31 #include <sys/types.h>
33 #include <sys/timeb.h>
34 // ----------------------------------------------------------------------------
36 // ----------------------------------------------------------------------------
38 wxList
wxTimerList(wxKEY_INTEGER
);
39 ULONG
wxTimerProc(HWND hwnd
, ULONG
, int nIdTimer
, ULONG
);
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 IMPLEMENT_ABSTRACT_CLASS(wxTimer
, wxObject
)
56 wxTimerList
.DeleteObject(this);
59 void wxTimer::Notify()
62 // The base class version generates an event if it has owner - which it
63 // should because otherwise nobody can process timer events, but it does
64 // not use the OS's ID, which OS/2 must have to figure out which timer fired
66 wxCHECK_RET( m_owner
, _T("wxTimer::Notify() should be overridden.") );
68 wxTimerEvent
vEvent( m_idTimer
72 (void)m_owner
->ProcessEvent(vEvent
);
73 } // end of wxTimer::Notify
80 (void)wxTimerBase::Start( nMilliseconds
84 wxCHECK_MSG( m_milli
> 0L, FALSE
, wxT("invalid value for timer") );
86 wxTimerList
.DeleteObject(this);
88 wxWindow
* pWin
= NULL
;
92 pWin
= (wxWindow
*)m_owner
;
93 m_ulId
= ::WinStartTimer( m_Hab
100 m_ulId
= ::WinStartTimer( m_Hab
103 ,(ULONG
)nMilliseconds
107 wxTimerList
.Append( m_ulId
114 wxLogSysError(_("Couldn't create a timer"));
126 wxWindow
* pWin
= (wxWindow
*)m_owner
;
128 ::WinStopTimer(m_Hab
, pWin
->GetHWND(), m_ulId
);
131 ::WinStopTimer(m_Hab
, NULLHANDLE
, m_ulId
);
132 wxTimerList
.DeleteObject(this);
137 // ----------------------------------------------------------------------------
139 // ----------------------------------------------------------------------------
146 // Avoid to process spurious timer events
148 if (rTimer
.m_ulId
== 0L)
151 if (rTimer
.IsOneShot())
164 wxNode
* pNode
= wxTimerList
.Find((ULONG
)nIdTimer
);
166 wxCHECK_MSG(pNode
, 0, wxT("bogus timer id in wxTimerProc") );
168 wxProcessTimer(*(wxTimer
*)pNode
->Data());