]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/timer.cpp
see mail to list
[wxWidgets.git] / src / gtk1 / timer.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: timer.cpp
3// Purpose:
4// Author: Robert Roebling
5// Created: 01/02/97
6// Id:
7// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11
12#ifdef __GNUG__
13#pragma implementation "timer.h"
14#endif
15
16#include "wx/timer.h"
17
18//-----------------------------------------------------------------------------
19// wxTimer
20//-----------------------------------------------------------------------------
21
22IMPLEMENT_DYNAMIC_CLASS(wxTimer,wxObject)
23
24gint timeout_callback( gpointer data )
25{
26 wxTimer *timer = (wxTimer*)data;
27 timer->Notify();
28 if (timer->OneShot()) timer->Stop();
29 return TRUE;
ff7b1510 30}
c801d85f
KB
31
32wxTimer::wxTimer(void)
33{
34 m_tag = -1;
35 m_time = 1000;
36 m_oneShot = FALSE;
ff7b1510 37}
c801d85f
KB
38
39wxTimer::~wxTimer(void)
40{
41 Stop();
ff7b1510 42}
c801d85f
KB
43
44int wxTimer::Interval(void)
45{
46 return m_time;
ff7b1510 47}
c801d85f
KB
48
49bool wxTimer::OneShot(void)
50{
51 return m_oneShot;
ff7b1510 52}
c801d85f
KB
53
54void wxTimer::Notify(void)
55{
ff7b1510 56}
c801d85f
KB
57
58void wxTimer::Start( int millisecs, bool oneShot )
59{
60 if (millisecs != -1) m_time = millisecs;
61 m_oneShot = oneShot;
62 m_tag = gtk_timeout_add( millisecs, timeout_callback, this );
ff7b1510 63}
c801d85f
KB
64
65void wxTimer::Stop(void)
66{
67 if (m_tag != -1)
68 gtk_timeout_remove( m_tag );
69 m_tag = -1;
ff7b1510 70}
c801d85f 71