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