]> git.lyx.org Git - lyx.git/blob - src/Timeout.h
Added patches from John and applied some fixes.
[lyx.git] / src / Timeout.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *        
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2000 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef TIMEOUT_H
13 #define TIMEOUT_H
14
15 #include <config.h>
16
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
20
21 #include <sigc++/signal_system.h>
22 /* ugly hack to prevent Qt's '#define emit ...' from 
23  * screwing us up below - jbl 2000/8/10 
24  */
25 #ifdef KDEGUI
26 #undef emit
27 #endif
28
29
30 #ifdef SIGC_CXX_NAMESPACES
31 using SigC::Signal0;
32 #endif
33
34 /** This class executes the callback when the timeout expires.
35     This class currently uses a regular callback, later it will use
36     signals and slots to provide the same.
37 */
38 class Timeout {
39 public:
40         ///
41         enum Type {
42                 ///
43                 ONETIME,
44                 ///
45                 CONTINOUS
46         };
47         ///
48         Timeout();
49         ///
50         Timeout(int msec, Type = ONETIME);
51         ///
52         ~Timeout();
53         ///
54         void start();
55         ///
56         void stop();
57         ///
58         void restart();
59         ///
60         Signal0<void> timeout;
61         ///
62         void emit();
63         ///
64         void setType(Type t);
65         ///
66         void setTimeout(int msec);
67 private:
68         ///
69         Type type;
70         ///
71         int timeout_ms;
72         ///
73         int timeout_id;
74 };
75
76 #endif