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