]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Tooltips.h
change some __GNUG_ to __GNUG__
[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 #include <boost/utility.hpp>
21 #include <sigc++/signal_system.h>
22 #include <map>
23 #include FORMS_H_LOCATION // Can't forward-declare FL_OBJECT
24
25 #ifdef __GNUG__
26 #pragma interface
27 #endif
28
29 class Tooltips : boost::noncopyable, public SigC::Object {
30 public:
31         Tooltips();
32
33         /// Initialise a tooltip for this ob.
34         void init(FL_OBJECT * ob, string const & tip);
35
36         /// Are the tooltips on or off?
37         static bool enabled() { return enabled_; }
38
39         /// This method is connected to the tooltipsToggled signal.
40         void set();
41
42 #if FL_REVISION < 89
43
44         /** Return the tooltip associated with this object.
45          *  Required by an xforms callback routine.
46          */
47         string const get(FL_OBJECT *) const;
48
49 #endif
50
51 private:
52
53         /// Are the tooltips on or off?
54         static bool enabled_;
55
56         /** This method is connected to Dialogs::toggleTooltips and toggles
57          *  the state of enabled_.
58          */
59         static void toggleEnabled();
60
61         /** Once enabled_ is changed, then this signal is emitted to update
62          *  all the tooltips.
63          */
64         static SigC::Signal0<void> toggled;
65
66         /// The tooltips are stored so that they can be turned on and off.
67         typedef std::map<FL_OBJECT *, string> TooltipsMap;
68
69         TooltipsMap tooltipsMap;
70
71 #if FL_REVISION < 89
72
73         /** A timer is started once the mouse enters an object, so that the
74          *  tip appears a short delay afterwards.
75          */
76         FL_OBJECT * tooltip_timer_;
77
78 #endif
79 };
80
81 #endif // TOOLTIPS_H