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