1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTimer implementation
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "timer.h"
18 #if !USE_SHARED_LIBRARY
19 IMPLEMENT_ABSTRACT_CLASS(wxTimer
, wxObject
)
22 static void wxProcessTimer( unsigned long event
, void *data
) ;
24 static pascal void MacTimerProc( TMTask
* t
)
26 MacTimerInfo
* tm
= (MacTimerInfo
*) t
;
27 wxMacAddEvent( tm
->m_table
, wxProcessTimer
, 0 , (void*) tm
->m_timer
, TRUE
) ;
30 static void wxProcessTimer( unsigned long event
, void *data
)
35 wxTimer
* timer
= (wxTimer
*) data
;
36 if ( timer
->IsOneShot() )
41 if ( timer
->m_info
.m_task
.tmAddr
&& !timer
->IsOneShot() )
43 PrimeTime( (QElemPtr
) &timer
->m_info
.m_task
, timer
->GetInterval() ) ;
49 m_info
.m_task
.tmAddr
= NULL
;
50 m_info
.m_task
.tmWakeUp
= 0 ;
51 m_info
.m_task
.tmReserved
= 0 ;
52 m_info
.m_task
.qType
= 0 ;
53 m_info
.m_table
= wxMacGetNotifierTable() ;
54 m_info
.m_timer
= this ;
57 bool wxTimer::IsRunning() const
59 return ( m_info
.m_task
.qType
& kTMTaskActive
) ;
67 bool wxTimer::Start(int milliseconds
,bool mode
)
69 (void)wxTimerBase::Start(milliseconds
, mode
);
71 wxCHECK_MSG( m_milli
> 0, FALSE
, wxT("invalid value for timer timeour") );
72 wxCHECK_MSG( m_info
.m_task
.tmAddr
== NULL
, FALSE
, wxT("attempting to restart a timer") );
74 m_milli
= milliseconds
;
75 #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
76 m_info
.m_task
.tmAddr
= NewTimerUPP( MacTimerProc
) ;
78 m_info
.m_task
.tmAddr
= NewTimerProc( MacTimerProc
) ;
80 m_info
.m_task
.tmWakeUp
= 0 ;
81 m_info
.m_task
.tmReserved
= 0 ;
82 InsXTime((QElemPtr
) &m_info
.m_task
) ;
83 PrimeTime( (QElemPtr
) &m_info
.m_task
, m_milli
) ;
90 if ( m_info
.m_task
.tmAddr
)
92 RmvTime( (QElemPtr
) &m_info
.m_task
) ;
93 DisposeTimerUPP(m_info
.m_task
.tmAddr
) ;
94 m_info
.m_task
.tmAddr
= NULL
;
96 wxMacRemoveAllNotifiersForData( wxMacGetNotifierTable() , this ) ;