]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/timer.cpp
Fix for TextCtrl problem as reported by Vegh
[wxWidgets.git] / src / gtk1 / timer.cpp
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
21 IMPLEMENT_ABSTRACT_CLASS(wxTimer,wxObject)
22
23 gint 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
34 wxTimer::wxTimer()
35 {
36 m_tag = -1;
37 m_time = 1000;
38 m_oneShot = FALSE;
39 }
40
41 wxTimer::~wxTimer()
42 {
43 Stop();
44 }
45
46 bool 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
58 void wxTimer::Stop()
59 {
60 if ( m_tag != -1 )
61 {
62 gtk_timeout_remove( m_tag );
63
64 m_tag = -1;
65 }
66 }
67