]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Tooltips.h
2002-07-02 Lars Gullik Bj�nnes <larsbj@birdstep.com>
[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 class Dialogs;
30
31
32 #ifdef __GNUG__
33 #pragma interface
34 #endif
35
36 class Tooltips : boost::noncopyable, public boost::signals::trackable {
37 public:
38         Tooltips(Dialogs &);
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 private:
59
60         /// Are the tooltips on or off?
61         static bool enabled_;
62
63         /** This method is connected to Dialogs::toggleTooltips and toggles
64          *  the state of enabled_.
65          */
66         static void toggleEnabled();
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