]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Tooltips.h
Really dull and boring header shit
[lyx.git] / src / frontends / xforms / Tooltips.h
1 // -*- C++ -*-
2 /**
3  * \file Tooltips.h
4  * Read the file COPYING
5  *
6  * \author Angus Leeming 
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 /* Tooltips for xforms. xforms 0.89 supports them directly, but 0.88 needs
12  * a bit of jiggery pokery. This class wraps it all up in a neat interface.
13  * Based on code originally in Toolbar_pimpl.C that appears to have been
14  * written by Matthias Ettrich and Jean-Marc Lasgouttes.
15  */
16
17 #ifndef TOOLTIPS_H
18 #define TOOLTIPS_H
19
20 #include "LString.h"
21
22 #include <boost/utility.hpp>
23 #include <boost/signals/signal0.hpp>
24 #include <boost/signals/trackable.hpp>
25
26 #include "forms_fwd.h" // Can't forward-declare FL_OBJECT
27
28 #include <map>
29
30 #ifdef __GNUG__
31 #pragma interface
32 #endif
33
34 class Tooltips : boost::noncopyable, public boost::signals::trackable {
35 public:
36         ///
37         Tooltips();
38
39         /// Initialise a tooltip for this ob.
40         void init(FL_OBJECT * ob, string const & tip);
41
42         /// Are the tooltips on or off?
43         static bool enabled() { return enabled_; }
44
45         /// This method is connected to the tooltipsToggled signal.
46         void set();
47
48 #if FL_VERSION < 1 && FL_REVISION < 89
49
50         /** Return the tooltip associated with this object.
51          *  Required by an xforms callback routine.
52          */
53         string const get(FL_OBJECT *) const;
54
55 #endif
56
57         /** This method is connected to Dialogs::toggleTooltips and toggles
58          *  the state of enabled_.
59          */
60         static void toggleEnabled();
61
62 private:
63
64         /// Are the tooltips on or off?
65         static bool enabled_;
66
67         /** Once enabled_ is changed, then this signal is emitted to update
68          *  all the tooltips.
69          */
70         static boost::signal0<void> toggled;
71
72         /// The tooltips are stored so that they can be turned on and off.
73         typedef std::map<FL_OBJECT *, string> TooltipsMap;
74
75         TooltipsMap tooltipsMap;
76
77 #if FL_VERSION < 1 && FL_REVISION < 89
78
79         /** A timer is started once the mouse enters an object, so that the
80          *  tip appears a short delay afterwards.
81          */
82         FL_OBJECT * tooltip_timer_;
83
84 #endif
85 };
86
87 #endif // TOOLTIPS_H