X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathPhantom.cpp;h=583e9f0b899ea7773a9db9cba8f645337e662062;hb=cdc847fd304019a19425a0d5d9d42a556a937097;hp=bbc2234a1863b2fe59f442a40c59e6f4af5583cd;hpb=187790135b73e3e99a43e53f8c6494d119e94e98;p=lyx.git diff --git a/src/mathed/InsetMathPhantom.cpp b/src/mathed/InsetMathPhantom.cpp index bbc2234a18..583e9f0b89 100644 --- a/src/mathed/InsetMathPhantom.cpp +++ b/src/mathed/InsetMathPhantom.cpp @@ -14,8 +14,12 @@ #include "LaTeXFeatures.h" #include "MathStream.h" + +#include "MetricsInfo.h" + #include "frontends/Painter.h" +#include #include namespace lyx { @@ -34,20 +38,21 @@ Inset * InsetMathPhantom::clone() const void InsetMathPhantom::metrics(MetricsInfo & mi, Dimension & dim) const { + Changer dummy = mi.base.changeEnsureMath(); cell(0).metrics(mi, dim); - metricsMarkers(dim); } void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const { + Changer dummy = pi.base.changeEnsureMath(); static int const arrow_size = 4; // We first draw the text and then an arrow ColorCode const origcol = pi.base.font.color(); if (visibleContents()) pi.base.font.setColor(Color_special); - cell(0).draw(pi, x + 1, y); + cell(0).draw(pi, x, y); if (visibleContents()) pi.base.font.setColor(origcol); Dimension const dim = dimension(*pi.base.bv); @@ -197,7 +202,7 @@ void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const pi.pain.line(x1, y2, x3, y2, Color_added_space); } - else if (kind_ == smash) { + else if (kind_ == smash || kind_ == smasht || kind_ == smashb) { // y1--------- // | // y2----- \ | / @@ -222,24 +227,33 @@ void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const int const y4 = std::min(y5, y3 + arrow_size); // top arrow - pi.pain.line(x1, y2, x2, y3, Color_added_space); - pi.pain.line(x3, y2, x2, y3, Color_added_space); + if (kind_ != smashb) { + pi.pain.line(x1, y2, x2, y3, Color_added_space); + pi.pain.line(x3, y2, x2, y3, Color_added_space); + } // bottom arrow - pi.pain.line(x1, y4, x2, y3, Color_added_space); - pi.pain.line(x3, y4, x2, y3, Color_added_space); + if (kind_ != smasht) { + pi.pain.line(x1, y4, x2, y3, Color_added_space); + pi.pain.line(x3, y4, x2, y3, Color_added_space); + } // joining line - pi.pain.line(x2, y1, x2, y5, Color_added_space); + if (kind_ == smasht) + pi.pain.line(x2, y1, x2, y3, Color_added_space); + else if (kind_ == smashb) + pi.pain.line(x2, y3, x2, y5, Color_added_space); + else + pi.pain.line(x2, y1, x2, y5, Color_added_space); } - - drawMarkers(pi, x, y); } void InsetMathPhantom::write(WriteStream & os) const { MathEnsurer ensurer(os); + if (os.fragile()) + os << "\\protect"; switch (kind_) { case phantom: os << "\\phantom{"; @@ -253,6 +267,12 @@ void InsetMathPhantom::write(WriteStream & os) const case smash: os << "\\smash{"; break; + case smasht: + os << "\\smash[t]{"; + break; + case smashb: + os << "\\smash[b]{"; + break; case mathclap: os << "\\mathclap{"; break; @@ -282,6 +302,12 @@ void InsetMathPhantom::normalize(NormalStream & os) const case smash: os << "[smash "; break; + case smasht: + os << "[smasht "; + break; + case smashb: + os << "[smashb "; + break; case mathclap: os << "[mathclap "; break; @@ -311,6 +337,12 @@ void InsetMathPhantom::infoize(odocstream & os) const case smash: os << "Smash"; break; + case smasht: + os << "Smashtop"; + break; + case smashb: + os << "Smashbottom"; + break; case mathllap: os << "Mathllap"; break; @@ -333,6 +365,10 @@ void InsetMathPhantom::validate(LaTeXFeatures & features) const case hphantom: case smash: break; + case smasht: + case smashb: + features.require("amsmath"); + break; case mathclap: case mathllap: case mathrlap: @@ -344,7 +380,7 @@ void InsetMathPhantom::validate(LaTeXFeatures & features) const bool InsetMathPhantom::visibleContents() const { - return kind_ == phantom || kind_ == vphantom || kind_ == vphantom; + return kind_ == phantom || kind_ == vphantom || kind_ == hphantom; }