]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Timeout_pimpl.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / Timeout_pimpl.C
1 /**
2  * \file xforms/Timeout_pimpl.C
3  * Copyright 2001 LyX Team
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS
11  */
12
13 #include <config.h>
14
15 #include FORMS_H_LOCATION
16
17 #ifdef __GNUG__
18 #pragma implementation
19 #endif
20
21 #include "Timeout_pimpl.h"
22 #include "debug.h"
23
24 using std::endl;
25
26 namespace {
27
28 extern "C" {
29
30 static
31 void C_intern_timeout_cb(int, void * data)
32 {
33         Timeout * to = static_cast<Timeout *>(data);
34         to->emit();
35 }
36
37 }
38
39 } // namespace anon
40
41
42 Timeout::Pimpl::Pimpl(Timeout * owner)
43         : owner_(owner), timeout_id(-1)
44 {
45 }
46
47
48 void Timeout::Pimpl::reset()
49 {
50         timeout_id = -1;
51 }
52
53
54 bool Timeout::Pimpl::running() const
55 {
56         return timeout_id != -1;
57 }
58
59
60 void Timeout::Pimpl::start()
61 {
62         if (timeout_id != -1)
63                 lyxerr << "Timeout::start: already running!" << endl;
64         timeout_id = fl_add_timeout(owner_->timeout_ms,
65                                     C_intern_timeout_cb, owner_);
66 }
67
68
69 void Timeout::Pimpl::stop()
70 {
71         if (timeout_id != -1) {
72                 fl_remove_timeout(timeout_id);
73                 timeout_id = -1;
74         }
75 }