2 * \file InsetMathCancel.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathCancel.h"
15 #include "MathStream.h"
17 #include "LaTeXFeatures.h"
18 #include "MetricsInfo.h"
20 #include "frontends/Painter.h"
27 InsetMathCancel::InsetMathCancel(Buffer * buf, Kind k)
28 : InsetMathNest(buf, 1), kind_(k)
32 Inset * InsetMathCancel::clone() const
34 return new InsetMathCancel(*this);
38 void InsetMathCancel::metrics(MetricsInfo & mi, Dimension & dim) const
40 Changer dummy = mi.base.changeEnsureMath();
41 cell(0).metrics(mi, dim);
45 void InsetMathCancel::draw(PainterInfo & pi, int x, int y) const
47 Changer dummy = pi.base.changeEnsureMath();
48 // We first draw the text and then an arrow
49 ColorCode const origcol = pi.base.font.color();
50 cell(0).draw(pi, x, y);
51 Dimension const dim = dimension(*pi.base.bv);
52 int const t = pi.base.solidLineThickness();
64 int const x2 = x + dim.wid;
66 int const y1 = y - dim.asc;
67 int const y2 = y + dim.des;
70 pi.pain.line(x2, y1, x1, y2, origcol, pi.pain.line_solid, t);
71 else if (kind_ == bcancel)
72 pi.pain.line(x2, y2, x1, y1, origcol, pi.pain.line_solid, t);
73 else if (kind_ == xcancel) {
74 pi.pain.line(x2, y1, x1, y2, origcol, pi.pain.line_solid, t);
75 pi.pain.line(x2, y2, x1, y1, origcol, pi.pain.line_solid, t);
80 void InsetMathCancel::write(TeXMathStream & os) const
82 MathEnsurer ensurer(os);
98 void InsetMathCancel::normalize(NormalStream & os) const
111 os << cell(0) << ']';
115 void InsetMathCancel::infoize(odocstream & os) const
131 // unfortunately, we do not have many options here, so we have to treat
132 // them all the same way.
133 void InsetMathCancel::htmlize(HtmlStream & os) const
135 os << MTag("span", "style='text-decoration: line-through;'")
141 void InsetMathCancel::mathmlize(MathMLStream & ms) const
145 ms << MTag("menclose", "notation='updiagonalstrike'")
150 ms << MTag("menclose", "notation='downdiagonalstrike'")
155 ms << MTag("menclose", "notation='updiagonalstrike'")
156 << MTag("menclose", "notation='downdiagonalstrike'")
165 void InsetMathCancel::validate(LaTeXFeatures & features) const
167 InsetMathNest::validate(features);
168 if (features.runparams().isLaTeX())
169 features.require("cancel");
170 InsetMathNest::validate(features);