]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Timeout_pimpl.C
Added // -*- C++ -*- to the top of all files in controllers/ and xforms/
[lyx.git] / src / frontends / xforms / Timeout_pimpl.C
1 // -*- C++ -*-
2 /**
3  * \file Timeout_pimpl.C
4  * Copyright 2001 LyX Team
5  * Read COPYING
6  *
7  * \author Lars Gullik Bjønnes
8  * \author John Levon
9  */
10
11 #include <config.h>
12
13 #include FORMS_H_LOCATION
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 #include "Timeout_pimpl.h"
20 #include "debug.h"
21
22 using std::endl;
23
24 namespace {
25
26 extern "C" 
27 void C_intern_timeout_cb(int, void * data)
28 {
29         Timeout * to = static_cast<Timeout *>(data);
30         to->emit();
31 }
32
33 } // namespace anon
34
35
36 Timeout::Pimpl::Pimpl(Timeout * owner)
37         : owner_(owner), timeout_id(-1)
38 {
39 }
40
41
42 void Timeout::Pimpl::reset()
43 {
44         timeout_id = -1;
45 }
46
47
48 void Timeout::Pimpl::start()
49 {
50         if (timeout_id != -1)
51                 lyxerr << "Timeout::start: already running!" << endl;
52         timeout_id = fl_add_timeout(owner_->timeout_ms,
53                                     C_intern_timeout_cb, owner_);
54 }
55
56
57 void Timeout::Pimpl::stop()
58 {
59         if (timeout_id != -1) {
60                 fl_remove_timeout(timeout_id);
61                 timeout_id = -1;
62         }
63 }