]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/timer.cpp
linking fixes
[wxWidgets.git] / src / gtk / timer.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
ed791986 2// Name: gtk/timer.cpp
1e6feb95 3// Purpose: wxTimer implementation
c801d85f 4// Author: Robert Roebling
a81258be 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
e1393d82 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
10
11#ifdef __GNUG__
12#pragma implementation "timer.h"
13#endif
14
1e6feb95
VZ
15#include "wx/defs.h"
16
17#if wxUSE_TIMER
18
c801d85f
KB
19#include "wx/timer.h"
20
83624f79
RR
21#include "gtk/gtk.h"
22
1e6feb95 23// ----------------------------------------------------------------------------
c801d85f 24// wxTimer
1e6feb95 25// ----------------------------------------------------------------------------
c801d85f 26
1e6feb95 27IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
c801d85f 28
7b90a8f2 29static gint timeout_callback( gpointer data )
c801d85f 30{
83624f79 31 wxTimer *timer = (wxTimer*)data;
e1393d82 32
f6577bba
RR
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 */
924ef850 36 gdk_threads_enter();
e1393d82 37
83624f79 38 timer->Notify();
03f38c58 39
f6577bba 40 /* release lock again */
924ef850 41 gdk_threads_leave();
f6577bba 42
0470b1e6 43 if ( timer->IsOneShot() )
e1393d82 44 return FALSE;
03f38c58 45
83624f79 46 return TRUE;
ff7b1510 47}
c801d85f 48
ed791986 49void wxTimer::Init()
c801d85f 50{
83624f79 51 m_tag = -1;
0470b1e6 52 m_milli = 1000;
ff7b1510 53}
c801d85f 54
03f38c58 55wxTimer::~wxTimer()
c801d85f 56{
0470b1e6 57 wxTimer::Stop();
ff7b1510 58}
c801d85f 59
03f38c58 60bool wxTimer::Start( int millisecs, bool oneShot )
c801d85f 61{
0470b1e6 62 (void)wxTimerBase::Start(millisecs, oneShot);
03f38c58 63
0470b1e6 64 m_tag = gtk_timeout_add( m_milli, timeout_callback, this );
03f38c58 65
83624f79 66 return TRUE;
ff7b1510 67}
c801d85f 68
03f38c58 69void wxTimer::Stop()
c801d85f 70{
83624f79
RR
71 if (m_tag != -1)
72 {
73 gtk_timeout_remove( m_tag );
74 m_tag = -1;
75 }
ff7b1510 76}
c801d85f 77
1e6feb95
VZ
78#endif // wxUSE_TIMER
79