]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/timer.cpp
added encoding conversion to wxHTML
[wxWidgets.git] / src / gtk1 / timer.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: timer.cpp
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
03f38c58 45wxTimer::wxTimer()
c801d85f 46{
83624f79 47 m_tag = -1;
0470b1e6 48 m_milli = 1000;
83624f79 49 m_oneShot = FALSE;
ff7b1510 50}
c801d85f 51
03f38c58 52wxTimer::~wxTimer()
c801d85f 53{
0470b1e6 54 wxTimer::Stop();
ff7b1510 55}
c801d85f 56
03f38c58 57bool wxTimer::Start( int millisecs, bool oneShot )
c801d85f 58{
0470b1e6 59 (void)wxTimerBase::Start(millisecs, oneShot);
03f38c58 60
0470b1e6 61 m_tag = gtk_timeout_add( m_milli, timeout_callback, this );
03f38c58 62
83624f79 63 return TRUE;
ff7b1510 64}
c801d85f 65
03f38c58 66void wxTimer::Stop()
c801d85f 67{
83624f79
RR
68 if (m_tag != -1)
69 {
70 gtk_timeout_remove( m_tag );
71 m_tag = -1;
72 }
ff7b1510 73}
c801d85f 74