From 599e49cf7dd251fae87389157dce3aee01a935bf Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 6 Feb 2002 12:12:04 +0000 Subject: [PATCH] Framework to select the verbosity of the tooltip. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3493 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/xforms/ChangeLog | 15 ++++++++++ src/frontends/xforms/FormBase.C | 45 +++++++++++++++++++++-------- src/frontends/xforms/FormBase.h | 28 +++++++++++++----- src/frontends/xforms/FormBibtex.C | 15 ++-------- src/frontends/xforms/FormBibtex.h | 4 +-- src/frontends/xforms/FormCitation.C | 18 +++--------- src/frontends/xforms/FormCitation.h | 6 ++-- src/frontends/xforms/FormTexinfo.C | 20 +++---------- src/frontends/xforms/FormTexinfo.h | 6 ++-- 9 files changed, 84 insertions(+), 73 deletions(-) diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 769b89767b..6c95d99aea 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,18 @@ +2002-02-06 Angus Leeming + + * FormBase.[Ch]: can now chose the verbosity of the tooltip through + a new method setTooltipLevel(). In turn this determines which of the + new virtual methods, getVerboseTooltip() or getMinimalTooltip() gets + called from getTooltip. + No need for a "message" widget at the bottom of every dialog, therefore. + If retained, this "message" widget can be used to display "warnings", + pure and simple. + + * FormBibtex.[Ch]: + * FormCitation.[Ch]: + * FormTexinfo.[Ch]: altered appropriately. Still need to be reshaped, + to lose the "message" widget and to gain a "tooltip level" choice. + 2002-02-05 Angus Leeming * forms/form_graphics.fd: Tiny tweek to make the Restore, Ok, Apply, diff --git a/src/frontends/xforms/FormBase.C b/src/frontends/xforms/FormBase.C index 2732f314e5..d3c3f1f83c 100644 --- a/src/frontends/xforms/FormBase.C +++ b/src/frontends/xforms/FormBase.C @@ -20,6 +20,7 @@ #include "FormBase.h" #include "xformsBC.h" #include "support/LAssert.h" +#include "xforms_helpers.h" // formatted #if FL_REVISION < 89 @@ -65,7 +66,7 @@ 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) + title_(t), warning_posted_(false), tooltip_level_(VERBOSE_TOOLTIP) { #if FL_REVISION < 89 @@ -198,27 +199,47 @@ void FormBase::setTooltipHandler(FL_OBJECT * ob) } -void FormBase::setPrehandler(FL_OBJECT * ob) +string const FormBase::getTooltip(FL_OBJECT * ob) const { lyx::Assert(ob); - fl_set_object_prehandler(ob, C_FormBasePrehandler); -} + switch (tooltip_level_) { + case VERBOSE_TOOLTIP: + { + string str = getVerboseTooltip(ob); + if (!str.empty()) + return formatted(_(str), 400); + // else, fall through + } + + case MINIMAL_TOOLTIP: + return getMinimalTooltip(ob); + + case NO_TOOLTIP: + default: + return string(); + } + +} + -void FormBase::setWarningPosted(bool warning) +void FormBase::setTooltipLevel(TooltipLevel level) { - warning_posted_ = warning; + tooltip_level_ = level; } -#if FL_REVISION < 89 - -string const FormBase::getTooltipCB(FL_OBJECT * ob) +void FormBase::setPrehandler(FL_OBJECT * ob) { - return getTooltip(ob); + lyx::Assert(ob); + fl_set_object_prehandler(ob, C_FormBasePrehandler); } -#endif // FL_REVISION < 89 + +void FormBase::setWarningPosted(bool warning) +{ + warning_posted_ = warning; +} namespace { @@ -317,7 +338,7 @@ void TooltipTimerCB(FL_OBJECT * timer, long data) FL_OBJECT * ob = reinterpret_cast(data); lyx::Assert(ob && ob->form); - string const help = GetForm(timer)->getTooltipCB(ob); + string const help = GetForm(timer)->getTooltip(ob); if (help.empty()) return; diff --git a/src/frontends/xforms/FormBase.h b/src/frontends/xforms/FormBase.h index c486ae4d0f..d6da374b80 100644 --- a/src/frontends/xforms/FormBase.h +++ b/src/frontends/xforms/FormBase.h @@ -33,6 +33,13 @@ class xformsBC; class FormBase : public ViewBC { public: + /// + enum TooltipLevel { + NO_TOOLTIP, + MINIMAL_TOOLTIP, + VERBOSE_TOOLTIP + }; + /// FormBase(ControlButtons &, string const &, bool allowResize); /// @@ -44,10 +51,9 @@ public: /// feedback callback function, invoked only by C_FormBasePrehandler void FeedbackCB(FL_OBJECT *, int event); -#if FL_REVISION < 89 - /// invoked only by TooltipTimerCB - string const getTooltipCB(FL_OBJECT *); -#endif + /** Return the tooltip dependent on the value of tooltip_level_ + Invoked only by setTooltipHandler and by TooltipTimerCB */ + string const getTooltip(FL_OBJECT *) const; protected: /// Build the dialog @@ -57,6 +63,9 @@ 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); @@ -83,10 +92,13 @@ private: that the xform colors have been re-mapped). */ virtual void redraw(); - /// - virtual string const getTooltip(FL_OBJECT *) { return string(); } + /// These methods can be overridden in the daughter classes. + virtual string const getMinimalTooltip(FL_OBJECT *) const + { return string(); } + virtual string const getVerboseTooltip(FL_OBJECT *) const + { return string(); } - /// post feedback for ob. Defaults to nothing + /// Post feedback for ob. Defaults to nothing virtual void feedback(FL_OBJECT * /* ob */) {} /// clear the feedback message virtual void clear_feedback() {} @@ -106,6 +118,8 @@ private: #if FL_REVISION < 89 FL_OBJECT * tooltip_timer_; #endif + /// How verbose are the tooltips? + TooltipLevel tooltip_level_; }; diff --git a/src/frontends/xforms/FormBibtex.C b/src/frontends/xforms/FormBibtex.C index a80c97818d..09ea0ead75 100644 --- a/src/frontends/xforms/FormBibtex.C +++ b/src/frontends/xforms/FormBibtex.C @@ -182,16 +182,9 @@ void FormBibtex::apply() } } -void FormBibtex::clear_feedback() -{ - fl_set_object_label(dialog_->text_info, ""); - fl_redraw_object(dialog_->text_info); -} -void FormBibtex::feedback(FL_OBJECT * ob) +string const FormBibtex::getVerboseTooltip(FL_OBJECT * ob) const { - lyx::Assert(ob); - string str; if (ob == dialog_->database) { @@ -210,9 +203,5 @@ void FormBibtex::feedback(FL_OBJECT * ob) str = _("Activate this option if you want the bibliography to appear in the Table of Contents (which doesn't happen by default)."); } - str = formatted(_(str), dialog_->text_info->w-10, FL_SMALL_SIZE); - - fl_set_object_label(dialog_->text_info, str.c_str()); - fl_set_object_lsize(dialog_->text_info, FL_SMALL_SIZE); - fl_redraw_object(dialog_->text_info); + return str; } diff --git a/src/frontends/xforms/FormBibtex.h b/src/frontends/xforms/FormBibtex.h index 8f9326af96..c26cc402b8 100644 --- a/src/frontends/xforms/FormBibtex.h +++ b/src/frontends/xforms/FormBibtex.h @@ -38,9 +38,7 @@ private: /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); /// tooltips - void feedback(FL_OBJECT *); - /// - void clear_feedback(); + string const getVerboseTooltip(FL_OBJECT *) const; /// Fdesign generated method FD_form_bibtex * build_bibtex(); diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index 0a34f3f75d..baf771b44d 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -494,7 +494,8 @@ void FormCitation::setCiteButtons(State status) const setEnabled(dialog_->button_down, activate_down); } -string const FormCitation::getTooltip(FL_OBJECT * ob) + +string const FormCitation::getMinimalTooltip(FL_OBJECT * ob) const { string str; @@ -544,16 +545,9 @@ string const FormCitation::getTooltip(FL_OBJECT * ob) return str; } -void FormCitation::clear_feedback() -{ - fl_set_object_label(dialog_->text_info, ""); - fl_redraw_object(dialog_->text_info); -} -void FormCitation::feedback(FL_OBJECT * ob) +string const FormCitation::getVerboseTooltip(FL_OBJECT * ob) const { - lyx::Assert(ob); - string str; if (ob == dialog_->button_add) { @@ -602,9 +596,5 @@ void FormCitation::feedback(FL_OBJECT * ob) str = N_("Activate if you want to enter Regular Expressions."); } - str = formatted(_(str), dialog_->text_info->w-10, FL_SMALL_SIZE); - - fl_set_object_label(dialog_->text_info, str.c_str()); - fl_set_object_lsize(dialog_->text_info, FL_SMALL_SIZE); - fl_redraw_object(dialog_->text_info); + return str; } diff --git a/src/frontends/xforms/FormCitation.h b/src/frontends/xforms/FormCitation.h index ea308900a0..6685baa2f1 100644 --- a/src/frontends/xforms/FormCitation.h +++ b/src/frontends/xforms/FormCitation.h @@ -52,11 +52,9 @@ private: /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); /// tooltips - string const getTooltip(FL_OBJECT *); + string const getMinimalTooltip(FL_OBJECT *) const; /// - void feedback(FL_OBJECT *); - /// - void clear_feedback(); + string const getVerboseTooltip(FL_OBJECT *) const; /// Fdesign generated method FD_form_citation * build_citation(); diff --git a/src/frontends/xforms/FormTexinfo.C b/src/frontends/xforms/FormTexinfo.C index 80f586b04c..f692f40a5f 100644 --- a/src/frontends/xforms/FormTexinfo.C +++ b/src/frontends/xforms/FormTexinfo.C @@ -115,14 +115,7 @@ void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle) } -void FormTexinfo::clear_feedback() -{ - fl_set_object_label(dialog_->message, ""); - fl_redraw_object(dialog_->message); -} - - -string const FormTexinfo::getTooltip(FL_OBJECT * ob) +string const FormTexinfo::getMinimalTooltip(FL_OBJECT * ob) const { string str; @@ -152,10 +145,9 @@ string const FormTexinfo::getTooltip(FL_OBJECT * ob) return str; } -void FormTexinfo::feedback(FL_OBJECT * ob) -{ - lyx::Assert(ob); +string const FormTexinfo::getVerboseTooltip(FL_OBJECT * ob) const +{ string str; if (ob == dialog_->radio_cls) { @@ -181,9 +173,5 @@ void FormTexinfo::feedback(FL_OBJECT * ob) } - str = formatted(_(str), dialog_->message->w-10, FL_SMALL_SIZE); - - fl_set_object_label(dialog_->message, str.c_str()); - fl_set_object_lsize(dialog_->message, FL_SMALL_SIZE); - fl_redraw_object(dialog_->message); + return str; } diff --git a/src/frontends/xforms/FormTexinfo.h b/src/frontends/xforms/FormTexinfo.h index b514a3ea61..ffe92cc12b 100644 --- a/src/frontends/xforms/FormTexinfo.h +++ b/src/frontends/xforms/FormTexinfo.h @@ -34,11 +34,9 @@ private: /// Filter the inputs on callback from xforms virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); /// - string const getTooltip(FL_OBJECT *); + string const getMinimalTooltip(FL_OBJECT *) const; /// - void feedback(FL_OBJECT *); - /// - void clear_feedback(); + string const getVerboseTooltip(FL_OBJECT *) const; /// void updateStyles(ControlTexinfo::texFileSuffix); /// Fdesign generated method -- 2.39.5