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