lyx_mirror/src/frontends/xforms/xformsTimeout.C
Angus Leeming 0be0fcfd59 If I ever see another licence blurb again, it'll be too soon...
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7598 a592a061-630c-0410-9148-cb99ea01b6c8
2003-08-23 00:17:00 +00:00

80 lines
1.2 KiB
C

/**
* \file xformsTimeout.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
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "xformsTimeout.h"
#include "debug.h"
#include "lyx_forms.h"
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;
}