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