]> git.lyx.org Git - features.git/commitdiff
Framework to select the verbosity of the tooltip.
authorAngus Leeming <leeming@lyx.org>
Wed, 6 Feb 2002 12:12:04 +0000 (12:12 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 6 Feb 2002 12:12:04 +0000 (12:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3493 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/FormBase.C
src/frontends/xforms/FormBase.h
src/frontends/xforms/FormBibtex.C
src/frontends/xforms/FormBibtex.h
src/frontends/xforms/FormCitation.C
src/frontends/xforms/FormCitation.h
src/frontends/xforms/FormTexinfo.C
src/frontends/xforms/FormTexinfo.h

index 769b89767b20280124a790552a88c8d1b2b102d7..6c95d99aea9248e7aea07e87590d8061141cc304 100644 (file)
@@ -1,3 +1,18 @@
+2002-02-06  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * 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  <a.leeming@ic.ac.uk>
 
        * forms/form_graphics.fd: Tiny tweek to make the Restore, Ok, Apply,
index 2732f314e596b6aca00cb0170990285f5ce02288..d3c3f1f83ccc674b1f8309ae9da00935473bdd5d 100644 (file)
@@ -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<xformsBC>(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<FL_OBJECT*>(data);
        lyx::Assert(ob && ob->form);
 
-       string const help = GetForm(timer)->getTooltipCB(ob);
+       string const help = GetForm(timer)->getTooltip(ob);
        if (help.empty())
                return;
 
index c486ae4d0f5d27fa989aa71d26d219e904054da3..d6da374b805d14f6b559aedf3e1b972bff15a7b6 100644 (file)
@@ -33,6 +33,13 @@ class xformsBC;
 class FormBase : public ViewBC<xformsBC>
 {
 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_;
 };
 
 
index a80c97818d937dd5c59cfa18b5267f25b4ad4cea..09ea0ead7582531bc366131af767bccef77c9e33 100644 (file)
@@ -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;
 }
index 8f9326af9652f5487063b88d2e5c31dc33dee3dc..c26cc402b8c49b11d6f41e420b4b3088789140aa 100644 (file)
@@ -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();
index 0a34f3f75d3bf4b932b0aa75160a46b5059ec857..baf771b44d30298de18cfa81b1f123f671533479 100644 (file)
@@ -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;
 }
index ea308900a0b08d2acff1710858ca569411e65ebb..6685baa2f137bc9fdd1a3fb0ce3a65685c5a1270 100644 (file)
@@ -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();
index 80f586b04c112ecfcdf334afecda13628fa1570e..f692f40a5f1edce5baab410d885afdef790a96e3 100644 (file)
@@ -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;
 }
index b514a3ea61154d32af9cb5c51996e29d46cf9765..ffe92cc12b4f2f5d07197e811f1d8f7f7d21b81f 100644 (file)
@@ -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