]> git.lyx.org Git - features.git/blobdiff - src/frontends/xforms/FormBase.C
Framework to select the verbosity of the tooltip.
[features.git] / src / frontends / xforms / FormBase.C
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;