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"
26 typedef struct MacTimerInfo
29 wxMacNotifierTableRef m_table
;
33 static void wxProcessTimer( unsigned long event
, void *data
) ;
35 static pascal void MacTimerProc( TMTask
* t
)
37 MacTimerInfo
* tm
= (MacTimerInfo
*) t
;
38 wxMacAddEvent( tm
->m_table
, wxProcessTimer
, 0 , (void*) tm
->m_timer
, TRUE
) ;
41 static void wxProcessTimer( unsigned long event
, void *data
)
46 wxTimer
* timer
= (wxTimer
*) data
;
47 if ( timer
->IsOneShot() )
52 if ( timer
->m_info
->m_task
.tmAddr
&& !timer
->IsOneShot() )
54 PrimeTime( (QElemPtr
) &timer
->m_info
->m_task
, timer
->GetInterval() ) ;
60 m_info
= new MacTimerInfo() ;
61 m_info
->m_task
.tmAddr
= NULL
;
62 m_info
->m_task
.tmWakeUp
= 0 ;
63 m_info
->m_task
.tmReserved
= 0 ;
64 m_info
->m_task
.qType
= 0 ;
65 m_info
->m_table
= wxMacGetNotifierTable() ;
66 m_info
->m_timer
= this ;
69 bool wxTimer::IsRunning() const
71 return ( m_info
->m_task
.qType
& kTMTaskActive
) ;
81 bool wxTimer::Start(int milliseconds
,bool mode
)
83 (void)wxTimerBase::Start(milliseconds
, mode
);
85 wxCHECK_MSG( m_milli
> 0, FALSE
, wxT("invalid value for timer timeour") );
86 wxCHECK_MSG( m_info
->m_task
.tmAddr
== NULL
, FALSE
, wxT("attempting to restart a timer") );
88 m_milli
= milliseconds
;
89 #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
90 m_info
->m_task
.tmAddr
= NewTimerUPP( MacTimerProc
) ;
92 m_info
->m_task
.tmAddr
= NewTimerProc( MacTimerProc
) ;
94 m_info
->m_task
.tmWakeUp
= 0 ;
95 m_info
->m_task
.tmReserved
= 0 ;
96 m_info
->m_task
.qType
= 0 ;
97 m_info
->m_timer
= this ;
98 InsXTime((QElemPtr
) &m_info
->m_task
) ;
99 PrimeTime( (QElemPtr
) &m_info
->m_task
, m_milli
) ;
106 if ( m_info
->m_task
.tmAddr
)
108 RmvTime( (QElemPtr
) &m_info
->m_task
) ;
109 DisposeTimerUPP(m_info
->m_task
.tmAddr
) ;
110 m_info
->m_task
.tmAddr
= NULL
;
112 wxMacRemoveAllNotifiersForData( wxMacGetNotifierTable() , this ) ;