]> git.lyx.org Git - features.git/commitdiff
* move extended tooltips support to InsetCollapsable (fixes bug 3778).
authorJürgen Spitzmüller <spitz@lyx.org>
Sun, 27 Apr 2008 14:47:07 +0000 (14:47 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Sun, 27 Apr 2008 14:47:07 +0000 (14:47 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24524 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetCollapsable.cpp
src/insets/InsetFloat.cpp
src/insets/InsetFoot.cpp
src/insets/InsetMarginal.cpp
src/insets/InsetMarginal.h

index 7b8e292bd07ccdd379dc295f4e4b50a59fa71d7a..ab2649f70147c3f9bb7ea268a731bb4848ad2ad3 100644 (file)
@@ -112,13 +112,26 @@ docstring InsetCollapsable::toolTip(BufferView const & bv, int x, int y) const
        if (x > xo(bv) + dim.wid || y > yo(bv) + dim.des)
                return docstring();
 
+       docstring default_tip;
        switch (status_) {
        case Open:
-               return _("Left-click to collapse the inset");
+               default_tip = _("Left-click to collapse the inset");
+               break;
        case Collapsed:
-               return _("Left-click to open the inset");
+               default_tip = _("Left-click to open the inset");
+               break;
        }
-       return docstring();
+
+       OutputParams rp(&buffer().params().encoding());
+       odocstringstream ods;
+       InsetText::plaintext(ods, rp);
+       docstring content_tip = ods.str();
+       // shorten it if necessary
+       if (content_tip.size() > 200)
+               content_tip = content_tip.substr(0, 200) + "...";
+       if (!isOpen() && !content_tip.empty())
+               return content_tip + '\n' + default_tip;
+       return default_tip;
 }
 
 
index f449e97783e7aec983cd436187364b2fa9603c67..d77701bcf4ed406774303ee7c915b12e1bcec039 100644 (file)
@@ -129,8 +129,15 @@ InsetFloat::~InsetFloat()
 
 docstring InsetFloat::toolTip(BufferView const & bv, int x, int y) const
 {
+       if (InsetCollapsable::toolTip(bv, x, y).empty())
+               return docstring();
+
+       docstring default_tip;
+       if (isOpen())
+               default_tip = _("Left-click to collapse the inset");
+       else
+               default_tip = _("Left-click to open the inset");
        OutputParams rp(&buffer().params().encoding());
-       docstring default_tip = InsetCollapsable::toolTip(bv, x, y);
        docstring caption_tip = getCaptionText(rp);
        if (!isOpen() && !caption_tip.empty())
                return caption_tip + '\n' + default_tip;
index d320476733a531ff6c6cf3ca25c73a5a70dbc603..d4e862c4e5b255efc261973f50276a7d5d1a9806 100644 (file)
@@ -82,15 +82,8 @@ void InsetFoot::addToToc(ParConstIterator const & cpit) const
 docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
 {
        docstring default_tip = InsetCollapsable::toolTip(bv, x, y);
-       OutputParams rp(&buffer().params().encoding());
-       odocstringstream ods;
-       InsetText::plaintext(ods, rp);
-       docstring foot_tip = custom_label_ + ": " + ods.str();
-       // shorten it if necessary
-       if (foot_tip.size() > 200)
-               foot_tip = foot_tip.substr(0, 200) + "...";
-       if (!isOpen() && !foot_tip.empty())
-               return foot_tip + '\n' + default_tip;
+       if (!isOpen())
+               return custom_label_ + ": " + default_tip;
        return default_tip;
 }
 
index 748ae3eca511b6e451a72f978971d997f502b6ca..2b5090561e56c7dbc15a7ebbd63a56087a5f3cb2 100644 (file)
@@ -38,22 +38,6 @@ docstring InsetMarginal::editMessage() const
 }
 
 
-docstring InsetMarginal::toolTip(BufferView const & bv, int x, int y) const
-{
-       docstring default_tip = InsetCollapsable::toolTip(bv, x, y);
-       OutputParams rp(&buffer().params().encoding());
-       odocstringstream ods;
-       InsetText::plaintext(ods, rp);
-       docstring margin_tip = ods.str();
-       // shorten it if necessary
-       if (margin_tip.size() > 200)
-               margin_tip = margin_tip.substr(0, 200) + "...";
-       if (!isOpen() && !margin_tip.empty())
-               return margin_tip + '\n' + default_tip;
-       return default_tip;
-}
-
-
 int InsetMarginal::latex(odocstream & os, OutputParams const & runparams) const
 {
        os << "%\n\\marginpar{";
index 2c395d601db4ea6053ba8b1e505b33da24869f6a..1899cf8d726683a4a2f7f4df39f85922ed2fec3e 100644 (file)
@@ -40,8 +40,6 @@ public:
        docstring editMessage() const;
        ///
        void addToToc(ParConstIterator const &) const;
-       ///
-       docstring toolTip(BufferView const & bv, int x, int y) const;
 private:
        ///
        Inset * clone() const { return new InsetMarginal(*this); }