+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.
#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_;
}
pimpl_->start();
}
+
void Timeout::stop()
{
pimpl_->stop();
}
+
void Timeout::restart()
{
pimpl_->stop();
pimpl_->start();
}
+
void Timeout::emit()
{
pimpl_->reset();
pimpl_->start();
}
+
Timeout & Timeout::setType(Type t)
{
type = t;
Timeout & Timeout::setTimeout(unsigned int msec)
{
+ // Can't have a timeout of zero!
+ lyx::Assert(msec);
+
timeout_ms = msec;
return * this;
}
#ifndef TIMEOUT_H
#define TIMEOUT_H
-
#include <boost/signals/signal0.hpp>
+
/**
* This class executes the callback when the timeout expires.
*/
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();
/// 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
+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 *.
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)
+++ /dev/null
-/**
- * \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.
-}
+++ /dev/null
-// -*- 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
--- /dev/null
+/**
+ * \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.
+}
--- /dev/null
+// -*- 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
+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
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 \
+++ /dev/null
-/**
- * \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();
-}
+++ /dev/null
-// -*- 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
--- /dev/null
+/**
+ * \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();
+}
--- /dev/null
+// -*- 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
+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
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 \
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 \
Menubar_pimpl.h \
RadioButtonGroup.C \
RadioButtonGroup.h \
- Timeout_pimpl.C \
- Timeout_pimpl.h \
Toolbar_pimpl.C \
Toolbar_pimpl.h \
Tooltips.C \
+++ /dev/null
-/**
- * \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;
- }
-}
+++ /dev/null
-// -*- 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
--- /dev/null
+/**
+ * \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;
+}
--- /dev/null
+// -*- 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