]> git.lyx.org Git - features.git/commitdiff
Make the GUI instantiation invisible to Timeout.
authorAngus Leeming <leeming@lyx.org>
Sat, 22 Feb 2003 18:01:16 +0000 (18:01 +0000)
committerAngus Leeming <leeming@lyx.org>
Sat, 22 Feb 2003 18:01:16 +0000 (18:01 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6230 a592a061-630c-0410-9148-cb99ea01b6c8

21 files changed:
src/frontends/ChangeLog
src/frontends/Timeout.C
src/frontends/Timeout.h
src/frontends/gnome/ChangeLog
src/frontends/gnome/Makefile.am
src/frontends/gnome/Timeout_pimpl.C [deleted file]
src/frontends/gnome/Timeout_pimpl.h [deleted file]
src/frontends/gnome/gnomeTimeout.C [new file with mode: 0644]
src/frontends/gnome/gnomeTimeout.h [new file with mode: 0644]
src/frontends/qt2/ChangeLog
src/frontends/qt2/Makefile.am
src/frontends/qt2/Timeout_pimpl.C [deleted file]
src/frontends/qt2/Timeout_pimpl.h [deleted file]
src/frontends/qt2/qtTimeout.C [new file with mode: 0644]
src/frontends/qt2/qtTimeout.h [new file with mode: 0644]
src/frontends/xforms/ChangeLog
src/frontends/xforms/Makefile.am
src/frontends/xforms/Timeout_pimpl.C [deleted file]
src/frontends/xforms/Timeout_pimpl.h [deleted file]
src/frontends/xforms/xformsTimeout.C [new file with mode: 0644]
src/frontends/xforms/xformsTimeout.h [new file with mode: 0644]

index 10084e01465ab9620a61ab44eb8616917ded8f26..05aed79c94aff40e903acb13fb7efd1fdad2899c 100644 (file)
@@ -1,3 +1,10 @@
+2003-02-21  Angus Leeming  <leeming@lyx.org>
+
+       * Timeout.[Ch]: define a Timeout::Impl abstract base class from
+       which the GUIs will derive their implementations. Means that
+       we no longer have to look into the GUIs to write the class.
+       Store the implementation in a boost::scoped_ptr, not a raw pointer.
+
 2003-02-21  Angus Leeming  <leeming@lyx.org>
 
        * Dialogs.h: remove forward declarations of InsetBibKey, InsetBibtex.
index 2ecb0442dffb971cef7770007ac7a7884929bb93..0cef024ee9acee35a24f804a3d6ecbd807755284 100644 (file)
 #include <config.h>
 
 #include "Timeout.h"
-#include "debug.h"
-
-#include "Timeout_pimpl.h"
-
-
-Timeout::Timeout(unsigned int msec, Type t)
-       : type(t), timeout_ms(msec)
-{
-       pimpl_ = new Pimpl(this);
-}
+#include "support/LAssert.h"
 
 
 Timeout::~Timeout()
 {
        pimpl_->stop();
-       delete pimpl_;
 }
 
 
@@ -42,17 +32,20 @@ void Timeout::start()
        pimpl_->start();
 }
 
+
 void Timeout::stop()
 {
        pimpl_->stop();
 }
 
+
 void Timeout::restart()
 {
        pimpl_->stop();
        pimpl_->start();
 }
 
+
 void Timeout::emit()
 {
        pimpl_->reset();
@@ -61,6 +54,7 @@ void Timeout::emit()
                pimpl_->start();
 }
 
+
 Timeout & Timeout::setType(Type t)
 {
        type = t;
@@ -70,6 +64,9 @@ Timeout & Timeout::setType(Type t)
 
 Timeout & Timeout::setTimeout(unsigned int msec)
 {
+       // Can't have a timeout of zero!
+       lyx::Assert(msec);
+
        timeout_ms = msec;
        return * this;
 }
index afa331decc2da17430cce5b1f77866030f9a8a1b..4d602e475bda8ad4e150aa0e1def282c363a4304 100644 (file)
@@ -13,9 +13,9 @@
 #ifndef TIMEOUT_H
 #define TIMEOUT_H
 
-
 #include <boost/signals/signal0.hpp>
 
+
 /**
  * This class executes the callback when the timeout expires.
  */
@@ -26,7 +26,7 @@ public:
                ONETIME, //< one-shot timer
                CONTINUOUS //< repeating
        };
-       ///
+       /// Note that the c-tor is implemented in the GUI-specific frontends
        Timeout(unsigned int msec, Type = ONETIME);
        ///
        ~Timeout();
@@ -47,13 +47,42 @@ public:
        /// set the timeout value
        Timeout & setTimeout(unsigned int msec);
 
+       /** Base class for the GUI implementation.
+           It must be public so that C callback functions can access its
+           daughter classes.
+        */
+       class Impl
+       {
+       public:
+               ///
+               Impl(Timeout & owner) : owner_(owner) {}
+               ///
+               virtual ~Impl() {}
+               /// Is the timer running?
+               virtual bool running() const = 0;
+               /// start the timer
+               virtual void start() = 0;
+               /// stop the timer
+               virtual void stop() = 0;
+               /// reset
+               virtual void reset() = 0;
+
+       protected:
+               ///
+               void emit() { owner_.emit(); }
+               ///
+               unsigned int timeout_ms() const { return owner_.timeout_ms; }
+
+       private:
+               ///
+               Timeout & owner_;
+       };
+       
 private:
        ///
-       struct Pimpl;
+       friend class Impl;
        ///
-       friend struct Pimpl;
-       /// implementation
-       Pimpl * pimpl_;
+       boost::scoped_ptr<Impl> const pimpl_;
        /// one-shot or repeating
        Type type;
        /// timeout value in milliseconds
index 9b33c9939fe7b804fbb2ff9a5c4301a2ad4cf3c7..3924ef2b1c7e7b295a02a0fb68885809b8aae752 100644 (file)
@@ -1,3 +1,9 @@
+2003-02-21  Angus Leeming  <leeming@lyx.org>
+
+       * Timeout_pimpl.[Ch]: removed.
+       * gnomeTimeout.[Ch]: new files, replacing the above.
+       The gnomeTimeout class derives from Timeout::Impl.
+
 2003-02-21  Angus Leeming  <leeming@lyx.org>
 
        * FileDialog.C (FileDialog): no need for LyXView *.
index 37859adb26d857b485e65fbcb171afb853aad8c7..aacdb81fbc1de1814d226b8a519f055d10360710 100644 (file)
@@ -152,8 +152,8 @@ libgnome_la_SOURCES = \
        gnomeBC.C \
        gnomeBC.h \
        lyx_gui.C \
-       Timeout_pimpl.C \
-       Timeout_pimpl.h \
+       gnomeTimeout.C \
+       gnomeTimeout.h \
        pixbutton.h 
 
 libgnome.la: xforms.lo $(libgnome_la_OBJECTS) $(libgnome_la_DEPENDENCIES)
diff --git a/src/frontends/gnome/Timeout_pimpl.C b/src/frontends/gnome/Timeout_pimpl.C
deleted file mode 100644 (file)
index 92af7e6..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * \file gnome/Timeout_pimpl.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Baruch Even
- * \author Michael Koziarski
- *
- * Full author contact details are available in file CREDITS
- */
-
-#include <config.h>
-
-
-#include <glibmm/main.h>
-#include "Timeout_pimpl.h"
-#include "debug.h"
-
-Timeout::Pimpl::Pimpl(Timeout * owner)
-  : owner_(owner)
-{
-}
-
-void Timeout::Pimpl::reset()
-{
-       stop();
-}
-
-bool Timeout::Pimpl::running() const
-{
-       return running_;
-}
-
-void Timeout::Pimpl::start()
-{
-       if (conn_.connected()) {
-               lyxerr << "Timeout::start: already running!" << std::endl;
-               stop();
-       }
-
-       conn_ = Glib::signal_timeout().connect(
-                        SigC::slot(*this, &Timeout::Pimpl::timeoutEvent),
-                        owner_->timeout_ms
-                       );
-       running_ = true;
-}
-
-
-void Timeout::Pimpl::stop()
-{
-       conn_.disconnect();
-       running_ = false;
-}
-
-
-bool Timeout::Pimpl::timeoutEvent()
-{
-       owner_->emit();
-       return false; // discontinue emitting timeouts.
-}
diff --git a/src/frontends/gnome/Timeout_pimpl.h b/src/frontends/gnome/Timeout_pimpl.h
deleted file mode 100644 (file)
index 8dfb26c..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// -*- C++ -*-
-/**
- * \file gnome/Timeout_pimpl.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Baruch Even
- *
- * Full author contact details are available in file CREDITS
- */
-#ifndef TIMEOUTPIMPL_H
-#define TIMEOUTPIMPL_H
-
-#include "frontends/Timeout.h"
-#include "glib.h" // for gint
-
-#include <sigc++/sigc++.h>
-
-
-/**
- * This class executes the callback when the timeout expires
- * using Gnome mechanisms
- */
-struct Timeout::Pimpl : public SigC::Object {
-public:
-       ///
-       Pimpl(Timeout * owner_);
-       /// start the timer
-       void start();
-       /// stop the timer
-       void stop();
-       /// reset
-       void reset();
-       /// Is the timer running?
-       bool running() const;
-
-
-public:
-       /// The timeout signal, this gets called when the timeout passed.
-       bool timeoutEvent();
-private:
-       /// the owning timer
-       Timeout * owner_;
-       /// Timer connection
-       SigC::Connection conn_;
-       /// Used for running as SigC::Connection::connected() isn't const
-       bool running_;
-};
-
-#endif
diff --git a/src/frontends/gnome/gnomeTimeout.C b/src/frontends/gnome/gnomeTimeout.C
new file mode 100644 (file)
index 0000000..0d53b5a
--- /dev/null
@@ -0,0 +1,67 @@
+/**
+ * \file gnomeTimeout.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Baruch Even
+ * \author Michael Koziarski
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#include <glibmm/main.h>
+#include "gnomeTimeout.h"
+#include "debug.h"
+
+
+Timeout::Timeout(unsigned int msec, Type t)
+       : pimpl_(new gnomeTimeout(*this)), type(t), timeout_ms(msec)
+{}
+
+
+gnomeTimeout::(gnomeTimeoutTimeout * owner)
+       : Timeout::Impl(owner), timeout_id(-1)
+{}
+
+
+void gnomeTimeout::reset()
+{
+       stop();
+}
+
+
+bool gnomeTimeout::running() const
+{
+       return running_;
+}
+
+
+void gnomeTimeout::start()
+{
+       if (conn_.connected()) {
+               lyxerr << "Timeout::start: already running!" << std::endl;
+               stop();
+       }
+
+       conn_ = Glib::signal_timeout().connect(
+                        SigC::slot(*this, &Timeout::Pimpl::timeoutEvent),
+                        timeout_ms()
+                       );
+       running_ = true;
+}
+
+
+void gnomeTimeout::stop()
+{
+       conn_.disconnect();
+       running_ = false;
+}
+
+
+bool gnomeTimeout::timeoutEvent()
+{
+       emit();
+       return false; // discontinue emitting timeouts.
+}
diff --git a/src/frontends/gnome/gnomeTimeout.h b/src/frontends/gnome/gnomeTimeout.h
new file mode 100644 (file)
index 0000000..8f28674
--- /dev/null
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+/**
+ * \file gnomeTimeout.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Baruch Even
+ *
+ * Full author contact details are available in file CREDITS
+ */
+#ifndef GNOMETIMEOUT_H
+#define GNOMETIMEOUT_H
+
+#include "frontends/Timeout.h"
+#include "glib.h" // for gint
+
+#include <sigc++/sigc++.h>
+
+
+/**
+ * This class executes the callback when the timeout expires
+ * using Gnome mechanisms
+ */
+struct gnomeTimeout : public SigC::Object, public Timeout::Impl {
+public:
+       ///
+       gnomeTimeout(Timeout * owner_);
+       /// start the timer
+       void start();
+       /// stop the timer
+       void stop();
+       /// reset
+       void reset();
+       /// Is the timer running?
+       bool running() const;
+
+
+public:
+       /// The timeout signal, this gets called when the timeout passed.
+       bool timeoutEvent();
+private:
+       /// Timer connection
+       SigC::Connection conn_;
+       /// Used for running as SigC::Connection::connected() isn't const
+       bool running_;
+};
+
+#endif // GNOMETIMEOUT
index c9e919385d601ae11584413eef8be8a748ab9819..3a7e57061dfabb7626aac1a11b78b0a7d89bf1d1 100644 (file)
@@ -1,3 +1,9 @@
+2003-02-21  Angus Leeming  <leeming@lyx.org>
+
+       * Timeout_pimpl.[Ch]: removed.
+       * qtTimeout.[Ch]: new files, replacing the above.
+       The qtTimeout class derives from Timeout::Impl.
+
 2003-02-21  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * qfont_loader.C (addFontPath): make debug messages quieter
index 29a6b77964357c2c60c7517e9f5c0bc9cf91f79a..5b4155514c4e0bae6bee0e53b3f97eab1c348cfe 100644 (file)
@@ -24,7 +24,7 @@ libqt2_la_SOURCES = \
        LyXKeySymFactory.C \
        LyXScreenFactory.C \
        Menubar_pimpl.C Menubar_pimpl.h \
-       Timeout_pimpl.C Timeout_pimpl.h \
+       qtTimeout.C qtTimeout.h \
        QAbout.C QAbout.h \
        QBibitem.C QBibitem.h \
        QBibtex.C QBibtex.h \
diff --git a/src/frontends/qt2/Timeout_pimpl.C b/src/frontends/qt2/Timeout_pimpl.C
deleted file mode 100644 (file)
index 3edad5f..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * \file qt2/Timeout_pimpl.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS
- */
-
-#include <config.h>
-
-
-#include "Timeout_pimpl.h"
-#include "debug.h"
-
-using std::endl;
-
-Timeout::Pimpl::Pimpl(Timeout * owner)
-       : owner_(owner), timeout_id(-1)
-{
-}
-
-
-void Timeout::Pimpl::timerEvent(QTimerEvent *)
-{
-       owner_->emit();
-}
-
-
-void Timeout::Pimpl::reset()
-{
-       killTimers();
-       timeout_id = -1;
-}
-
-
-bool Timeout::Pimpl::running() const
-{
-       return timeout_id != -1;
-}
-
-
-void Timeout::Pimpl::start()
-{
-       if (running())
-               lyxerr << "Timeout::start: already running!" << endl;
-       timeout_id = startTimer(owner_->timeout_ms);
-}
-
-
-void Timeout::Pimpl::stop()
-{
-       if (running())
-               reset();
-}
diff --git a/src/frontends/qt2/Timeout_pimpl.h b/src/frontends/qt2/Timeout_pimpl.h
deleted file mode 100644 (file)
index f8b5f7d..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-// -*- C++ -*-
-/**
- * \file qt2/Timeout_pimpl.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS
- */
-
-#ifndef TIMEOUTPIMPL_H
-#define TIMEOUTPIMPL_H
-
-
-#include "frontends/Timeout.h"
-#include <qobject.h>
-
-// stupid Qt
-#undef emit
-
-/**
- * This class executes the callback when the timeout expires
- * using Qt mechanisms
- */
-struct Timeout::Pimpl : QObject {
-public:
-       ///
-       Pimpl(Timeout * owner_);
-       /// start the timer
-       void start();
-       /// stop the timer
-       void stop();
-       /// reset
-       void reset();
-       /// is the timer running ?
-       bool running() const;
-protected:
-       /// slot
-       virtual void timerEvent(QTimerEvent *);
-private:
-       /// the owning timer
-       Timeout * owner_;
-       /// QTimer id
-       int timeout_id;
-};
-
-#endif
diff --git a/src/frontends/qt2/qtTimeout.C b/src/frontends/qt2/qtTimeout.C
new file mode 100644 (file)
index 0000000..36bfb4b
--- /dev/null
@@ -0,0 +1,58 @@
+/**
+ * \file qtTimeout.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#include "qtTimeout.h"
+#include "debug.h"
+
+
+Timeout::Timeout(unsigned int msec, Type t)
+       : pimpl_(new qtTimeout(*this)), type(t), timeout_ms(msec)
+{}
+
+
+qtTimeout::qtTimeout(Timeout & owner)
+       : Timeout::Impl(owner), timeout_id(-1)
+{}
+
+
+void qtTimeout::timerEvent(QTimerEvent *)
+{
+       emit();
+}
+
+
+void qtTimeout::reset()
+{
+       killTimers();
+       timeout_id = -1;
+}
+
+
+bool qtTimeout::running() const
+{
+       return timeout_id != -1;
+}
+
+
+void qtTimeout::start()
+{
+       if (running())
+               lyxerr << "Timeout::start: already running!" << std::endl;
+       timeout_id = startTimer(timeout_ms());
+}
+
+
+void qtTimeout::stop()
+{
+       if (running())
+               reset();
+}
diff --git a/src/frontends/qt2/qtTimeout.h b/src/frontends/qt2/qtTimeout.h
new file mode 100644 (file)
index 0000000..649df71
--- /dev/null
@@ -0,0 +1,47 @@
+// -*- C++ -*-
+/**
+ * \file qtTimeout.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef QTTIMEOUT_H
+#define QTTIMEOUT_H
+
+#include "frontends/Timeout.h"
+#include <qobject.h> 
+
+// stupid Qt
+#undef emit
+
+/**
+ * This class executes the callback when the timeout expires
+ * using Qt mechanisms
+ */
+struct qtTimeout : QObject, public Timeout::Impl {
+public:
+       ///
+       qtTimeout(Timeout & owner_);
+       ///
+       virtual bool running() const;
+       /// start the timer
+       virtual void start();
+       /// stop the timer
+       virtual void stop();
+       /// reset
+       virtual void reset();
+
+protected:
+       /// slot
+       virtual void timerEvent(QTimerEvent *);
+
+private:
+       /// timout id
+       int timeout_id;
+};
+
+#endif // QTTIMEOUT_H
index 214806be658facc1a578187fd646e6b0c30c3efa..404c0145c373d9cd8146d83aad006a07d11399ed 100644 (file)
@@ -1,3 +1,9 @@
+2003-02-21  Angus Leeming  <leeming@lyx.org>
+
+       * Timeout_pimpl.[Ch]: removed.
+       * xformsTimeout.[Ch]: new files, replacing the above.
+       The xformsTimeout class derives from Timeout::Impl.
+
 2003-02-21  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * xfont_loader.C (addFontPath): make debug messages quieter
index be6da8f9bfe7eaa9b805ac0e75e9ecbde45c5eaf..a67ac6279a6d4cb66a2d12d1f91b17db9bacad85 100644 (file)
@@ -9,8 +9,6 @@ INCLUDES = -I$(top_srcdir)/images -I$(top_srcdir)/src \
 
 SUBDIRS = forms
 
-EXTRA_DIST = xformsImage.C xformsImage.h
-
 # Alphabetical order please.  It makes it easier to figure out what's missing.
 libxforms_la_SOURCES = \
        forms_fwd.h \
@@ -35,10 +33,12 @@ libxforms_la_SOURCES = \
        xforms_helpers.h \
        xforms_resize.C \
        xforms_resize.h \
-       xformsImage.C \
-       xformsImage.h \
        xformsBC.C \
        xformsBC.h \
+       xformsImage.C \
+       xformsImage.h \
+       xformsTimeout.C \
+       xformsTimeout.h \
        xscreen.C \
        xscreen.h \
        Alert_pimpl.C \
@@ -146,8 +146,6 @@ libxforms_la_SOURCES = \
        Menubar_pimpl.h \
        RadioButtonGroup.C \
        RadioButtonGroup.h \
-       Timeout_pimpl.C \
-       Timeout_pimpl.h \
        Toolbar_pimpl.C \
        Toolbar_pimpl.h \
        Tooltips.C \
diff --git a/src/frontends/xforms/Timeout_pimpl.C b/src/frontends/xforms/Timeout_pimpl.C
deleted file mode 100644 (file)
index ca08385..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * \file xforms/Timeout_pimpl.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Lars Gullik Bjønnes
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS
- */
-
-#include <config.h>
-
-#include FORMS_H_LOCATION
-
-
-#include "Timeout_pimpl.h"
-#include "debug.h"
-
-using std::endl;
-
-namespace {
-
-extern "C" {
-
-static
-void C_intern_timeout_cb(int, void * data)
-{
-       Timeout * to = static_cast<Timeout *>(data);
-       to->emit();
-}
-
-}
-
-} // namespace anon
-
-
-Timeout::Pimpl::Pimpl(Timeout * owner)
-       : owner_(owner), timeout_id(-1)
-{
-}
-
-
-void Timeout::Pimpl::reset()
-{
-       timeout_id = -1;
-}
-
-
-bool Timeout::Pimpl::running() const
-{
-       return timeout_id != -1;
-}
-
-
-void Timeout::Pimpl::start()
-{
-       if (timeout_id != -1)
-               lyxerr << "Timeout::start: already running!" << endl;
-       timeout_id = fl_add_timeout(owner_->timeout_ms,
-                                   C_intern_timeout_cb, owner_);
-}
-
-
-void Timeout::Pimpl::stop()
-{
-       if (timeout_id != -1) {
-               fl_remove_timeout(timeout_id);
-               timeout_id = -1;
-       }
-}
diff --git a/src/frontends/xforms/Timeout_pimpl.h b/src/frontends/xforms/Timeout_pimpl.h
deleted file mode 100644 (file)
index df5b858..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-// -*- C++ -*-
-/**
- * \file xforms/Timeout_pimpl.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Lars Gullik Bjønnes
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS
- */
-#ifndef TIMEOUTPIMPL_H
-#define TIMEOUTPIMPL_H
-
-#include "frontends/Timeout.h"
-
-
-/**
- * This class executes the callback when the timeout expires
- * using XForms mechanisms
- */
-struct Timeout::Pimpl {
-public:
-       ///
-       Pimpl(Timeout * owner_);
-       /// Is the timer running?
-       bool running() const;
-       /// start the timer
-       void start();
-       /// stop the timer
-       void stop();
-       /// reset
-       void reset();
-
-private:
-       /// the owning timer
-       Timeout * owner_;
-       /// xforms id
-       int timeout_id;
-};
-
-#endif
diff --git a/src/frontends/xforms/xformsTimeout.C b/src/frontends/xforms/xformsTimeout.C
new file mode 100644 (file)
index 0000000..658ae9b
--- /dev/null
@@ -0,0 +1,77 @@
+/**
+ * \file xformsTimeout.C
+ * Copyright 2001 LyX Team
+ * Read COPYING
+ *
+ * \author Lars Gullik Bjønnes
+ * \author John Levon
+ * \author Angus Leeming
+ */
+
+#include <config.h>
+
+#include "xformsTimeout.h"
+#include "debug.h"
+
+#include FORMS_H_LOCATION
+
+
+Timeout::Timeout(unsigned int msec, Type t)
+       : pimpl_(new xformsTimeout(*this)), type(t), timeout_ms(msec)
+{}
+
+
+namespace {
+
+extern "C"
+void C_TimeoutCB(int, void * data)
+{
+       xformsTimeout * to = static_cast<xformsTimeout *>(data);
+       to->emitCB();
+}
+
+} // namespace anon
+
+
+xformsTimeout::xformsTimeout(Timeout & owner)
+       : Timeout::Impl(owner), timeout_id(-1)
+{}
+
+
+void xformsTimeout::emitCB()
+{
+       emit();
+}
+
+
+bool xformsTimeout::running() const
+{
+       return timeout_id != -1;
+}
+
+
+void xformsTimeout::start()
+{
+       if (running()) {
+               lyxerr << "Timeout::start: already running!" << std::endl;
+
+       } else {
+               timeout_id = fl_add_timeout(timeout_ms(),
+                                           C_TimeoutCB, this);
+       }
+}
+
+
+void xformsTimeout::stop()
+{
+       if (running()) {
+               fl_remove_timeout(timeout_id);
+               timeout_id = -1;
+       }
+}
+
+
+void xformsTimeout::reset()
+{
+       timeout_id = -1;
+}
diff --git a/src/frontends/xforms/xformsTimeout.h b/src/frontends/xforms/xformsTimeout.h
new file mode 100644 (file)
index 0000000..c5273ca
--- /dev/null
@@ -0,0 +1,44 @@
+// -*- C++ -*-
+/**
+ * \file xformsTimeout.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author John Levon
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef XFORMSTIMEOUT_H
+#define XFORMSTIMEOUT_H
+
+#include "frontends/Timeout.h"
+
+
+/**
+ * This class executes the callback when the timeout expires
+ * using xforms mechanisms
+ */
+class xformsTimeout : public Timeout::Impl {
+public:
+       ///
+       xformsTimeout(Timeout &);
+       ///
+       virtual bool running() const;
+       ///
+       virtual void start();
+       ///
+       virtual void stop();
+       ///
+       virtual void reset();
+       /// xforms callback function
+       void emitCB();
+
+private:
+       ///
+       int timeout_id;
+};
+
+#endif // XFORMSTIMEOUT_H