From: Jürgen Spitzmüller Date: Sun, 27 Apr 2008 14:47:07 +0000 (+0000) Subject: * move extended tooltips support to InsetCollapsable (fixes bug 3778). X-Git-Tag: 1.6.10~4977 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=fa568e12f0e0ff116103e378b120023ceb4c6a8f;p=features.git * move extended tooltips support to InsetCollapsable (fixes bug 3778). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24524 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 7b8e292bd0..ab2649f701 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -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; } diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index f449e97783..d77701bcf4 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -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; diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index d320476733..d4e862c4e5 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -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; } diff --git a/src/insets/InsetMarginal.cpp b/src/insets/InsetMarginal.cpp index 748ae3eca5..2b5090561e 100644 --- a/src/insets/InsetMarginal.cpp +++ b/src/insets/InsetMarginal.cpp @@ -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{"; diff --git a/src/insets/InsetMarginal.h b/src/insets/InsetMarginal.h index 2c395d601d..1899cf8d72 100644 --- a/src/insets/InsetMarginal.h +++ b/src/insets/InsetMarginal.h @@ -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); }