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 "MathExtern.h"
16 #include "MathStream.h"
17 #include "TextPainter.h"
18 #include "frontends/Painter.h"
23 InsetMathSqrt::InsetMathSqrt(Buffer * buf)
24 : InsetMathNest(buf, 1)
28 Inset * InsetMathSqrt::clone() const
30 return new InsetMathSqrt(*this);
34 void InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & dim) const
36 cell(0).metrics(mi, dim);
44 void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
46 cell(0).draw(pi, x + 10, y);
47 Dimension const dim = dimension(*pi.base.bv);
48 int const a = dim.ascent();
49 int const d = dim.descent();
52 pi.pain.line(x + dim.width(), y - a + 1,
53 x + 8, y - a + 1, Color_math);
54 xp[0] = x + 8; yp[0] = y - a + 1;
55 xp[1] = x + 5; yp[1] = y + d - 1;
56 xp[2] = x; yp[2] = y + (d - a)/2;
57 pi.pain.lines(xp, yp, 3, Color_math);
58 drawMarkers(pi, x, y);
62 void InsetMathSqrt::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
64 cell(0).metricsT(mi, dim);
70 void InsetMathSqrt::drawT(TextPainter & /*pain*/, int /*x*/, int /*y*/) const
73 cell(0).drawT(pain, x + 2, y);
74 Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
75 pain.horizontalLine(x + 2, y - dim0.ascent(), dim0.width(), '_');
76 pain.verticalLine (x + 1, y - dim0.ascent() + 1, dim0.height());
77 pain.draw(x, y + dim0.descent(), '\\');
82 void InsetMathSqrt::write(WriteStream & os) const
84 MathEnsurer ensurer(os);
85 os << "\\sqrt{" << cell(0) << '}';
89 void InsetMathSqrt::normalize(NormalStream & os) const
91 os << "[sqrt " << cell(0) << ']';
94 void InsetMathSqrt::maple(MapleStream & os) const
96 os << "sqrt(" << cell(0) << ')';
99 void InsetMathSqrt::mathematica(MathematicaStream & os) const
101 os << "Sqrt[" << cell(0) << ']';
105 void InsetMathSqrt::octave(OctaveStream & os) const
107 os << "sqrt(" << cell(0) << ')';
111 docstring InsetMathSqrt::mathmlize(MathStream & os) const
114 docstring const rv = lyx::mathmlize(cell(0), os);