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);
42 metricsMarkers(mi, dim);
46 void InsetMathCancel::draw(PainterInfo & pi, int x, int y) const
48 Changer dummy = pi.base.changeEnsureMath();
49 // We first draw the text and then an arrow
50 ColorCode const origcol = pi.base.font.color();
51 cell(0).draw(pi, x + 1, y);
52 Dimension const dim = dimension(*pi.base.bv);
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);
71 else if (kind_ == bcancel)
72 pi.pain.line(x2, y2, x1, y1, origcol);
73 else if (kind_ == xcancel) {
74 pi.pain.line(x2, y1, x1, y2, origcol);
75 pi.pain.line(x2, y2, x1, y1, origcol);
78 drawMarkers(pi, x, y);
82 void InsetMathCancel::write(WriteStream & os) const
84 MathEnsurer ensurer(os);
100 void InsetMathCancel::normalize(NormalStream & os) const
113 os << cell(0) << ']';
117 void InsetMathCancel::infoize(odocstream & os) const
133 // unfortunately, we do not have many options here, so we have to treat
134 // them all the same way.
135 void InsetMathCancel::htmlize(HtmlStream & os) const
137 os << MTag("span", "style='text-decoration: line-through;'")
143 void InsetMathCancel::mathmlize(MathStream & os) const
147 os << MTag("menclose", "notation='updiagonalstrike'")
152 os << MTag("menclose", "notation='downdiagonalstrike'")
157 os << MTag("menclose", "notation='updiagonalstrike'")
158 << MTag("menclose", "notation='downdiagonalstrike'")
167 void InsetMathCancel::validate(LaTeXFeatures & features) const
169 InsetMathNest::validate(features);
170 if (features.runparams().isLaTeX())
171 features.require("cancel");
172 InsetMathNest::validate(features);