\section{\class{wxTimer}}\label{wxtimer}
-The wxTimer class allows you to execute code at specified intervals. To
-use it, derive a new class and override the {\bf Notify} member to
-perform the required action. Start with {\bf Start}, stop with {\bf
-Stop}, it's as simple as that.
+The wxTimer class allows you to execute code at specified intervals. Its
+precision is platform-dependent, but in general will not be better than 1ms nor
+worse than 1s.
+
+There are three different ways to use this class:
+
+\begin{enumerate}
+\item You may derive a new class from wxTimer and override the
+\helpref{Notify}{wxtimernotify} member to perform the required action.
+\item Or you may redirect the notifications to any
+\helpref{wxEvtHandler}{wxevthandler} derived object by using the non-default
+constructor or \helpref{SetOwner}{wxtimersetowner}. Then use the {\tt EVT\_TIMER}
+macro to connect it to the event handler which will receive
+\helpref{wxTimerEvent}{wxtimerevent} notifications.
+\item Or you may use a derived class and the {\tt EVT\_TIMER}
+macro to connect it to an event handler defined in the derived class.
+If the default constructor is used, the timer object will be its
+own owner object, since it is derived from wxEvtHandler.
+\end{enumerate}
+
+In any case, you must start the timer with \helpref{Start}{wxtimerstart}
+after constructing it before it actually starts sending notifications. It can
+be stopped later with \helpref{Stop}{wxtimerstop}.
+
+{\bf Note:} A timer can only be used from the main thread.
\wxheading{Derived from}
+\helpref{wxEvtHandler}{wxevthandler}
\helpref{wxObject}{wxobject}
\wxheading{Include files}
\latexignore{\rtfignore{\wxheading{Members}}}
-\membersection{wxTimer::wxTimer}
+\membersection{wxTimer::wxTimer}\label{wxtimerwxtimer}
\func{}{wxTimer}{\void}
-Constructor.
+Default constructor. If you use it to construct the object and don't call
+\helpref{SetOwner}{wxtimersetowner} later, you must override
+\helpref{Notify}{wxtimernotify} method to process the notifications.
-\membersection{wxTimer::\destruct{wxTimer}}
+\func{}{wxTimer}{\param{wxEvtHandler *}{owner}, \param{int }{id = -1}}
+
+Creates a timer and associates it with {\it owner}. Please see
+\helpref{SetOwner}{wxtimersetowner} for the description of parameters.
+
+\membersection{wxTimer::\destruct{wxTimer}}\label{wxtimerdtor}
\func{}{\destruct{wxTimer}}{\void}
-Destructor. Stops the timer if activated.
+Destructor. Stops the timer if it is running.
+
+\membersection{wxTimer::GetInterval}\label{wxtimergetinterval}
+
+\constfunc{int}{GetInterval}{\void}
+
+Returns the current interval for the timer (in milliseconds).
+
+\membersection{wxTimer::IsOneShot}\label{wxtimerisoneshot}
+
+\constfunc{bool}{IsOneShot}{\void}
-\membersection{wxTimer::Interval}
+Returns {\tt true} if the timer is one shot, i.e.\ if it will stop after firing the
+first notification automatically.
-\func{int}{Interval}{\void}
+\membersection{wxTimer::IsRunning}\label{wxtimerisrunning}
-Returns the current interval for the timer.
+\constfunc{bool}{IsRunning}{\void}
-\membersection{wxTimer::Notify}
+Returns {\tt true} if the timer is running, {\tt false} if it is stopped.
+
+\membersection{wxTimer::Notify}\label{wxtimernotify}
\func{void}{Notify}{\void}
-This member should be overridden by the user. It is called on timeout.
+This member should be overridden by the user if the default constructor was
+used and \helpref{SetOwner}{wxtimersetowner} wasn't called.
-\membersection{wxTimer::Start}
+Perform whatever action which is to be taken periodically here.
-\func{bool}{Start}{\param{int}{ milliseconds = -1}, \param{bool}{ oneShot=FALSE}}
+\membersection{wxTimer::SetOwner}\label{wxtimersetowner}
-(Re)starts the timer. If {\it milliseconds}\/ is absent or -1, the
-previous value is used. Returns FALSE if the timer could not be started,
-TRUE otherwise (in MS Windows timers are a limited resource).
+\func{void}{SetOwner}{\param{wxEvtHandler *}{owner}, \param{int }{id = -1}}
-If {\it oneShot} is FALSE (the default), the Notify function will be repeatedly
-called. If TRUE, Notify will be called only once.
+Associates the timer with the given {\it owner}\/ object. When the timer is
+running, the owner will receive \helpref{timer events}{wxtimerevent} with
+id equal to {\it id}\/ specified here.
-\membersection{wxTimer::Stop}
+\membersection{wxTimer::Start}\label{wxtimerstart}
-\func{void}{Stop}{\void}
+\func{bool}{Start}{\param{int }{milliseconds = -1}, \param{bool }{oneShot = {\tt false}}}
-Stops the timer.
+(Re)starts the timer. If {\it milliseconds}\/ parameter is -1 (value by default),
+the previous value is used. Returns {\tt false} if the timer could not be started,
+{\tt true} otherwise (in MS Windows timers are a limited resource).
-\section{\class{wxStopWatch}}\label{wxstopwatch}
+If {\it oneShot}\/ is {\tt false} (the default), the \helpref{Notify}{wxtimernotify}
+function will be called repeatedly until the timer is stopped. If {\tt true},
+it will be called only once and the timer will stop automatically. To make your
+code more readable you may also use the following symbolic constants:
-The wxStopWatch class allow you to measure time intervalls.
+\twocolwidtha{5cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{wxTIMER\_CONTINUOUS}{Start a normal, continuously running, timer}
+\twocolitem{wxTIMER\_ONE\_SHOT}{Start a one shot timer}
+\end{twocollist}
-\wxheading{Include files}
+If the timer was already running, it will be stopped by this method before
+restarting it.
-<wx/timer.h>
+\membersection{wxTimer::Stop}\label{wxtimerstop}
-\wxheading{See also}
+\func{void}{Stop}{\void}
-\helpref{::wxStartTimer}{wxstarttimer}, \helpref{::wxGetElapsedTime}{wxgetelapsedtime}, \helpref{wxTimer}{wxtimer}
+Stops the timer.
-\latexignore{\rtfignore{\wxheading{Members}}}
+\section{\class{wxTimerEvent}}\label{wxtimerevent}
+
+wxTimerEvent object is passed to the event handler of timer events.
+
+For example:
+
+\begin{verbatim}
+class MyFrame : public wxFrame
+{
+public:
+ ...
+ void OnTimer(wxTimerEvent& event);
-\membersection{wxStopWatch::wxStopWatch}
+private:
+ wxTimer m_timer;
+};
-\func{}{wxStopWatch}{\void}
+BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+ EVT_TIMER(TIMER_ID, MyFrame::OnTimer)
+END_EVENT_TABLE()
-Constructor. This starts the stop watch.
+MyFrame::MyFrame()
+ : m_timer(this, TIMER_ID)
+{
+ m_timer.Start(1000); // 1 second interval
+}
-\membersection{wxStopWatch::Pause}\label{wxstopwatchpause}
+void MyFrame::OnTimer(wxTimerEvent& event)
+{
+ // do whatever you want to do every second here
+}
-\func{void}{Pause}{\void}
+\end{verbatim}
-Pauses the stop watch. Call \helpref{wxStopWatch::Resume}{wxstopwatchresume} to resume
-time measuring again.
+\wxheading{Derived from}
+
+\helpref{wxEvent}{wxevent}
-\membersection{wxStopWatch::Start}
+\wxheading{Include files}
-\func{void}{Start}{\param{long}{ milliseconds = 0}}
+<wx/timer.h>
-(Re)starts the stop watch with a given initial value.
+\wxheading{See also}
-\membersection{wxStopWatch::Resume}\label{wxstopwatchresume}
+\helpref{wxTimer}{wxtimer}
-\func{void}{Resume}{\void}
+\latexignore{\rtfignore{\wxheading{Members}}}
-Resumes the stop watch after having been paused with \helpref{wxStopWatch::Pause}{wxstopwatchpause}.
+\membersection{wxTimerEvent::GetInterval}\label{wxtimereventgetinterval}
-\membersection{wxStopWatch::Time}
+\constfunc{int}{GetInterval}{\void}
-\func{long}{Time}{\void}\label{wxstopwatchtime}
+Returns the interval of the timer which generated this event.
-Returns the time in milliseconds since the start (or restart) or the last call of
-\helpref{wxStopWatch::Pause}{wxstopwatchpause}.