]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/timer.cpp
Fixed a bug so wxLC_VRULES works by itself.
[wxWidgets.git] / src / gtk1 / timer.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: gtk/timer.cpp
3// Purpose: wxTimer implementation
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/defs.h"
16
17#if wxUSE_TIMER
18
19#include "wx/timer.h"
20
21#include "gtk/gtk.h"
22
23// ----------------------------------------------------------------------------
24// wxTimer
25// ----------------------------------------------------------------------------
26
27IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
28
29static gint timeout_callback( gpointer data )
30{
31 wxTimer *timer = (wxTimer*)data;
32
33 /* when getting called from GDK's timer handler we
34 are no longer within GDK's grab on the GUI
35 thread so we must lock it here ourselves */
36 gdk_threads_enter();
37
38 timer->Notify();
39
40 /* release lock again */
41 gdk_threads_leave();
42
43 if ( timer->IsOneShot() )
44 return FALSE;
45
46 return TRUE;
47}
48
49void wxTimer::Init()
50{
51 m_tag = -1;
52 m_milli = 1000;
53}
54
55wxTimer::~wxTimer()
56{
57 wxTimer::Stop();
58}
59
60bool wxTimer::Start( int millisecs, bool oneShot )
61{
62 (void)wxTimerBase::Start(millisecs, oneShot);
63
64 m_tag = gtk_timeout_add( m_milli, timeout_callback, this );
65
66 return TRUE;
67}
68
69void wxTimer::Stop()
70{
71 if (m_tag != -1)
72 {
73 gtk_timeout_remove( m_tag );
74 m_tag = -1;
75 }
76}
77
78#endif // wxUSE_TIMER
79