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
)
23 #include "wx/mac/private.h"
29 typedef struct MacTimerInfo
32 wxMacNotifierTableRef m_table
;
36 static void wxProcessTimer( unsigned long event
, void *data
) ;
38 static pascal void MacTimerProc( TMTask
* t
)
40 MacTimerInfo
* tm
= (MacTimerInfo
*) t
;
41 wxMacAddEvent( tm
->m_table
, wxProcessTimer
, 0 , (void*) tm
->m_timer
, TRUE
) ;
44 static void wxProcessTimer( unsigned long event
, void *data
)
49 wxTimer
* timer
= (wxTimer
*) data
;
50 if ( timer
->IsOneShot() )
55 if ( timer
->m_info
->m_task
.tmAddr
&& !timer
->IsOneShot() )
57 PrimeTime( (QElemPtr
) &timer
->m_info
->m_task
, timer
->GetInterval() ) ;
63 m_info
= new MacTimerInfo() ;
64 m_info
->m_task
.tmAddr
= NULL
;
65 m_info
->m_task
.tmWakeUp
= 0 ;
66 m_info
->m_task
.tmReserved
= 0 ;
67 m_info
->m_task
.qType
= 0 ;
68 m_info
->m_table
= wxMacGetNotifierTable() ;
69 m_info
->m_timer
= this ;
72 bool wxTimer::IsRunning() const
74 return ( m_info
->m_task
.qType
& kTMTaskActive
) ;
84 bool wxTimer::Start(int milliseconds
,bool mode
)
86 (void)wxTimerBase::Start(milliseconds
, mode
);
88 wxCHECK_MSG( m_milli
> 0, FALSE
, wxT("invalid value for timer timeour") );
89 wxCHECK_MSG( m_info
->m_task
.tmAddr
== NULL
, FALSE
, wxT("attempting to restart a timer") );
91 m_milli
= milliseconds
;
92 #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
93 m_info
->m_task
.tmAddr
= NewTimerUPP( MacTimerProc
) ;
95 m_info
->m_task
.tmAddr
= NewTimerProc( MacTimerProc
) ;
97 m_info
->m_task
.tmWakeUp
= 0 ;
98 m_info
->m_task
.tmReserved
= 0 ;
99 m_info
->m_task
.qType
= 0 ;
100 m_info
->m_timer
= this ;
101 InsXTime((QElemPtr
) &m_info
->m_task
) ;
102 PrimeTime( (QElemPtr
) &m_info
->m_task
, m_milli
) ;
109 if ( m_info
->m_task
.tmAddr
)
111 RmvTime( (QElemPtr
) &m_info
->m_task
) ;
112 DisposeTimerUPP(m_info
->m_task
.tmAddr
) ;
113 m_info
->m_task
.tmAddr
= NULL
;
115 wxMacRemoveAllNotifiersForData( wxMacGetNotifierTable() , this ) ;