X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FTooltips.C;h=d5e3defd6f807d3b3d9517f8844809151067f5cb;hb=8daf842ccd447521676dfcb9dbcd9a541e997e6f;hp=fb1283163fd9b7aa7a44f868495ea69f93acf793;hpb=8eeed19540ddb3aa051e307645a0930db3d7c1d7;p=lyx.git diff --git a/src/frontends/xforms/Tooltips.C b/src/frontends/xforms/Tooltips.C index fb1283163f..d5e3defd6f 100644 --- a/src/frontends/xforms/Tooltips.C +++ b/src/frontends/xforms/Tooltips.C @@ -1,9 +1,11 @@ -/* +/** * \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 @@ -19,30 +21,24 @@ #endif #include "Tooltips.h" -#include "Dialogs.h" #include "xforms_helpers.h" // formatted #include "gettext.h" #include "support/lstrings.h" #include "support/LAssert.h" +#include FORMS_H_LOCATION -using SigC::slot; - +#include -bool Tooltips::enabled_ = false; +bool Tooltips::enabled_ = true; -SigC::Signal0 Tooltips::toggled; +boost::signal0 Tooltips::toggled; -#if FL_REVISION >= 89 +#if FL_VERSION > 0 || FL_REVISION >= 89 Tooltips::Tooltips() { - static bool first = true; - if (first) { - first = false; - Dialogs::toggleTooltips.connect(slot(&Tooltips::toggleEnabled)); - } - toggled.connect(slot(this, &Tooltips::set)); + toggled.connect(boost::bind(&Tooltips::set, this)); } @@ -56,12 +52,10 @@ void Tooltips::toggleEnabled() 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; @@ -74,17 +68,13 @@ void Tooltips::init(FL_OBJECT * ob, string const & tip) { lyx::Assert(ob && ob->form); - // Paranoia check! - TooltipsMap::const_iterator it = tooltipsMap.find(ob); - if (it != tooltipsMap.end()) - return; - - string const str = strip(frontStrip(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); } @@ -95,7 +85,7 @@ namespace { int TooltipHandler(FL_OBJECT *ob, int event); void TooltipTimerCB(FL_OBJECT * timer, long data); - + } extern "C" { @@ -113,17 +103,12 @@ static void C_TooltipTimerCB(FL_OBJECT * ob, long data) } } - + Tooltips::Tooltips() : tooltip_timer_(0) { - static bool first = true; - if (first) { - first = false; - Dialogs::toggleTooltips.connect(slot(&Tooltips::toggleEnabled)); - } - toggled.connect(slot(this, &Tooltips::set)); + toggled.connect(boost::bind(&Tooltips::set, this)); } @@ -147,12 +132,12 @@ void Tooltips::init(FL_OBJECT * ob, string const & tip) if (it != tooltipsMap.end()) return; - string const str = strip(frontStrip(tip)); + string const str = trim(tip); if (str.empty()) return; // Store the tooltip string - tooltipsMap[ob] = formatted(_(str), 400); + tooltipsMap[ob] = formatted(str, 400); if (!tooltip_timer_) { if (fl_current_form && ob->form != fl_current_form) @@ -174,7 +159,7 @@ void Tooltips::init(FL_OBJECT * ob, string const & tip) } -string const Tooltips::get(FL_OBJECT * ob) const +string const Tooltips::get(FL_OBJECT * ob) const { TooltipsMap::const_iterator it = tooltipsMap.find(ob); if (it == tooltipsMap.end())