#include "support/docstream.h"
#include "support/gettext.h"
+#include "support/lstrings.h"
#include "support/Translator.h"
#include "frontends/Application.h"
//
/////////////////////////////////////////////////////////////////////
-InsetPhantom::InsetPhantom(Buffer const & buf, string const & label)
+InsetPhantom::InsetPhantom(Buffer * buf, string const & label)
: InsetCollapsable(buf)
{
+ setDrawFrame(false);
params_.type = phantomtranslator().find(label);
}
}
-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);
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);
case LFUN_INSET_MODIFY:
string2params(to_utf8(cmd.argument()), params_);
- setLayout(buffer().params());
break;
case LFUN_INSET_DIALOG_UPDATE:
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;
}
-docstring InsetPhantom::toolTip(BufferView const & bv, int x, int y) const
+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) + "...";
- if (params_.type == InsetPhantomParams::Phantom)
- return from_ascii("Phantom: ") + content_tip;
- if (params_.type == InsetPhantomParams::HPhantom)
- return from_ascii("HPhantom: ") + content_tip;
- if (params_.type == InsetPhantomParams::VPhantom)
- return from_ascii("VPhantom: ") + content_tip;
+ 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(": ") + "\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";
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 << "</" + cmdname + ">";
return i;
}
+docstring InsetPhantom::xhtml(XHTMLStream &, OutputParams const &) const
+{
+ return docstring();
+}
+
docstring InsetPhantom::contextMenu(BufferView const &, int, int) const
{
return from_ascii("context-phantom");