]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/timer.cpp
show the standard wxWin fonts (modified patch 530698)
[wxWidgets.git] / src / gtk1 / 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
90350682 29extern "C" 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
574bf507
RR
64 if (m_tag != -1)
65 gtk_timeout_remove( m_tag );
66
0470b1e6 67 m_tag = gtk_timeout_add( m_milli, timeout_callback, this );
03f38c58 68
83624f79 69 return TRUE;
ff7b1510 70}
c801d85f 71
03f38c58 72void wxTimer::Stop()
c801d85f 73{
83624f79
RR
74 if (m_tag != -1)
75 {
76 gtk_timeout_remove( m_tag );
77 m_tag = -1;
78 }
ff7b1510 79}
c801d85f 80
1e6feb95
VZ
81#endif // wxUSE_TIMER
82