3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS
11 /* Tooltips for xforms. xforms 0.89 supports them directly, but 0.88 needs
12 * a bit of jiggery pokery. This class wraps it all up in a neat interface.
13 * Based on code originally in Toolbar_pimpl.C that appears to have been
14 * written by Matthias Ettrich and Jean-Marc Lasgouttes.
20 #pragma implementation
24 #include "xforms_helpers.h" // formatted
26 #include "support/lstrings.h"
27 #include "support/LAssert.h"
28 #include FORMS_H_LOCATION
30 #include <boost/bind.hpp>
32 bool Tooltips::enabled_ = true;
34 boost::signal0<void> Tooltips::toggled;
39 toggled.connect(boost::bind(&Tooltips::set, this));
43 void Tooltips::toggleEnabled()
52 if (tooltipsMap.empty())
55 TooltipsMap::const_iterator it = tooltipsMap.begin();
56 TooltipsMap::const_iterator end = tooltipsMap.end();
57 for (; it != end; ++it) {
58 FL_OBJECT * const ob = it->first;
59 char const * const c_str = enabled_ ? it->second.c_str() : 0;
60 fl_set_object_helper(ob, c_str);
65 void Tooltips::init(FL_OBJECT * ob, string const & tip)
67 lyx::Assert(ob && ob->form);
69 // Store the tooltip string
70 string const str = formatted(trim(tip), 400);
71 tooltipsMap[ob] = str;
74 char const * const c_str = enabled_ ? str.c_str() : 0;
75 fl_set_object_helper(ob, c_str);