]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xformsTimeout.C
remove defaults stuff, let Qt handle no toolbar
[lyx.git] / src / frontends / xforms / xformsTimeout.C
1 /**
2  * \file xformsTimeout.C
3  * Copyright 2001 LyX Team
4  * Read COPYING
5  *
6  * \author Lars Gullik Bjønnes
7  * \author John Levon
8  * \author Angus Leeming
9  */
10
11 #include <config.h>
12
13 #include "xformsTimeout.h"
14 #include "debug.h"
15
16 #include FORMS_H_LOCATION
17
18
19 Timeout::Timeout(unsigned int msec, Type t)
20         : pimpl_(new xformsTimeout(*this)), type(t), timeout_ms(msec)
21 {}
22
23
24 namespace {
25
26 extern "C"
27 void C_TimeoutCB(int, void * data)
28 {
29         xformsTimeout * to = static_cast<xformsTimeout *>(data);
30         to->emitCB();
31 }
32
33 } // namespace anon
34
35
36 xformsTimeout::xformsTimeout(Timeout & owner)
37         : Timeout::Impl(owner), timeout_id(-1)
38 {}
39
40
41 void xformsTimeout::emitCB()
42 {
43         emit();
44 }
45
46
47 bool xformsTimeout::running() const
48 {
49         return timeout_id != -1;
50 }
51
52
53 void xformsTimeout::start()
54 {
55         if (running()) {
56                 lyxerr << "Timeout::start: already running!" << std::endl;
57
58         } else {
59                 timeout_id = fl_add_timeout(timeout_ms(),
60                                             C_TimeoutCB, this);
61         }
62 }
63
64
65 void xformsTimeout::stop()
66 {
67         if (running()) {
68                 fl_remove_timeout(timeout_id);
69                 timeout_id = -1;
70         }
71 }
72
73
74 void xformsTimeout::reset()
75 {
76         timeout_id = -1;
77 }