]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Tooltips.h
Give people a rational basis to describe what they dislike about tooltips!!!
[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  * Tooltips for xforms. xforms 0.89 supports them directly, but 0.88 needs
10  * a bit of jiggery pokery. This class wraps it all up in a neat interface.
11  * Based on code originally in Toolbar_pimpl.C that appears to have been
12  * written by Matthias Ettrich and Jean-Marc Lasgouttes.
13  */
14
15 #ifndef TOOLTIPS_H
16 #define TOOLTIPS_H
17
18 #include "LString.h"
19 #include <boost/utility.hpp>
20 #include <sigc++/signal_system.h>
21 #include FORMS_H_LOCATION // Can't forward-declare FL_OBJECT
22 #include <map>
23
24 #ifdef __GNUG__
25 #pragma interface
26 #endif
27
28 class Tooltips : boost::noncopyable, public SigC::Object {
29 public:
30         Tooltips();
31
32         /// Initialise a tooltip for this ob
33         void initTooltip(FL_OBJECT * ob, string const & tip);
34
35         /// Are the tooltips on or off?
36         static bool enabled() { return enabled_; }
37
38 #if FL_REVISION < 89
39
40         /// Return the tooltip associated with this object
41         string const getTooltip(FL_OBJECT *) const;
42
43 #endif
44
45 private:
46
47         /// Are the tooltips on or off?
48         static bool enabled_;
49
50         /** This method is connected to Dialogs::toggleTooltips and toggles
51          *  the state of enabled_
52          */
53         static void toggleEnabled();
54
55         /** Once enabled_ is changed, then this signal is emitted to update
56          *  all the tooltips.
57          */
58         static SigC::Signal0<void> tooltipsToggled;
59
60         /// This method is connected to the tooltipsToggled signal.
61         void toggleTooltips();
62
63         /// The tooltips are stored so that they can be turned on and off
64         typedef std::map<FL_OBJECT *, string> TooltipsMap;
65
66         TooltipsMap tooltipsMap;
67
68 #if FL_REVISION < 89
69
70         FL_OBJECT * tooltip_timer_;
71
72 #endif // FL_REVISION >= 89
73 };
74
75 #endif // TOOLTIPS_H