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"
26 InsetMathSqrt::InsetMathSqrt()
31 auto_ptr<Inset> InsetMathSqrt::doClone() const
33 return auto_ptr<Inset>(new InsetMathSqrt(*this));
37 bool InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & dim) const
39 cell(0).metrics(mi, dim);
51 void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
53 cell(0).draw(pi, x + 10, y);
54 int const a = dim_.ascent();
55 int const d = dim_.descent();
58 pi.pain.line(x + dim_.width(), y - a + 1,
59 x + 8, y - a + 1, Color::math);
60 xp[0] = x + 8; yp[0] = y - a + 1;
61 xp[1] = x + 5; yp[1] = y + d - 1;
62 xp[2] = x; yp[2] = y + (d - a)/2;
63 pi.pain.lines(xp, yp, 3, Color::math);
64 drawMarkers(pi, x, y);
68 void InsetMathSqrt::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
70 cell(0).metricsT(mi, dim);
76 void InsetMathSqrt::drawT(TextPainter & pain, int x, int y) const
78 cell(0).drawT(pain, x + 2, y);
79 pain.horizontalLine(x + 2, y - cell(0).ascent(), cell(0).width(), '_');
80 pain.verticalLine (x + 1, y - cell(0).ascent() + 1, cell(0).height());
81 pain.draw(x, y + cell(0).descent(), '\\');
85 void InsetMathSqrt::write(WriteStream & os) const
87 os << "\\sqrt{" << cell(0) << '}';
91 void InsetMathSqrt::normalize(NormalStream & os) const
93 os << "[sqrt " << cell(0) << ']';
96 void InsetMathSqrt::maple(MapleStream & os) const
98 os << "sqrt(" << cell(0) << ')';
101 void InsetMathSqrt::mathematica(MathematicaStream & os) const
103 os << "Sqrt[" << cell(0) << ']';
107 void InsetMathSqrt::octave(OctaveStream & os) const
109 os << "sqrt(" << cell(0) << ')';
113 void InsetMathSqrt::mathmlize(MathStream & os) const
115 os << MTag("msqrt") << cell(0) << ETag("msqrt");