]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/timer.cpp
Added some files
[wxWidgets.git] / src / gtk1 / timer.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: timer.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
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
21IMPLEMENT_ABSTRACT_CLASS(wxTimer,wxObject)
22
23gint timeout_callback( gpointer data )
24{
25 wxTimer *timer = (wxTimer*)data;
26 timer->Notify();
27
28 if ( timer->OneShot() )
29 timer->Stop();
30
31 return TRUE;
32}
33
34wxTimer::wxTimer()
35{
36 m_tag = -1;
37 m_time = 1000;
38 m_oneShot = FALSE;
39}
40
41wxTimer::~wxTimer()
42{
43 Stop();
44}
45
46bool wxTimer::Start( int millisecs, bool oneShot )
47{
48 if ( millisecs != -1 )
49 m_time = millisecs;
50
51 m_oneShot = oneShot;
52
53 m_tag = gtk_timeout_add( millisecs, timeout_callback, this );
54
55 return TRUE;
56}
57
58void wxTimer::Stop()
59{
60 if ( m_tag != -1 )
61 {
62 gtk_timeout_remove( m_tag );
63
64 m_tag = -1;
65 }
66}
67