From: Angus Leeming Date: Wed, 6 Feb 2002 17:15:28 +0000 (+0000) Subject: Stabilise the tooltips interface and use it successfully in the Bibtex, X-Git-Tag: 1.6.10~19899 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=98385a16b87859f19d1c726b46ba5e7ca18167fb;p=features.git Stabilise the tooltips interface and use it successfully in the Bibtex, Citation and Texinfo dialogs. Remove all the horrible #if FL_REVISION < 89 cruft from FormBase and put it in a little wrapper class Tooltips. For now use the 0.88 code for all versions of xforms as I can't see an easy way of changing the tooltip on the fly with fl_set_object_helper. To use, call setTooltipHandler for each widget, add a choice widget to the dialog together with 4 lines of code to set/get the level of verbosity. Finally, and two methods, getMinimalTooltip and getVerboseTooltip to return the tooltip. What could be easier? Please try this out. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3496 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 6c95d99aea..873183118a 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,31 @@ +2002-02-06 Angus Leeming + + Stabilise the tooltip interface and get Jürgen's patch to work ;-) + + * Tooltips.[Ch]: new files. A wrapper to the tooltip code with a nice + clean interface. Means that FormBase, FormBaseDeprecated and + Tollbar_pimpl can all use the same code to have tooltips. No bloat. + + * FormBase.C: add a Tooltips instance and interface with it. + (setTooltipLevel): removed. Replaced by fillTooltipChoice and + setTooltipLevel(ob). + (getVerboseTooltip, getMinimalTooltip) now passed a const FL_OBJECT. + + * FormBibtex.[Ch]: + * FormCitation.[Ch]: + * FormTexinfo.[Ch]: + * Makefile.am: altered appropriately. + +2002-02-06 Juergen Spitzmueller + + * forms/form_texinfo.fd: + * forms/form_bibtex.fd: + * forms/form_citation.fd: delete text_info field again, add help choice + + * FormBibtex.[Ch]: + * FormCitation.[Ch]: + * FormTexinfo.[Ch]: Implement new Tooltip behaviour. + 2002-02-06 Angus Leeming * FormBase.[Ch]: can now chose the verbosity of the tooltip through diff --git a/src/frontends/xforms/FormBase.C b/src/frontends/xforms/FormBase.C index d3c3f1f83c..a2e65732de 100644 --- a/src/frontends/xforms/FormBase.C +++ b/src/frontends/xforms/FormBase.C @@ -20,36 +20,9 @@ #include "FormBase.h" #include "xformsBC.h" #include "support/LAssert.h" +#include "Tooltips.h" #include "xforms_helpers.h" // formatted -#if FL_REVISION < 89 - -namespace { - -int TooltipHandler(FL_OBJECT *ob, int event); - -void TooltipTimerCB(FL_OBJECT * timer, long data); - -} - -extern "C" { - -static int C_FormBaseTooltipHandler(FL_OBJECT * ob, int event, - FL_Coord, FL_Coord, int, void *) -{ - return TooltipHandler(ob, event); -} - -static void C_FormBaseTooltipTimerCB(FL_OBJECT * ob, long data) -{ - TooltipTimerCB(ob, data); -} - -} - -#endif // FL_REVISION < 89 - - extern "C" { // Callback function invoked by xforms when the dialog is closed by the @@ -66,15 +39,19 @@ static int C_FormBasePrehandler(FL_OBJECT * ob, int event, FormBase::FormBase(ControlButtons & c, string const & t, bool allowResize) : ViewBC(c), minw_(0), minh_(0), allow_resize_(allowResize), - title_(t), warning_posted_(false), tooltip_level_(VERBOSE_TOOLTIP) + title_(t), warning_posted_(false), tooltip_level_(NO_TOOLTIP) { -#if FL_REVISION < 89 - tooltip_timer_ = 0; -#endif + tooltip_ = new Tooltips; + tooltip_->getTooltip.connect(SigC::slot(this, &FormBase::getTooltip)); } +FormBase::~FormBase() +{ + delete tooltip_; +} + void FormBase::redraw() { if (form() && form()->visible) @@ -179,27 +156,11 @@ void FormBase::FeedbackCB(FL_OBJECT * ob, int event) void FormBase::setTooltipHandler(FL_OBJECT * ob) { - lyx::Assert(ob); - -#if FL_REVISION < 89 - if (!tooltip_timer_) { - fl_addto_form(form()); - tooltip_timer_ = fl_add_timer(FL_HIDDEN_TIMER, 0, 0, 0, 0, ""); - fl_end_form(); - } - - fl_set_object_posthandler(ob, C_FormBaseTooltipHandler); - ob->u_cdata = reinterpret_cast(tooltip_timer_); - -#else - string const help(getTooltip(ob)); - if (!help.empty()) - fl_set_object_helper(ob, help.c_str()); -#endif // FL_REVISION < 89 + tooltip_->activateTooltip(ob); } -string const FormBase::getTooltip(FL_OBJECT * ob) const +string FormBase::getTooltip(FL_OBJECT const * ob) { lyx::Assert(ob); @@ -223,9 +184,44 @@ string const FormBase::getTooltip(FL_OBJECT * ob) const } -void FormBase::setTooltipLevel(TooltipLevel level) +/// Fill the tooltips chooser with the standard descriptions +void FormBase::fillTooltipChoice(FL_OBJECT * ob) +{ + lyx::Assert(ob && ob->objclass == FL_CHOICE); + + fl_clear_choice(ob); + fl_addto_choice(ob, _(" None | Normal | Verbose ")); + + switch(tooltip_level_){ + case NO_TOOLTIP: + fl_set_choice(ob, 1); + break; + case MINIMAL_TOOLTIP: + fl_set_choice(ob, 2); + break; + case VERBOSE_TOOLTIP: + fl_set_choice(ob, 3); + break; + } +} + + +void FormBase::setTooltipLevel(FL_OBJECT * ob) { - tooltip_level_ = level; + lyx::Assert(ob && ob->objclass == FL_CHOICE && + fl_get_choice_maxitems(ob) == 3); + + switch(fl_get_choice(ob)){ + case 1: + tooltip_level_ = NO_TOOLTIP; + break; + case 2: + tooltip_level_ = MINIMAL_TOOLTIP; + break; + case 3: + tooltip_level_ = VERBOSE_TOOLTIP; + break; + } } @@ -327,48 +323,3 @@ static int C_FormBasePrehandler(FL_OBJECT * ob, int event, } } // extern "C" - - -#if FL_REVISION < 89 - -namespace { - -void TooltipTimerCB(FL_OBJECT * timer, long data) -{ - FL_OBJECT * ob = reinterpret_cast(data); - lyx::Assert(ob && ob->form); - - string const help = GetForm(timer)->getTooltip(ob); - if (help.empty()) - return; - - fl_show_oneliner(help.c_str(), - ob->form->x + ob->x, - ob->form->y + ob->y + ob->h); -} - - -// post_handler for bubble-help (Matthias) -int TooltipHandler(FL_OBJECT *ob, int event) -{ - lyx::Assert(ob); - FL_OBJECT * timer = reinterpret_cast(ob->u_cdata); - lyx::Assert(timer); - - // We do not test for empty help here, since this can never happen - if (event == FL_ENTER){ - fl_set_object_callback(timer, - C_FormBaseTooltipTimerCB, - reinterpret_cast(ob)); - fl_set_timer(timer, 1); - } - else if (event != FL_MOTION){ - fl_set_timer(timer, 0); - fl_hide_oneliner(); - } - return 0; -} - -} // namespace anon - -#endif // FL_REVISION < 89 diff --git a/src/frontends/xforms/FormBase.h b/src/frontends/xforms/FormBase.h index d6da374b80..4cbc0d2f48 100644 --- a/src/frontends/xforms/FormBase.h +++ b/src/frontends/xforms/FormBase.h @@ -26,11 +26,11 @@ #include "ButtonPolicies.h" class xformsBC; - +class Tooltips; /** This class is an XForms GUI base class. */ -class FormBase : public ViewBC +class FormBase : public ViewBC, public SigC::Object { public: /// @@ -43,7 +43,7 @@ public: /// FormBase(ControlButtons &, string const &, bool allowResize); /// - virtual ~FormBase() {} + virtual ~FormBase(); /** input callback function. Invoked only by C_FormBaseInputCB and by C_FormBasePrehandler */ @@ -52,8 +52,8 @@ public: void FeedbackCB(FL_OBJECT *, int event); /** Return the tooltip dependent on the value of tooltip_level_ - Invoked only by setTooltipHandler and by TooltipTimerCB */ - string const getTooltip(FL_OBJECT *) const; + currently non-const becuase it gets connected to a SigC::slot */ + string getTooltip(FL_OBJECT const *); protected: /// Build the dialog @@ -63,9 +63,6 @@ protected: /// Create the dialog if necessary, update it and display it. void show(); - /// Set's how verbose the tooltips are going to be - void setTooltipLevel(TooltipLevel level); - /// Prepare the way to produce a tooltip when the mouse is over ob. void setTooltipHandler(FL_OBJECT * ob); @@ -82,6 +79,12 @@ protected: clear_feedback(). */ void setWarningPosted(bool); + /** Fill the tooltips chooser with the standard descriptions + and set it to the tooltips_level_ */ + void fillTooltipChoice(FL_OBJECT *); + /// Set tooltips_level_ from the chooser. + void setTooltipLevel(FL_OBJECT *); + private: /// Pointer to the actual instantiation of xform's form virtual FL_FORM * form() const = 0; @@ -93,9 +96,9 @@ private: virtual void redraw(); /// These methods can be overridden in the daughter classes. - virtual string const getMinimalTooltip(FL_OBJECT *) const + virtual string const getMinimalTooltip(FL_OBJECT const *) const { return string(); } - virtual string const getVerboseTooltip(FL_OBJECT *) const + virtual string const getVerboseTooltip(FL_OBJECT const *) const { return string(); } /// Post feedback for ob. Defaults to nothing @@ -114,10 +117,8 @@ private: /** Variable used to decide whether to remove the existing feedback message or not (if it is infact a warning) */ bool warning_posted_; - /// Enables tooltips for crappy GUI libraries... -#if FL_REVISION < 89 - FL_OBJECT * tooltip_timer_; -#endif + /// + Tooltips * tooltip_; /// How verbose are the tooltips? TooltipLevel tooltip_level_; }; diff --git a/src/frontends/xforms/FormBibtex.C b/src/frontends/xforms/FormBibtex.C index 09ea0ead75..27a2f1217f 100644 --- a/src/frontends/xforms/FormBibtex.C +++ b/src/frontends/xforms/FormBibtex.C @@ -37,6 +37,8 @@ void FormBibtex::build() { dialog_.reset(build_bibtex()); + // the help choice + fillTooltipChoice(dialog_->choice_help); fl_set_input_return(dialog_->database, FL_RETURN_CHANGED); fl_set_input_return(dialog_->style, FL_RETURN_CHANGED); @@ -50,12 +52,12 @@ void FormBibtex::build() bc().addReadOnly(dialog_->style); bc().addReadOnly(dialog_->radio_bibtotoc); - // set up the feedback mechanism - setPrehandler(dialog_->database_browse); - setPrehandler(dialog_->database); - setPrehandler(dialog_->style_browse); - setPrehandler(dialog_->style); - setPrehandler(dialog_->radio_bibtotoc); + // set up the help mechanism + setTooltipHandler(dialog_->database_browse); + setTooltipHandler(dialog_->database); + setTooltipHandler(dialog_->style_browse); + setTooltipHandler(dialog_->style); + setTooltipHandler(dialog_->radio_bibtotoc); } @@ -92,6 +94,11 @@ ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT * ob, long) } } + if (ob == dialog_->choice_help) { + setTooltipLevel(dialog_->choice_help); + return ButtonPolicy::SMI_NOOP; + } + if (!compare(fl_get_input(dialog_->database),"")) { return ButtonPolicy::SMI_NOOP; } @@ -183,7 +190,30 @@ void FormBibtex::apply() } -string const FormBibtex::getVerboseTooltip(FL_OBJECT * ob) const +string const FormBibtex::getMinimalTooltip(FL_OBJECT const * ob) const +{ + string str; + + if (ob == dialog_->database) { + str = N_("The BibTeX Database"); + + } else if (ob == dialog_->database_browse) { + str = _("Browse for BibTeX databases."); + + } else if (ob == dialog_->style) { + str = _("The BibTeX style to use"); + + } else if (ob == dialog_->style_browse) { + str = _("Browse for BibTeX stylefiles."); + + } else if (ob == dialog_->radio_bibtotoc) { + str = _("Bibliography to Table of Contents"); + } + + return str; +} + +string const FormBibtex::getVerboseTooltip(FL_OBJECT const * ob) const { string str; diff --git a/src/frontends/xforms/FormBibtex.h b/src/frontends/xforms/FormBibtex.h index c26cc402b8..c20ce54d14 100644 --- a/src/frontends/xforms/FormBibtex.h +++ b/src/frontends/xforms/FormBibtex.h @@ -38,7 +38,9 @@ private: /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); /// tooltips - string const getVerboseTooltip(FL_OBJECT *) const; + string const getVerboseTooltip(FL_OBJECT const *) const; + /// + string const getMinimalTooltip(FL_OBJECT const *) const; /// Fdesign generated method FD_form_bibtex * build_bibtex(); diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index baf771b44d..98ca7a4b6b 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -154,6 +154,8 @@ void FormCitation::build() fl_set_button(dialog_->button_search_case, 0); fl_set_button(dialog_->button_search_type, 0); + // the help choice + fillTooltipChoice(dialog_->choice_help); // Manage the ok, apply, restore and cancel/close buttons bc().setOK(dialog_->button_ok); @@ -171,23 +173,6 @@ void FormCitation::build() bc().addReadOnly(dialog_->button_full_author_list); bc().addReadOnly(dialog_->button_force_uppercase); - //set up the feedback mechanism - setPrehandler(dialog_->button_add); - setPrehandler(dialog_->button_del); - setPrehandler(dialog_->button_up); - setPrehandler(dialog_->button_down); - setPrehandler(dialog_->browser_cite); - setPrehandler(dialog_->browser_bib); - setPrehandler(dialog_->browser_info); - setPrehandler(dialog_->choice_style); - setPrehandler(dialog_->input_before); - setPrehandler(dialog_->input_after); - setPrehandler(dialog_->button_full_author_list); - setPrehandler(dialog_->button_force_uppercase); - setPrehandler(dialog_->input_search); - setPrehandler(dialog_->button_search_case); - setPrehandler(dialog_->button_search_type); - //set up the tooltip mechanism setTooltipHandler(dialog_->button_add); setTooltipHandler(dialog_->button_del); @@ -399,6 +384,11 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long) activate = ButtonPolicy::SMI_VALID; } + if (ob == dialog_->choice_help) { + setTooltipLevel(dialog_->choice_help); + return ButtonPolicy::SMI_NOOP; + } + string currentCitekey; if (!citekeys.empty()) currentCitekey = citekeys[0]; @@ -495,7 +485,7 @@ void FormCitation::setCiteButtons(State status) const } -string const FormCitation::getMinimalTooltip(FL_OBJECT * ob) const +string const FormCitation::getMinimalTooltip(FL_OBJECT const * ob) const { string str; @@ -546,7 +536,7 @@ string const FormCitation::getMinimalTooltip(FL_OBJECT * ob) const } -string const FormCitation::getVerboseTooltip(FL_OBJECT * ob) const +string const FormCitation::getVerboseTooltip(FL_OBJECT const * ob) const { string str; @@ -578,7 +568,7 @@ string const FormCitation::getVerboseTooltip(FL_OBJECT * ob) const str = N_("Activate if you want to print all authors in a reference with more than three authors, and not \" et.al.\" (Natbib)."); } else if (ob == dialog_->button_force_uppercase) { - str = N_("Activate if you want to print the first character of the author name as uppercase (\"Van Gogh\", not \"van Gogh\". Useful at the beginning of sentences (Natbib)."); + str = N_("Activate if you want to print the first character of the author name as uppercase (\"Van Gogh\", not \"van Gogh\"). Useful at the beginning of sentences (Natbib)."); } else if (ob == dialog_->input_before) { str = N_("Optional text which appears before the citation reference, e.g. \"see \""); diff --git a/src/frontends/xforms/FormCitation.h b/src/frontends/xforms/FormCitation.h index 6685baa2f1..270f1f5979 100644 --- a/src/frontends/xforms/FormCitation.h +++ b/src/frontends/xforms/FormCitation.h @@ -52,9 +52,9 @@ private: /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); /// tooltips - string const getMinimalTooltip(FL_OBJECT *) const; + string const getMinimalTooltip(FL_OBJECT const *) const; /// - string const getVerboseTooltip(FL_OBJECT *) const; + string const getVerboseTooltip(FL_OBJECT const *) const; /// Fdesign generated method FD_form_citation * build_citation(); diff --git a/src/frontends/xforms/FormTexinfo.C b/src/frontends/xforms/FormTexinfo.C index f692f40a5f..8efff8ca8d 100644 --- a/src/frontends/xforms/FormTexinfo.C +++ b/src/frontends/xforms/FormTexinfo.C @@ -38,16 +38,10 @@ void FormTexinfo::build() { fl_set_button(dialog_->button_fullPath, 1); updateStyles(ControlTexinfo::cls); - setPrehandler(dialog_->button_rescan); - setPrehandler(dialog_->button_view); - setPrehandler(dialog_->button_texhash); - setPrehandler(dialog_->button_fullPath); - setPrehandler(dialog_->browser); - setPrehandler(dialog_->radio_cls); - setPrehandler(dialog_->radio_sty); - setPrehandler(dialog_->radio_bst); - setPrehandler(dialog_->message); + // the help choice + fillTooltipChoice(dialog_->choice_help); + // setting up the help mechanism setTooltipHandler(dialog_->button_rescan); setTooltipHandler(dialog_->button_view); setTooltipHandler(dialog_->button_texhash); @@ -56,14 +50,13 @@ void FormTexinfo::build() { setTooltipHandler(dialog_->radio_cls); setTooltipHandler(dialog_->radio_sty); setTooltipHandler(dialog_->radio_bst); - setTooltipHandler(dialog_->message); } ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) { if (ob == dialog_->radio_cls) { - updateStyles(ControlTexinfo::cls); + updateStyles(ControlTexinfo::cls); } else if (ob == dialog_->radio_sty) { updateStyles(ControlTexinfo::sty); @@ -98,6 +91,11 @@ ButtonPolicy::SMInput FormTexinfo::input(FL_OBJECT * ob, long) { } } + if (ob == dialog_->choice_help) { + setTooltipLevel(dialog_->choice_help); + return ButtonPolicy::SMI_NOOP; + } + return ButtonPolicy::SMI_VALID; } @@ -115,18 +113,18 @@ void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle) } -string const FormTexinfo::getMinimalTooltip(FL_OBJECT * ob) const +string const FormTexinfo::getMinimalTooltip(FL_OBJECT const * ob) const { string str; if (ob == dialog_->radio_cls) { - str = N_(""); + str = N_("Available LaTeX Classes"); } else if (ob == dialog_->radio_sty) { - str = _(""); + str = _("Available LaTeX Styles"); } else if (ob == dialog_->radio_bst) { - str = _(""); + str = _("Available BibTeX Styles"); } else if (ob == dialog_->button_rescan) { str = _("Rescan File List"); @@ -135,7 +133,7 @@ string const FormTexinfo::getMinimalTooltip(FL_OBJECT * ob) const str = _("Show Full Path or not"); } else if (ob == dialog_->button_texhash) { - str = _(""); + str = _("Execute Script \"Texhash\""); } else if (ob == dialog_->button_view) { str = N_("View Content of the File"); @@ -146,7 +144,7 @@ string const FormTexinfo::getMinimalTooltip(FL_OBJECT * ob) const } -string const FormTexinfo::getVerboseTooltip(FL_OBJECT * ob) const +string const FormTexinfo::getVerboseTooltip(FL_OBJECT const * ob) const { string str; diff --git a/src/frontends/xforms/FormTexinfo.h b/src/frontends/xforms/FormTexinfo.h index ffe92cc12b..1bf5af0bb8 100644 --- a/src/frontends/xforms/FormTexinfo.h +++ b/src/frontends/xforms/FormTexinfo.h @@ -34,9 +34,9 @@ private: /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); /// - string const getMinimalTooltip(FL_OBJECT *) const; + string const getMinimalTooltip(FL_OBJECT const *) const; /// - string const getVerboseTooltip(FL_OBJECT *) const; + string const getVerboseTooltip(FL_OBJECT const *) const; /// void updateStyles(ControlTexinfo::texFileSuffix); /// Fdesign generated method diff --git a/src/frontends/xforms/Makefile.am b/src/frontends/xforms/Makefile.am index 5ed1ba0ea4..5c002c5251 100644 --- a/src/frontends/xforms/Makefile.am +++ b/src/frontends/xforms/Makefile.am @@ -191,6 +191,8 @@ libxforms_la_SOURCES = \ Timeout_pimpl.h \ Toolbar_pimpl.C \ Toolbar_pimpl.h \ + Tooltips.C \ + Tooltips.h \ xforms_helpers.C \ xforms_helpers.h \ xformsBC.C \ diff --git a/src/frontends/xforms/Tooltips.C b/src/frontends/xforms/Tooltips.C new file mode 100644 index 0000000000..ef82135d45 --- /dev/null +++ b/src/frontends/xforms/Tooltips.C @@ -0,0 +1,125 @@ +/* + * \file Tooltips.C + * Copyright 2002 the LyX Team + * Read the file COPYING + * + * \author Angus Leeming, a.leeming@ic.ac.uk + * + * 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. + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "Tooltips.h" +#include "support/LAssert.h" + +//#if FL_REVISION >= 89 +// Usually, this is all that is needed for xforms 0.89 +// However, I can't see an easy way to change Tooltips on the fly +// with this method, so for now use the jiggery pokery below. ;-) +// Angus 6 Feb 2002 + +/* +void Tooltips::activateTooltip(FL_OBJECT * ob) +{ + lyx::Assert(ob); + + string const help(getTooltip(ob)); + if (!help.empty()) + fl_set_object_helper(ob, help.c_str()); +} +*/ + +//#else // if FL_REVISION < 89 + +namespace { + +int TooltipHandler(FL_OBJECT *ob, int event); + +void TooltipTimerCB(FL_OBJECT * timer, long data); + +} + +extern "C" { + +static int C_TooltipHandler(FL_OBJECT * ob, int event, + FL_Coord, FL_Coord, int, void *) +{ + return TooltipHandler(ob, event); +} + + +static void C_TooltipTimerCB(FL_OBJECT * ob, long data) +{ + TooltipTimerCB(ob, data); +} + +} + + +void Tooltips::activateTooltip(FL_OBJECT * ob) +{ + lyx::Assert(ob); + + if (!tooltip_timer_) { + lyx::Assert(ob->form); + fl_addto_form(ob->form); + tooltip_timer_ = fl_add_timer(FL_HIDDEN_TIMER, 0, 0, 0, 0, ""); + fl_end_form(); + } + + fl_set_object_posthandler(ob, C_TooltipHandler); + ob->u_cdata = reinterpret_cast(tooltip_timer_); + tooltip_timer_->u_vdata = this; +} + + +namespace { + +void TooltipTimerCB(FL_OBJECT * timer, long data) +{ + FL_OBJECT * ob = reinterpret_cast(data); + lyx::Assert(ob && ob->form && timer && timer->u_vdata); + FL_FORM * form = ob->form; + Tooltips * tooltip = static_cast(timer->u_vdata); + + string const help = tooltip->getTooltip(ob); + if (help.empty()) + return; + + fl_show_oneliner(help.c_str(), + form->x + ob->x, form->y + ob->y + ob->h); +} + + +// post_handler for bubble-help (Matthias) +int TooltipHandler(FL_OBJECT *ob, int event) +{ + lyx::Assert(ob); + FL_OBJECT * timer = reinterpret_cast(ob->u_cdata); + lyx::Assert(timer); + + // We do not test for empty help here, since this can never happen + if (event == FL_ENTER){ + fl_set_object_callback(timer, + C_TooltipTimerCB, + reinterpret_cast(ob)); + fl_set_timer(timer, 1); + } + else if (event != FL_MOTION){ + fl_set_timer(timer, 0); + fl_hide_oneliner(); + } + return 0; +} + +} // namespace anon + +//#endif // FL_REVISION < 89 diff --git a/src/frontends/xforms/Tooltips.h b/src/frontends/xforms/Tooltips.h new file mode 100644 index 0000000000..36d2f8b8ac --- /dev/null +++ b/src/frontends/xforms/Tooltips.h @@ -0,0 +1,49 @@ +// -*- C++ -*- +/* + * \file Tooltips.h + * Copyright 2002 the LyX Team + * Read the file COPYING + * + * \author Angus Leeming, a.leeming@ic.ac.uk + * + * 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. + */ + +#ifndef TOOLTIPS_H +#define TOOLTIPS_H + +#include "LString.h" +#include +#include +#include FORMS_H_LOCATION // Can't forward-declare FL_OBJECT + +#ifdef __GNUG__ +#pragma interface +#endif + +class Tooltips : boost::noncopyable { +public: + /// Activate tooltips for this ob + void activateTooltip(FL_OBJECT * ob); + /** Connect this signal to the function returning the tooltip for ob + Eg, string FormBase::getTooltip(FL_OBJECT const *) + Note that SigC is unable to create a Signal1 returning string const + or to connect it to a const method. + */ + SigC::Signal1 getTooltip; + + // We use the old method because we want to change tooltips on the fly +//#if FL_REVISION < 89 + /// + Tooltips() : tooltip_timer_(0) {} + +private: + + FL_OBJECT * tooltip_timer_; +//#endif +}; + +#endif // TOOLTIPS_H diff --git a/src/frontends/xforms/form_bibtex.C b/src/frontends/xforms/form_bibtex.C index 0fc718c6d7..2bd9126a1c 100644 --- a/src/frontends/xforms/form_bibtex.C +++ b/src/frontends/xforms/form_bibtex.C @@ -22,9 +22,9 @@ FD_form_bibtex * FormBibtex::build_bibtex() FL_OBJECT *obj; FD_form_bibtex *fdui = new FD_form_bibtex; - fdui->form = fl_bgn_form(FL_NO_BOX, 450, 215); + fdui->form = fl_bgn_form(FL_NO_BOX, 450, 160); fdui->form->u_vdata = this; - obj = fl_add_box(FL_UP_BOX, 0, 0, 450, 215, ""); + obj = fl_add_box(FL_UP_BOX, 0, 0, 450, 160, ""); { char const * const dummy = N_("Database:|#D"); fdui->database = obj = fl_add_input(FL_NORMAL_INPUT, 90, 10, 245, 30, idex(_(dummy))); @@ -67,9 +67,13 @@ FD_form_bibtex * FormBibtex::build_bibtex() fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_callback(obj, C_FormBaseInputCB, 0); - fdui->text_info = obj = fl_add_text(FL_NORMAL_TEXT, 10, 166, 431, 42, ""); - fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); - obj = fl_add_frame(FL_ENGRAVED_FRAME, 10, 159, 429, 1, ""); + { + char const * const dummy = N_("Help:|#H"); + fdui->choice_help = obj = fl_add_choice(FL_NORMAL_CHOICE, 89, 120, 136, 29, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } + fl_set_object_boxtype(obj, FL_FRAME_BOX); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_bibtex.h b/src/frontends/xforms/form_bibtex.h index faff54787f..6753fa766f 100644 --- a/src/frontends/xforms/form_bibtex.h +++ b/src/frontends/xforms/form_bibtex.h @@ -22,7 +22,7 @@ struct FD_form_bibtex { FL_OBJECT *database_browse; FL_OBJECT *style_browse; FL_OBJECT *radio_bibtotoc; - FL_OBJECT *text_info; + FL_OBJECT *choice_help; }; #endif /* FD_form_bibtex_h_ */ diff --git a/src/frontends/xforms/form_citation.C b/src/frontends/xforms/form_citation.C index 21c18d0a9d..b96d165b27 100644 --- a/src/frontends/xforms/form_citation.C +++ b/src/frontends/xforms/form_citation.C @@ -22,9 +22,9 @@ FD_form_citation * FormCitation::build_citation() FL_OBJECT *obj; FD_form_citation *fdui = new FD_form_citation; - fdui->form = fl_bgn_form(FL_NO_BOX, 680, 480); + fdui->form = fl_bgn_form(FL_NO_BOX, 680, 440); fdui->form->u_vdata = this; - fdui->box = obj = fl_add_box(FL_UP_BOX, 0, 0, 680, 480, ""); + fdui->box = obj = fl_add_box(FL_UP_BOX, 0, 0, 680, 440, ""); fl_set_object_lsize(obj, FL_NORMAL_SIZE); { char const * const dummy = N_("Inset keys|#I"); @@ -37,7 +37,7 @@ FD_form_citation * FormCitation::build_citation() fl_set_object_resize(obj, FL_RESIZE_X); fl_set_object_callback(obj, C_FormBaseInputCB, 0); { - char const * const dummy = N_("Bibliography keys|#B"); + char const * const dummy = N_("Bibliography keys|#y"); fdui->browser_bib = obj = fl_add_browser(FL_HOLD_BROWSER, 200, 30, 160, 240, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } @@ -164,19 +164,19 @@ FD_form_citation * FormCitation::build_citation() fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("Restore|#R"); - fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 395, 100, 30, idex(_(dummy))); + fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 220, 400, 100, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest); fl_set_object_callback(obj, C_FormBaseRestoreCB, 0); - fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 360, 395, 90, 30, _("OK")); + fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 360, 400, 90, 30, _("OK")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); fl_set_object_callback(obj, C_FormBaseOKCB, 0); { char const * const dummy = N_("Apply|#A"); - fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 470, 395, 90, 30, idex(_(dummy))); + fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 470, 400, 90, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); @@ -184,15 +184,19 @@ FD_form_citation * FormCitation::build_citation() fl_set_object_callback(obj, C_FormBaseApplyCB, 0); { char const * const dummy = N_("Cancel|^["); - fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 580, 395, 90, 30, idex(_(dummy))); + fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 580, 400, 90, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); fl_set_object_callback(obj, C_FormBaseCancelCB, 0); - fdui->text_info = obj = fl_add_text(FL_NORMAL_TEXT, 10, 440, 660, 30, ""); - fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); - obj = fl_add_frame(FL_ENGRAVED_FRAME, 10, 430, 660, 1, ""); + { + char const * const dummy = N_("Help:|#H"); + fdui->choice_help = obj = fl_add_choice(FL_NORMAL_CHOICE, 80, 400, 130, 30, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } + fl_set_object_boxtype(obj, FL_FRAME_BOX); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_citation.h b/src/frontends/xforms/form_citation.h index fc1b066d2f..2bd6f4ff97 100644 --- a/src/frontends/xforms/form_citation.h +++ b/src/frontends/xforms/form_citation.h @@ -41,7 +41,7 @@ struct FD_form_citation { FL_OBJECT *button_ok; FL_OBJECT *button_apply; FL_OBJECT *button_cancel; - FL_OBJECT *text_info; + FL_OBJECT *choice_help; }; #endif /* FD_form_citation_h_ */ diff --git a/src/frontends/xforms/form_texinfo.C b/src/frontends/xforms/form_texinfo.C index 49ba2371fc..2b8705d271 100644 --- a/src/frontends/xforms/form_texinfo.C +++ b/src/frontends/xforms/form_texinfo.C @@ -22,9 +22,9 @@ FD_form_texinfo * FormTexinfo::build_texinfo() FL_OBJECT *obj; FD_form_texinfo *fdui = new FD_form_texinfo; - fdui->form = fl_bgn_form(FL_NO_BOX, 513, 394); + fdui->form = fl_bgn_form(FL_NO_BOX, 513, 353); fdui->form->u_vdata = this; - obj = fl_add_box(FL_UP_BOX, 0, 0, 513, 394, ""); + obj = fl_add_box(FL_UP_BOX, 0, 0, 513, 353, ""); fl_set_object_lstyle(obj, FL_FIXED_STYLE); fdui->browser = obj = fl_add_browser(FL_HOLD_BROWSER, 15, 12, 324, 241, ""); fl_set_object_lalign(obj, FL_ALIGN_TOP); @@ -92,12 +92,9 @@ FD_form_texinfo * FormTexinfo::build_texinfo() fl_set_object_lalign(obj, FL_ALIGN_RIGHT); fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast); fl_set_object_callback(obj, C_FormBaseInputCB, 2); - fdui->message = obj = fl_add_text(FL_NORMAL_TEXT, 14, 323, 482, 56, ""); - fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); - fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast); { char const * const dummy = N_("Run Texhash|#T"); - fdui->button_texhash = obj = fl_add_button(FL_NORMAL_BUTTON, 15, 271, 135, 30, idex(_(dummy))); + fdui->button_texhash = obj = fl_add_button(FL_NORMAL_BUTTON, 14, 270, 131, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); @@ -105,13 +102,19 @@ FD_form_texinfo * FormTexinfo::build_texinfo() fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("Close|^[^M"); - fdui->button_close = obj = fl_add_button(FL_NORMAL_BUTTON, 408, 272, 90, 30, idex(_(dummy))); + fdui->button_close = obj = fl_add_button(FL_NORMAL_BUTTON, 409, 313, 90, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); fl_set_object_callback(obj, C_FormBaseCancelCB, 0); - obj = fl_add_frame(FL_ENGRAVED_FRAME, 13, 312, 485, 1, ""); + { + char const * const dummy = N_("Help:|#H"); + fdui->choice_help = obj = fl_add_choice(FL_NORMAL_CHOICE, 344, 270, 155, 29, idex(_(dummy))); + fl_set_button_shortcut(obj, scex(_(dummy)), 1); + } + fl_set_object_boxtype(obj, FL_FRAME_BOX); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_texinfo.h b/src/frontends/xforms/form_texinfo.h index 2147aa09f0..293ba72e8d 100644 --- a/src/frontends/xforms/form_texinfo.h +++ b/src/frontends/xforms/form_texinfo.h @@ -21,9 +21,9 @@ struct FD_form_texinfo { FL_OBJECT *button_rescan; FL_OBJECT *button_view; FL_OBJECT *button_fullPath; - FL_OBJECT *message; FL_OBJECT *button_texhash; FL_OBJECT *button_close; + FL_OBJECT *choice_help; }; #endif /* FD_form_texinfo_h_ */ diff --git a/src/frontends/xforms/forms/form_bibtex.fd b/src/frontends/xforms/forms/form_bibtex.fd index 39c87242a4..850c5dd8d6 100644 --- a/src/frontends/xforms/forms/form_bibtex.fd +++ b/src/frontends/xforms/forms/form_bibtex.fd @@ -10,13 +10,13 @@ SnapGrid: 1 =============== FORM =============== Name: form_bibtex Width: 450 -Height: 215 -Number of Objects: 10 +Height: 160 +Number of Objects: 9 -------------------- class: FL_BOX type: UP_BOX -box: 0 0 450 215 +box: 0 0 450 160 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -158,40 +158,22 @@ callback: C_FormBaseInputCB argument: 0 -------------------- -class: FL_TEXT -type: NORMAL_TEXT -box: 10 166 431 42 -boxtype: FL_FLAT_BOX -colors: FL_COL1 FL_MCOL -alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE -style: FL_NORMAL_STYLE -size: FL_DEFAULT_SIZE -lcol: FL_BLACK -label: -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: text_info -callback: -argument: - --------------------- -class: FL_FRAME -type: ENGRAVED_FRAME -box: 10 159 429 1 -boxtype: FL_NO_BOX -colors: FL_BLACK FL_COL1 -alignment: FL_ALIGN_CENTER +class: FL_CHOICE +type: NORMAL_CHOICE +box: 89 120 136 29 +boxtype: FL_FRAME_BOX +colors: FL_COL1 FL_BLACK +alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_DEFAULT_SIZE lcol: FL_BLACK -label: +label: Help:|#H shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: -callback: -argument: +name: choice_help +callback: C_FormBaseInputCB +argument: 0 ============================== create_the_forms diff --git a/src/frontends/xforms/forms/form_citation.fd b/src/frontends/xforms/forms/form_citation.fd index d0a287ae3e..cdc3fa3362 100644 --- a/src/frontends/xforms/forms/form_citation.fd +++ b/src/frontends/xforms/forms/form_citation.fd @@ -9,13 +9,13 @@ Unit of measure: FL_COORD_PIXEL =============== FORM =============== Name: form_citation Width: 680 -Height: 480 -Number of Objects: 27 +Height: 440 +Number of Objects: 26 -------------------- class: FL_BOX type: UP_BOX -box: 0 0 680 480 +box: 0 0 680 440 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -58,7 +58,7 @@ alignment: FL_ALIGN_TOP_LEFT style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Bibliography keys|#B +label: Bibliography keys|#y shortcut: resize: FL_RESIZE_X gravity: FL_North FL_SouthEast @@ -393,7 +393,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 10 395 100 30 +box: 220 400 100 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -411,7 +411,7 @@ argument: 0 -------------------- class: FL_BUTTON type: RETURN_BUTTON -box: 360 395 90 30 +box: 360 400 90 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -429,7 +429,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 470 395 90 30 +box: 470 400 90 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -447,7 +447,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 580 395 90 30 +box: 580 400 90 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -463,40 +463,22 @@ callback: C_FormBaseCancelCB argument: 0 -------------------- -class: FL_TEXT -type: NORMAL_TEXT -box: 10 440 660 30 -boxtype: FL_FLAT_BOX -colors: FL_COL1 FL_MCOL -alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE -style: FL_NORMAL_STYLE -size: FL_DEFAULT_SIZE -lcol: FL_BLACK -label: -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: text_info -callback: -argument: - --------------------- -class: FL_FRAME -type: ENGRAVED_FRAME -box: 10 430 660 1 -boxtype: FL_NO_BOX -colors: FL_BLACK FL_COL1 -alignment: FL_ALIGN_CENTER +class: FL_CHOICE +type: NORMAL_CHOICE +box: 80 400 130 30 +boxtype: FL_FRAME_BOX +colors: FL_COL1 FL_BLACK +alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_DEFAULT_SIZE lcol: FL_BLACK -label: +label: Help:|#H shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: -callback: -argument: +name: choice_help +callback: C_FormBaseInputCB +argument: 0 ============================== create_the_forms diff --git a/src/frontends/xforms/forms/form_texinfo.fd b/src/frontends/xforms/forms/form_texinfo.fd index e9007b9744..a303e1b3b6 100644 --- a/src/frontends/xforms/forms/form_texinfo.fd +++ b/src/frontends/xforms/forms/form_texinfo.fd @@ -10,13 +10,13 @@ SnapGrid: 1 =============== FORM =============== Name: form_texinfo Width: 513 -Height: 394 -Number of Objects: 14 +Height: 353 +Number of Objects: 13 -------------------- class: FL_BOX type: UP_BOX -box: 0 0 513 394 +box: 0 0 513 353 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -194,28 +194,10 @@ name: button_fullPath callback: C_FormBaseInputCB argument: 2 --------------------- -class: FL_TEXT -type: NORMAL_TEXT -box: 14 323 482 56 -boxtype: FL_FLAT_BOX -colors: FL_COL1 FL_MCOL -alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE -style: FL_NORMAL_STYLE -size: FL_DEFAULT_SIZE -lcol: FL_BLACK -label: -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_SouthWest FL_SouthEast -name: message -callback: -argument: - -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 15 271 135 30 +box: 14 270 131 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -233,7 +215,7 @@ argument: 0 -------------------- class: FL_BUTTON type: NORMAL_BUTTON -box: 408 272 90 30 +box: 409 313 90 30 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -249,22 +231,22 @@ callback: C_FormBaseCancelCB argument: 0 -------------------- -class: FL_FRAME -type: ENGRAVED_FRAME -box: 13 312 485 1 -boxtype: FL_NO_BOX -colors: FL_BLACK FL_COL1 -alignment: FL_ALIGN_CENTER +class: FL_CHOICE +type: NORMAL_CHOICE +box: 344 270 155 29 +boxtype: FL_FRAME_BOX +colors: FL_COL1 FL_BLACK +alignment: FL_ALIGN_LEFT style: FL_NORMAL_STYLE size: FL_DEFAULT_SIZE lcol: FL_BLACK -label: +label: Help:|#H shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity -name: -callback: -argument: +name: choice_help +callback: C_FormBaseInputCB +argument: 0 ============================== create_the_form