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 "LaTeXFeatures.h"
16 #include "MathStream.h"
18 #include "frontends/Painter.h"
25 InsetMathCancel::InsetMathCancel(Buffer * buf, Kind k)
26 : InsetMathNest(buf, 1), kind_(k)
30 Inset * InsetMathCancel::clone() const
32 return new InsetMathCancel(*this);
36 void InsetMathCancel::metrics(MetricsInfo & mi, Dimension & dim) const
38 cell(0).metrics(mi, dim);
43 void InsetMathCancel::draw(PainterInfo & pi, int x, int y) const
45 // We first draw the text and then an arrow
46 ColorCode const origcol = pi.base.font.color();
47 cell(0).draw(pi, x + 1, y);
48 Dimension const dim = dimension(*pi.base.bv);
58 int const x2 = x + dim.wid;
60 int const y1 = y - dim.asc;
61 int const y2 = y + dim.des;
64 pi.pain.line(x2, y1, x1, y2, origcol);
65 else if (kind_ == bcancel)
66 pi.pain.line(x2, y2, x1, y1, origcol);
67 else if (kind_ == xcancel) {
68 pi.pain.line(x2, y1, x1, y2, origcol);
69 pi.pain.line(x2, y2, x1, y1, origcol);
72 drawMarkers(pi, x, y);
76 void InsetMathCancel::write(WriteStream & os) const
78 MathEnsurer ensurer(os);
94 void InsetMathCancel::normalize(NormalStream & os) const
107 os << cell(0) << ']';
111 void InsetMathCancel::infoize(odocstream & os) const
126 void InsetMathCancel::validate(LaTeXFeatures & features) const
128 InsetMathNest::validate(features);
129 if (features.runparams().isLaTeX())
130 features.require("cancel");
131 InsetMathNest::validate(features);