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 "MathStream.h"
16 #include "TextPainter.h"
18 #include "frontends/Painter.h"
23 InsetMathSqrt::InsetMathSqrt()
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);
41 // Cache the inset dimension.
46 void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
48 cell(0).draw(pi, x + 10, y);
49 Dimension const dim = dimension(*pi.base.bv);
50 int const a = dim.ascent();
51 int const d = dim.descent();
54 pi.pain.line(x + dim.width(), y - a + 1,
55 x + 8, y - a + 1, Color::math);
56 xp[0] = x + 8; yp[0] = y - a + 1;
57 xp[1] = x + 5; yp[1] = y + d - 1;
58 xp[2] = x; yp[2] = y + (d - a)/2;
59 pi.pain.lines(xp, yp, 3, Color::math);
60 drawMarkers(pi, x, y);
64 void InsetMathSqrt::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
66 cell(0).metricsT(mi, dim);
72 void InsetMathSqrt::drawT(TextPainter & /*pain*/, int /*x*/, int /*y*/) const
75 cell(0).drawT(pain, x + 2, y);
76 Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
77 pain.horizontalLine(x + 2, y - dim0.ascent(), dim0.width(), '_');
78 pain.verticalLine (x + 1, y - dim0.ascent() + 1, dim0.height());
79 pain.draw(x, y + dim0.descent(), '\\');
84 void InsetMathSqrt::write(WriteStream & os) const
86 os << "\\sqrt{" << cell(0) << '}';
90 void InsetMathSqrt::normalize(NormalStream & os) const
92 os << "[sqrt " << cell(0) << ']';
95 void InsetMathSqrt::maple(MapleStream & os) const
97 os << "sqrt(" << cell(0) << ')';
100 void InsetMathSqrt::mathematica(MathematicaStream & os) const
102 os << "Sqrt[" << cell(0) << ']';
106 void InsetMathSqrt::octave(OctaveStream & os) const
108 os << "sqrt(" << cell(0) << ')';
112 void InsetMathSqrt::mathmlize(MathStream & os) const
114 os << MTag("msqrt") << cell(0) << ETag("msqrt");