]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/Timeout.h
Handle Qt-style file filters like
[lyx.git] / src / frontends / Timeout.h
index 281e7d9f350c3bedc539b88ad1a820ffc06e4b27..e642a989e1b70f4891da70990796c0914ecfb1c8 100644 (file)
@@ -1,41 +1,37 @@
 // -*- C++ -*-
 /**
  * \file Timeout.h
- * Copyright 2001 LyX Team
- * Read COPYING
+ * 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 TIMEOUT_H
 #define TIMEOUT_H
 
-#include <config.h>
-
-#ifdef __GNUG__
-#pragma interface
-#endif
+#include <boost/signals/signal0.hpp>
 
-#include <sigc++/signal_system.h>
 
 /**
  * This class executes the callback when the timeout expires.
  */
 class Timeout {
 public:
-       ///
+       /// the timeout type
        enum Type {
-               /// one-shot timer
-               ONETIME,
-               /// repeating
-               CONTINUOUS
+               ONETIME, //< one-shot timer
+               CONTINUOUS //< repeating
        };
-       ///
-       Timeout();
-       ///
+       /// Note that the c-tor is implemented in the GUI-specific frontends
        Timeout(unsigned int msec, Type = ONETIME);
        ///
        ~Timeout();
+       /// Is the timer running?
+       bool running() const;
        /// start the timer
        void start();
        /// stop the timer
@@ -43,7 +39,7 @@ public:
        /// restart the timer
        void restart();
        /// signal emitted on timer expiry
-       SigC::Signal0<void> timeout;
+       boost::signal0<void> timeout;
        /// emit the signal
        void emit();
        /// set the timer type
@@ -51,12 +47,42 @@ public:
        /// set the timeout value
        Timeout & setTimeout(unsigned int msec);
 
-private:
-       struct Pimpl;
-       friend struct Pimpl;
-       /// implementation
-       Pimpl * pimpl_;
+       /** 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:
+       ///
+       friend class Impl;
+       ///
+       boost::scoped_ptr<Impl> const pimpl_;
        /// one-shot or repeating
        Type type;
        /// timeout value in milliseconds