X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetPhantom.cpp;h=8a6d2e68dbe59cb426499ea75384801dfb949906;hb=142caff8336c54627606c09d3ce5bb7de7a8adb6;hp=9790e82e1d9c4d1e87f8487aa6a6f6e0b5ae91e5;hpb=96f45fc16382ee9f80193f1e78bf6c9b23709269;p=lyx.git diff --git a/src/insets/InsetPhantom.cpp b/src/insets/InsetPhantom.cpp index 9790e82e1d..8a6d2e68db 100644 --- a/src/insets/InsetPhantom.cpp +++ b/src/insets/InsetPhantom.cpp @@ -32,6 +32,7 @@ #include "support/docstream.h" #include "support/gettext.h" +#include "support/lstrings.h" #include "support/Translator.h" #include "frontends/Application.h" @@ -111,7 +112,7 @@ void InsetPhantomParams::read(Lexer & lex) // ///////////////////////////////////////////////////////////////////// -InsetPhantom::InsetPhantom(Buffer const & buf, string const & label) +InsetPhantom::InsetPhantom(Buffer * buf, string const & label) : InsetCollapsable(buf) { setDrawFrame(false); @@ -125,27 +126,15 @@ InsetPhantom::~InsetPhantom() } -docstring InsetPhantom::editMessage() const -{ - return _("Opened Phantom Inset"); -} - - docstring InsetPhantom::name() const { return from_ascii("Phantom:" + phantomtranslator().find(params_.type)); } -Inset::DisplayType InsetPhantom::display() const -{ - return Inline; -} - - void InsetPhantom::metrics(MetricsInfo & mi, Dimension & dim) const { - InsetText::metrics(mi, dim); + InsetCollapsable::metrics(mi, dim); // cache the inset dimension setDimCache(mi, dim); @@ -155,7 +144,7 @@ void InsetPhantom::metrics(MetricsInfo & mi, Dimension & dim) const void InsetPhantom::draw(PainterInfo & pi, int x, int y) const { // draw the text - InsetText::draw(pi, x, y); + InsetCollapsable::draw(pi, x, y); // draw the inset marker drawMarkers(pi, x, y); @@ -267,11 +256,10 @@ bool InsetPhantom::showInsetDialog(BufferView * bv) const void InsetPhantom::doDispatch(Cursor & cur, FuncRequest & cmd) { - switch (cmd.action) { + switch (cmd.action()) { case LFUN_INSET_MODIFY: string2params(to_utf8(cmd.argument()), params_); - setLayout(buffer().params()); break; case LFUN_INSET_DIALOG_UPDATE: @@ -288,9 +276,14 @@ void InsetPhantom::doDispatch(Cursor & cur, FuncRequest & cmd) bool InsetPhantom::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & flag) const { - switch (cmd.action) { + switch (cmd.action()) { case LFUN_INSET_MODIFY: + if (cmd.getArg(0) == "phantom") { + InsetPhantomParams params; + string2params(to_utf8(cmd.argument()), params); + flag.setOnOff(params_.type == params.type); + } flag.setEnabled(true); return true; @@ -308,55 +301,48 @@ docstring InsetPhantom::toolTip(BufferView const &, int, int) const { 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) + "..."; + InsetCollapsable::plaintext(ods, rp); + docstring content_tip = support::wrapParas(ods.str()); docstring res = phantomtranslator_loc().find(params_.type); if (!content_tip.empty()) - res += from_ascii(": ") + content_tip; + res += from_ascii(": ") + "\n" + content_tip; return res; } -int InsetPhantom::latex(odocstream & os, OutputParams const & runparams_in) const +int InsetPhantom::latex(odocstream & os, OutputParams const & runparams) const { - OutputParams runparams(runparams_in); if (params_.type == InsetPhantomParams::Phantom) os << "\\phantom{"; else if (params_.type == InsetPhantomParams::HPhantom) os << "\\hphantom{"; else if (params_.type == InsetPhantomParams::VPhantom) os << "\\vphantom{"; - int const i = InsetText::latex(os, runparams); + int const i = InsetCollapsable::latex(os, runparams); os << "}"; - runparams_in.encoding = runparams.encoding; - return i + 2; + return i; } int InsetPhantom::plaintext(odocstream & os, - OutputParams const & runparams_in) const + OutputParams const & runparams) const { - OutputParams runparams(runparams_in); if (params_.type == InsetPhantomParams::Phantom) os << '[' << buffer().B_("phantom") << ":"; else if (params_.type == InsetPhantomParams::HPhantom) os << '[' << buffer().B_("hphantom") << ":"; else if (params_.type == InsetPhantomParams::VPhantom) os << '[' << buffer().B_("vphantom") << ":"; - InsetText::plaintext(os, runparams); + InsetCollapsable::plaintext(os, runparams); os << "]"; return PLAINTEXT_NEWLINE; } -int InsetPhantom::docbook(odocstream & os, OutputParams const & runparams_in) const +int InsetPhantom::docbook(odocstream & os, OutputParams const & runparams) const { - OutputParams runparams(runparams_in); string cmdname; if (params_.type == InsetPhantomParams::Phantom) cmdname = "phantom"; @@ -365,13 +351,18 @@ int InsetPhantom::docbook(odocstream & os, OutputParams const & runparams_in) co else if (params_.type == InsetPhantomParams::VPhantom) cmdname = "phantom"; os << "<" + cmdname + ">"; - int const i = InsetText::docbook(os, runparams); + int const i = InsetCollapsable::docbook(os, runparams); os << ""; return i; } +docstring InsetPhantom::xhtml(XHTMLStream &, OutputParams const &) const +{ + return docstring(); +} + docstring InsetPhantom::contextMenu(BufferView const &, int, int) const { return from_ascii("context-phantom");