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