-/*
+/**
* \file Tooltips.C
- * Copyright 2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * \author Angus Leeming, a.leeming@ic.ac.uk
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
*/
/* Tooltips for xforms. xforms 0.89 supports them directly, but 0.88 needs
#endif
#include "Tooltips.h"
-#include "Dialogs.h"
#include "xforms_helpers.h" // formatted
#include "gettext.h"
#include "support/lstrings.h"
#if FL_VERSION > 0 || FL_REVISION >= 89
-Tooltips::Tooltips(Dialogs & d)
+Tooltips::Tooltips()
{
- static bool first = true;
- if (first) {
- first = false;
- d.toggleTooltips.connect(boost::bind(&Tooltips::toggleEnabled));
- }
toggled.connect(boost::bind(&Tooltips::set, this));
}
void Tooltips::set()
{
if (tooltipsMap.empty())
- // There are no objects with tooltips in this dialog, so
- // just go away. Don't change the cursor to a question mark.
return;
- TooltipsMap::iterator it = tooltipsMap.begin();
- TooltipsMap::iterator end = tooltipsMap.end();
+ TooltipsMap::const_iterator it = tooltipsMap.begin();
+ TooltipsMap::const_iterator end = tooltipsMap.end();
for (; it != end; ++it) {
FL_OBJECT * const ob = it->first;
char const * const c_str = enabled_ ? it->second.c_str() : 0;
{
lyx::Assert(ob && ob->form);
- // Paranoia check!
- TooltipsMap::const_iterator it = tooltipsMap.find(ob);
- if (it != tooltipsMap.end())
- return;
-
- string const str = trim(tip);
- if (str.empty())
- return;
-
// Store the tooltip string
- tooltipsMap[ob] = formatted(str, 400);
+ string const str = formatted(trim(tip), 400);
+ tooltipsMap[ob] = str;
+
+ // Set the tooltip
+ char const * const c_str = enabled_ ? str.c_str() : 0;
+ fl_set_object_helper(ob, c_str);
}
}
-Tooltips::Tooltips(Dialogs & d)
+Tooltips::Tooltips()
: tooltip_timer_(0)
{
- static bool first = true;
- if (first) {
- first = false;
- d.toggleTooltips.connect(boost::bind(&Tooltips::toggleEnabled));
- }
toggled.connect(boost::bind(&Tooltips::set, this));
}