1 #include "math_sqrtinset.h"
2 #include "math_mathmlstream.h"
4 #include "frontends/Painter.h"
5 #include "textpainter.h"
10 MathSqrtInset::MathSqrtInset()
15 auto_ptr<InsetBase> MathSqrtInset::clone() const
17 return auto_ptr<InsetBase>(new MathSqrtInset(*this));
21 void MathSqrtInset::metrics(MetricsInfo & mi, Dimension & dim) const
23 cell(0).metrics(mi, dim_);
32 void MathSqrtInset::draw(PainterInfo & pi, int x, int y) const
34 cell(0).draw(pi, x + 10, y);
35 int const a = dim_.ascent();
36 int const d = dim_.descent();
39 xp[0] = x + dim_.width(); yp[0] = y - a + 1;
40 xp[1] = x + 8; yp[1] = y - a + 1;
41 xp[2] = x + 5; yp[2] = y + d - 1;
42 xp[3] = x; yp[3] = y + (d - a)/2;
43 pi.pain.lines(xp, yp, 4, LColor::math);
44 drawMarkers(pi, x, y);
48 void MathSqrtInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
50 cell(0).metricsT(mi, dim);
56 void MathSqrtInset::drawT(TextPainter & pain, int x, int y) const
58 cell(0).drawT(pain, x + 2, y);
59 pain.horizontalLine(x + 2, y - cell(0).ascent(), cell(0).width(), '_');
60 pain.verticalLine (x + 1, y - cell(0).ascent() + 1, cell(0).height());
61 pain.draw(x, y + cell(0).descent(), '\\');
65 void MathSqrtInset::write(WriteStream & os) const
67 os << "\\sqrt{" << cell(0) << '}';
71 void MathSqrtInset::normalize(NormalStream & os) const
73 os << "[sqrt " << cell(0) << ']';
76 void MathSqrtInset::maple(MapleStream & os) const
78 os << "sqrt(" << cell(0) << ')';
81 void MathSqrtInset::mathematica(MathematicaStream & os) const
83 os << "Sqrt[" << cell(0) << ']';
87 void MathSqrtInset::octave(OctaveStream & os) const
89 os << "sqrt(" << cell(0) << ')';
93 void MathSqrtInset::mathmlize(MathMLStream & os) const
95 os << MTag("msqrt") << cell(0) << ETag("msqrt");