]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/timer.cpp
Prealpha, prebeta of new wxTreeCtrl for GTK. It is possible to AddRoot,
[wxWidgets.git] / src / gtk / timer.cpp
... / ...
CommitLineData
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_ABSTRACT_CLASS(wxTimer,wxObject)
23
24gint timeout_callback( gpointer data )
25{
26 wxTimer *timer = (wxTimer*)data;
27 timer->Notify();
28
29 if ( timer->OneShot() )
30 timer->Stop();
31
32 return TRUE;
33}
34
35wxTimer::wxTimer()
36{
37 m_tag = -1;
38 m_time = 1000;
39 m_oneShot = FALSE;
40}
41
42wxTimer::~wxTimer()
43{
44 Stop();
45}
46
47bool wxTimer::Start( int millisecs, bool oneShot )
48{
49 if ( millisecs != -1 )
50 m_time = millisecs;
51
52 m_oneShot = oneShot;
53
54 m_tag = gtk_timeout_add( millisecs, timeout_callback, this );
55
56 return TRUE;
57}
58
59void wxTimer::Stop()
60{
61 if ( m_tag != -1 )
62 {
63 gtk_timeout_remove( m_tag );
64
65 m_tag = -1;
66 }
67}
68