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 bool InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & dim) const
36 cell(0).metrics(mi, dim);
48 void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
50 cell(0).draw(pi, x + 10, y);
51 int const a = dim_.ascent();
52 int const d = dim_.descent();
55 pi.pain.line(x + dim_.width(), y - a + 1,
56 x + 8, y - a + 1, Color::math);
57 xp[0] = x + 8; yp[0] = y - a + 1;
58 xp[1] = x + 5; yp[1] = y + d - 1;
59 xp[2] = x; yp[2] = y + (d - a)/2;
60 pi.pain.lines(xp, yp, 3, Color::math);
61 drawMarkers(pi, x, y);
65 void InsetMathSqrt::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
67 cell(0).metricsT(mi, dim);
73 void InsetMathSqrt::drawT(TextPainter & pain, int x, int y) const
75 cell(0).drawT(pain, x + 2, y);
76 pain.horizontalLine(x + 2, y - cell(0).ascent(), cell(0).width(), '_');
77 pain.verticalLine (x + 1, y - cell(0).ascent() + 1, cell(0).height());
78 pain.draw(x, y + cell(0).descent(), '\\');
82 void InsetMathSqrt::write(WriteStream & os) const
84 os << "\\sqrt{" << cell(0) << '}';
88 void InsetMathSqrt::normalize(NormalStream & os) const
90 os << "[sqrt " << cell(0) << ']';
93 void InsetMathSqrt::maple(MapleStream & os) const
95 os << "sqrt(" << cell(0) << ')';
98 void InsetMathSqrt::mathematica(MathematicaStream & os) const
100 os << "Sqrt[" << cell(0) << ']';
104 void InsetMathSqrt::octave(OctaveStream & os) const
106 os << "sqrt(" << cell(0) << ')';
110 void InsetMathSqrt::mathmlize(MathStream & os) const
112 os << MTag("msqrt") << cell(0) << ETag("msqrt");