]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/timer.cpp
forwarding style changes to documentViews, see #14578
[wxWidgets.git] / src / gtk1 / timer.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/gtk1/timer.cpp
1e6feb95 3// Purpose: wxTimer implementation
c801d85f 4// Author: Robert Roebling
a81258be 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2 10#include "wx/wxprec.h"
1e6feb95
VZ
11
12#if wxUSE_TIMER
13
c2ca375c 14#include "wx/gtk1/private/timer.h"
c801d85f 15
83624f79
RR
16#include "gtk/gtk.h"
17
1e6feb95 18// ----------------------------------------------------------------------------
c801d85f 19// wxTimer
1e6feb95 20// ----------------------------------------------------------------------------
c801d85f 21
865bb325 22extern "C" {
c2ca375c 23static gint timeout_callback(void *data)
c801d85f 24{
c2ca375c 25 wxTimerImpl * const timer = (wxTimerImpl *)data;
3d257b8d 26
c2ca375c
VZ
27 const bool keepGoing = !timer->IsOneShot();
28 if ( !keepGoing )
7b14c561 29 timer->Stop();
3d257b8d 30
7b14c561
RR
31 // When getting called from GDK's timer handler we
32 // are no longer within GDK's grab on the GUI
33 // thread so we must lock it here ourselves.
924ef850 34 gdk_threads_enter();
e1393d82 35
83624f79 36 timer->Notify();
03f38c58 37
7b14c561 38 // Release lock again.
924ef850 39 gdk_threads_leave();
f6577bba 40
c2ca375c 41 return keepGoing;
ff7b1510 42}
ff7b1510 43}
c801d85f 44
c2ca375c 45bool wxGTKTimerImpl::Start(int millisecs, bool oneShot)
c801d85f 46{
c2ca375c
VZ
47 if ( !wxTimerImpl::Start(millisecs, oneShot) )
48 return false;
03f38c58 49
9a83f860 50 wxASSERT_MSG( m_tag == -1, wxT("shouldn't be still running") );
574bf507 51
0470b1e6 52 m_tag = gtk_timeout_add( m_milli, timeout_callback, this );
03f38c58 53
c2ca375c 54 return true;
ff7b1510 55}
c801d85f 56
c2ca375c 57void wxGTKTimerImpl::Stop()
c801d85f 58{
9a83f860 59 wxASSERT_MSG( m_tag != -1, wxT("should be running") );
c2ca375c
VZ
60
61 gtk_timeout_remove( m_tag );
62 m_tag = -1;
ff7b1510 63}
c801d85f 64
1e6feb95
VZ
65#endif // wxUSE_TIMER
66