X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2FTimeout.h;h=e642a989e1b70f4891da70990796c0914ecfb1c8;hb=558e849e692cc72ea74ac3859405b85e54c6e315;hp=717096f83ef8b46b1605961f8fcb635c13bdf15a;hpb=f490ae76abc44001313dfe65e0729b964ea4f76b;p=lyx.git diff --git a/src/frontends/Timeout.h b/src/frontends/Timeout.h index 717096f83e..e642a989e1 100644 --- a/src/frontends/Timeout.h +++ b/src/frontends/Timeout.h @@ -1,44 +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 - -#ifdef __GNUG__ -#pragma interface -#endif - -#include +#include -#ifdef SIGC_CXX_NAMESPACES -using SigC::Signal0; -#endif /** * 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 @@ -46,7 +39,7 @@ public: /// restart the timer void restart(); /// signal emitted on timer expiry - Signal0 timeout; + boost::signal0 timeout; /// emit the signal void emit(); /// set the timer type @@ -54,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 const pimpl_; /// one-shot or repeating Type type; /// timeout value in milliseconds