2 * \file InsetMathSqrt.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 "InsetMathSqrt.h"
15 #include "InsetMathRoot.h"
17 #include "MathStream.h"
18 #include "MathSupport.h"
20 #include "LaTeXFeatures.h"
21 #include "MetricsInfo.h"
22 #include "TextPainter.h"
24 #include "frontends/Painter.h"
29 InsetMathSqrt::InsetMathSqrt(Buffer * buf)
30 : InsetMathNest(buf, 1)
34 Inset * InsetMathSqrt::clone() const
36 return new InsetMathSqrt(*this);
40 void InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & dim) const
42 mathed_root_metrics(mi, cell(0), nullptr, dim);
46 void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
48 mathed_draw_root(pi, x, y, cell(0), nullptr, dimension(*pi.base.bv));
52 void InsetMathSqrt::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
54 cell(0).metricsT(mi, dim);
60 void InsetMathSqrt::drawT(TextPainter & /*pain*/, int /*x*/, int /*y*/) const
63 cell(0).drawT(pain, x + 2, y);
64 Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
65 pain.horizontalLine(x + 2, y - dim0.ascent(), dim0.width(), '_');
66 pain.verticalLine (x + 1, y - dim0.ascent() + 1, dim0.height());
67 pain.draw(x, y + dim0.descent(), '\\');
72 void InsetMathSqrt::write(TeXMathStream & os) const
74 MathEnsurer ensurer(os);
75 os << "\\sqrt{" << cell(0) << '}';
79 void InsetMathSqrt::normalize(NormalStream & os) const
81 os << "[sqrt " << cell(0) << ']';
84 void InsetMathSqrt::maple(MapleStream & os) const
86 os << "sqrt(" << cell(0) << ')';
89 void InsetMathSqrt::mathematica(MathematicaStream & os) const
91 os << "Sqrt[" << cell(0) << ']';
95 void InsetMathSqrt::octave(OctaveStream & os) const
97 os << "sqrt(" << cell(0) << ')';
101 void InsetMathSqrt::mathmlize(MathMLStream & ms) const
103 ms << MTag("msqrt") << cell(0) << ETag("msqrt");
107 void InsetMathSqrt::htmlize(HtmlStream & os) const
109 os << MTag("span", "class='sqrt'")
110 << from_ascii("√")
111 << MTag("span", "class='sqrtof'") << cell(0) << ETag("span")
116 void InsetMathSqrt::validate(LaTeXFeatures & features) const
118 if (features.runparams().math_flavor == OutputParams::MathAsHTML)
119 features.addCSSSnippet("span.sqrtof{border-top: thin solid black;}");
120 InsetMathNest::validate(features);