X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FTooltips.C;h=d5e3defd6f807d3b3d9517f8844809151067f5cb;hb=8daf842ccd447521676dfcb9dbcd9a541e997e6f;hp=4328bab6eeee1d6f9956b2c37493b6020be1d0b6;hpb=7cbe56d12ec3a8dcb0a14758866ae68daa39b6e8;p=lyx.git diff --git a/src/frontends/xforms/Tooltips.C b/src/frontends/xforms/Tooltips.C index 4328bab6ee..d5e3defd6f 100644 --- a/src/frontends/xforms/Tooltips.C +++ b/src/frontends/xforms/Tooltips.C @@ -1,14 +1,14 @@ -/* +/** * \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 +/* Tooltips for xforms. xforms 0.89 supports them directly, but 0.88 needs * a bit of jiggery pokery. This class wraps it all up in a neat interface. * Based on code originally in Toolbar_pimpl.C that appears to have been * written by Matthias Ettrich and Jean-Marc Lasgouttes. @@ -21,79 +21,58 @@ #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::tooltipsToggled; +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)); - } - tooltipsToggled.connect(slot(this, &Tooltips::toggleTooltips)); + toggled.connect(boost::bind(&Tooltips::set, this)); } void Tooltips::toggleEnabled() { enabled_ = !enabled_; - tooltipsToggled(); + toggled(); } -void Tooltips::toggleTooltips() +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; fl_set_object_helper(ob, c_str); } - - // Set the cursor to a question mark or back to the default. - FL_OBJECT * const ob = tooltipsMap.begin()->first; - int const cursor = enabled_ ? XC_question_arrow : FL_DEFAULT_CURSOR; - fl_set_cursor(FL_ObjWin(ob), cursor); } -void Tooltips::initTooltip(FL_OBJECT * ob, string const & tip) +void Tooltips::init(FL_OBJECT * ob, string const & tip) { - lyx::Assert(ob); - - // Paranoia check! - TooltipsMap::const_iterator it = tooltipsMap.find(ob); - if (it != tooltipsMap.end()) - return; - - string const str = strip(frontStrip(tip)); - if (str.empty()) - return; + lyx::Assert(ob && ob->form); // Store the tooltip string - tooltipsMap[ob] = formatted(_(str), 400); + string const str = formatted(trim(tip), 400); + tooltipsMap[ob] = str; - // Set the initial state of the tooltips + // Set the tooltip char const * const c_str = enabled_ ? str.c_str() : 0; fl_set_object_helper(ob, c_str); } @@ -106,7 +85,7 @@ namespace { int TooltipHandler(FL_OBJECT *ob, int event); void TooltipTimerCB(FL_OBJECT * timer, long data); - + } extern "C" { @@ -124,59 +103,43 @@ 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)); - } - tooltipsToggled.connect(slot(this, &Tooltips::toggleTooltips)); + toggled.connect(boost::bind(&Tooltips::set, this)); } void Tooltips::toggleEnabled() { enabled_ = !enabled_; - tooltipsToggled(); + toggled(); } -void Tooltips::toggleTooltips() -{ - 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; +void Tooltips::set() +{} - // Set the cursor to a question mark or back to the default. - FL_OBJECT * const ob = tooltipsMap.begin()->first; - int const cursor = enabled_ ? XC_question_arrow : FL_DEFAULT_CURSOR; - fl_set_cursor(FL_ObjWin(ob), cursor); -} - -void Tooltips::initTooltip(FL_OBJECT * ob, string const & tip) +void Tooltips::init(FL_OBJECT * ob, string const & tip) { - lyx::Assert(ob); + 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)); + 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_) { - lyx::Assert(ob->form); if (fl_current_form && ob->form != fl_current_form) fl_end_form(); @@ -196,7 +159,7 @@ void Tooltips::initTooltip(FL_OBJECT * ob, string const & tip) } -string const Tooltips::getTooltip(FL_OBJECT * ob) const +string const Tooltips::get(FL_OBJECT * ob) const { TooltipsMap::const_iterator it = tooltipsMap.find(ob); if (it == tooltipsMap.end()) @@ -214,7 +177,7 @@ void TooltipTimerCB(FL_OBJECT * timer, long data) FL_FORM * form = ob->form; Tooltips * tooltip = static_cast(timer->u_vdata); - string const help = tooltip->getTooltip(ob); + string const help = tooltip->get(ob); if (help.empty()) return;