]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/timer.cpp
supports typedefs, generates "See also:" and adds "virtual " for virtual
[wxWidgets.git] / src / gtk1 / 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
83624f79
RR
17#include "gtk/gtk.h"
18
c801d85f
KB
19//-----------------------------------------------------------------------------
20// wxTimer
21//-----------------------------------------------------------------------------
22
03f38c58 23IMPLEMENT_ABSTRACT_CLASS(wxTimer,wxObject)
c801d85f
KB
24
25gint timeout_callback( gpointer data )
26{
83624f79
RR
27 wxTimer *timer = (wxTimer*)data;
28 timer->Notify();
03f38c58 29
83624f79
RR
30 if (timer->OneShot())
31 {
32 timer->Stop();
33 }
03f38c58 34
83624f79 35 return TRUE;
ff7b1510 36}
c801d85f 37
03f38c58 38wxTimer::wxTimer()
c801d85f 39{
83624f79
RR
40 m_tag = -1;
41 m_time = 1000;
42 m_oneShot = FALSE;
ff7b1510 43}
c801d85f 44
03f38c58 45wxTimer::~wxTimer()
c801d85f 46{
83624f79 47 Stop();
ff7b1510 48}
c801d85f 49
03f38c58 50bool wxTimer::Start( int millisecs, bool oneShot )
c801d85f 51{
83624f79
RR
52 if (millisecs != -1)
53 {
54 m_time = millisecs;
55 }
c801d85f 56
83624f79 57 m_oneShot = oneShot;
03f38c58 58
83624f79 59 m_tag = gtk_timeout_add( millisecs, timeout_callback, this );
03f38c58 60
83624f79 61 return TRUE;
ff7b1510 62}
c801d85f 63
03f38c58 64void wxTimer::Stop()
c801d85f 65{
83624f79
RR
66 if (m_tag != -1)
67 {
68 gtk_timeout_remove( m_tag );
69 m_tag = -1;
70 }
ff7b1510 71}
c801d85f 72