X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetPhantom.cpp;h=d1a25f6a70bc32cfcce4f32712c6112e7e37ca97;hb=8124e6c02ea1fd6779bb6c47ffe2bca2c8bd2d97;hp=c1da30195755ea0195a4410ca796b8f858fd13d7;hpb=fd5d47d182a70de532225715a04b77fe4155aa18;p=lyx.git diff --git a/src/insets/InsetPhantom.cpp b/src/insets/InsetPhantom.cpp index c1da301957..d1a25f6a70 100644 --- a/src/insets/InsetPhantom.cpp +++ b/src/insets/InsetPhantom.cpp @@ -15,19 +15,16 @@ #include "Buffer.h" #include "BufferParams.h" #include "BufferView.h" -#include "BufferParams.h" -#include "Counters.h" #include "Cursor.h" #include "Dimension.h" #include "DispatchResult.h" #include "Exporter.h" #include "FuncRequest.h" #include "FuncStatus.h" -#include "InsetIterator.h" #include "LaTeXFeatures.h" #include "Lexer.h" #include "MetricsInfo.h" -#include "OutputParams.h" +#include "texstream.h" #include "TextClass.h" #include "support/docstream.h" @@ -84,7 +81,7 @@ PhantomTranslatorLoc const & phantomtranslator_loc() return translator; } -} // anon +} // namespace InsetPhantomParams::InsetPhantomParams() @@ -115,7 +112,7 @@ void InsetPhantomParams::read(Lexer & lex) ///////////////////////////////////////////////////////////////////// InsetPhantom::InsetPhantom(Buffer * buf, string const & label) - : InsetCollapsable(buf) + : InsetCollapsible(buf) { setDrawFrame(false); params_.type = phantomtranslator().find(label); @@ -134,29 +131,20 @@ docstring InsetPhantom::layoutName() const } -void InsetPhantom::metrics(MetricsInfo & mi, Dimension & dim) const -{ - InsetCollapsable::metrics(mi, dim); - - // cache the inset dimension - setDimCache(mi, dim); -} - - void InsetPhantom::draw(PainterInfo & pi, int x, int y) const { // draw the text - InsetCollapsable::draw(pi, x, y); + InsetCollapsible::draw(pi, x, y); // draw the inset marker drawMarkers(pi, x, y); - + // draw the arrow(s) static int const arrow_size = 4; ColorCode const origcol = pi.base.font.color(); pi.base.font.setColor(Color_special); pi.base.font.setColor(origcol); - Dimension const dim = Inset::dimension(*pi.base.bv); + Dimension const dim = dimension(*pi.base.bv); if (params_.type == InsetPhantomParams::Phantom || params_.type == InsetPhantomParams::VPhantom) { @@ -203,10 +191,10 @@ void InsetPhantom::draw(PainterInfo & pi, int x, int y) const // | | | | // x1 x2 x3 x4 - x = x + TEXT_TO_INSET_OFFSET; + x += leftOffset(pi.base.bv); int const x1 = x; int const x2 = x + arrow_size; - int const x4 = x + dim.wid - 2 * TEXT_TO_INSET_OFFSET; + int const x4 = x + dim.wid - leftOffset(pi.base.bv) - rightOffset(pi.base.bv); int const x3 = x4 - arrow_size; int const y2 = y + (dim.des - dim.asc) / 2; @@ -230,14 +218,14 @@ void InsetPhantom::draw(PainterInfo & pi, int x, int y) const void InsetPhantom::write(ostream & os) const { params_.write(os); - InsetCollapsable::write(os); + InsetCollapsible::write(os); } void InsetPhantom::read(Lexer & lex) { params_.read(lex); - InsetCollapsable::read(lex); + InsetCollapsible::read(lex); } @@ -261,7 +249,7 @@ void InsetPhantom::doDispatch(Cursor & cur, FuncRequest & cmd) switch (cmd.action()) { case LFUN_INSET_MODIFY: - cur.recordUndoInset(ATOMIC_UNDO, this); + cur.recordUndoInset(this); string2params(to_utf8(cmd.argument()), params_); setButtonLabel(); cur.forceBufferUpdate(); @@ -272,7 +260,7 @@ void InsetPhantom::doDispatch(Cursor & cur, FuncRequest & cmd) break; default: - InsetCollapsable::doDispatch(cur, cmd); + InsetCollapsible::doDispatch(cur, cmd); break; } } @@ -297,7 +285,7 @@ bool InsetPhantom::getStatus(Cursor & cur, FuncRequest const & cmd, return true; default: - return InsetCollapsable::getStatus(cur, cmd, flag); + return InsetCollapsible::getStatus(cur, cmd, flag); } } @@ -312,7 +300,7 @@ docstring InsetPhantom::toolTip(BufferView const &, int, int) const void InsetPhantom::latex(otexstream & os, OutputParams const & runparams) const { if (runparams.moving_arg) - os << "\\protect"; + os << "\\protect"; switch (params_.type) { case InsetPhantomParams::Phantom: @@ -328,7 +316,7 @@ void InsetPhantom::latex(otexstream & os, OutputParams const & runparams) const os << "\\phantom{"; break; } - InsetCollapsable::latex(os, runparams); + InsetCollapsible::latex(os, runparams); os << "}"; } @@ -339,39 +327,31 @@ int InsetPhantom::plaintext(odocstringstream & os, switch (params_.type) { case InsetPhantomParams::Phantom: os << '[' << buffer().B_("phantom") << ":"; + break; case InsetPhantomParams::HPhantom: os << '[' << buffer().B_("hphantom") << ":"; + break; case InsetPhantomParams::VPhantom: os << '[' << buffer().B_("vphantom") << ":"; + break; default: os << '[' << buffer().B_("phantom") << ":"; + break; } - InsetCollapsable::plaintext(os, runparams, max_length); + InsetCollapsible::plaintext(os, runparams, max_length); os << "]"; return PLAINTEXT_NEWLINE; } -int InsetPhantom::docbook(odocstream & os, OutputParams const & runparams) const +void InsetPhantom::docbook(XMLStream &, OutputParams const &) const { - string cmdname; - switch (params_.type) { - case InsetPhantomParams::Phantom: - case InsetPhantomParams::HPhantom: - case InsetPhantomParams::VPhantom: - default: - cmdname = "phantom"; - } - os << "<" + cmdname + ">"; - int const i = InsetCollapsable::docbook(os, runparams); - os << ""; - - return i; + return; } -docstring InsetPhantom::xhtml(XHTMLStream &, OutputParams const &) const +docstring InsetPhantom::xhtml(XMLStream &, OutputParams const &) const { return docstring(); }