mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
Extended tooltips for footnotes/marginpars:
* src/insets/InsetFoot.{cpp,h}: * src/insets/InsetMarginal.{cpp,h}: - implement tooltip git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24202 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
64cfc12f39
commit
9ad1a3af4f
@ -26,6 +26,7 @@
|
||||
#include "TocBackend.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/docstream.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <ostream>
|
||||
@ -55,9 +56,10 @@ void InsetFoot::updateLabels(ParIterator const & it)
|
||||
if (!outer.layout().intitle && cnts.hasCounter(foot)) {
|
||||
cnts.step(foot);
|
||||
// FIXME: the counter should format itself.
|
||||
setLabel(support::bformat(from_ascii("%1$s %2$s"),
|
||||
custom_label_= support::bformat(from_ascii("%1$s %2$s"),
|
||||
getLayout(buffer().params()).labelstring(),
|
||||
cnts.theCounter(foot)));
|
||||
cnts.theCounter(foot));
|
||||
setLabel(custom_label_);
|
||||
|
||||
}
|
||||
InsetCollapsable::updateLabels(it);
|
||||
@ -72,11 +74,27 @@ void InsetFoot::addToToc(ParConstIterator const & cpit) const
|
||||
Toc & toc = buffer().tocBackend().toc("footnote");
|
||||
// FIXME: we probably want the footnote number too.
|
||||
docstring str;
|
||||
str = getNewLabel(str);
|
||||
str = custom_label_ + ": " + getNewLabel(str);
|
||||
toc.push_back(TocItem(pit, 0, str));
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
return default_tip;
|
||||
}
|
||||
|
||||
|
||||
int InsetFoot::latex(odocstream & os, OutputParams const & runparams_in) const
|
||||
{
|
||||
OutputParams runparams = runparams_in;
|
||||
|
@ -44,7 +44,11 @@ private:
|
||||
///
|
||||
void addToToc(ParConstIterator const &) const;
|
||||
///
|
||||
docstring toolTip(BufferView const & bv, int x, int y) const;
|
||||
///
|
||||
Inset * clone() const { return new InsetFoot(*this); }
|
||||
///
|
||||
docstring custom_label_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -14,9 +14,11 @@
|
||||
#include "InsetMarginal.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
#include "OutputParams.h"
|
||||
#include "TocBackend.h"
|
||||
|
||||
#include "support/docstream.h"
|
||||
#include "support/gettext.h"
|
||||
|
||||
#include <ostream>
|
||||
@ -36,6 +38,22 @@ 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{";
|
||||
|
@ -40,6 +40,8 @@ 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); }
|
||||
|
Loading…
Reference in New Issue
Block a user