]> git.lyx.org Git - lyx.git/blob - src/mathed/math_sqrtinset.C
fix #1073
[lyx.git] / src / mathed / math_sqrtinset.C
1
2 #include "math_sqrtinset.h"
3 #include "math_mathmlstream.h"
4 #include "LColor.h"
5 #include "frontends/Painter.h"
6 #include "textpainter.h"
7
8
9 MathSqrtInset::MathSqrtInset()
10         : MathNestInset(1)
11 {}
12
13
14 MathInset * MathSqrtInset::clone() const
15 {
16         return new MathSqrtInset(*this);
17 }
18
19
20 void MathSqrtInset::metrics(MetricsInfo & mi) const
21 {
22         cell(0).metrics(mi);
23         dim_.a = cell(0).ascent()  + 4;
24         dim_.d = cell(0).descent() + 2;
25         dim_.w = cell(0).width()   + 12;
26         metricsMarkers();
27 }
28
29
30 void MathSqrtInset::draw(PainterInfo & pi, int x, int y) const
31 {
32         cell(0).draw(pi, x + 10, y);
33         int const a = ascent();
34         int const d = descent();
35         int xp[4];
36         int yp[4];
37         xp[0] = x + width(); yp[0] = y - a + 1;
38         xp[1] = x + 8;       yp[1] = y - a + 1;
39         xp[2] = x + 5;       yp[2] = y + d - 1;
40         xp[3] = x;           yp[3] = y + (d - a)/2;
41         pi.pain.lines(xp, yp, 4, LColor::math);
42         drawMarkers(pi, x, y);
43 }
44
45
46 void MathSqrtInset::metricsT(TextMetricsInfo const & mi) const
47 {
48         cell(0).metricsT(mi);
49         dim_.a = cell(0).ascent()  + 1;
50         dim_.d = cell(0).descent();
51         dim_.w = cell(0).width()   + 2;
52 }
53
54
55 void MathSqrtInset::drawT(TextPainter & pain, int x, int y) const
56 {
57         cell(0).drawT(pain, x + 2, y);
58         pain.horizontalLine(x + 2, y - cell(0).ascent(), cell(0).width(), '_');
59         pain.verticalLine  (x + 1, y - cell(0).ascent() + 1, cell(0).height());
60         pain.draw(x, y + cell(0).descent(), '\\');
61 }
62
63
64 void MathSqrtInset::write(WriteStream & os) const
65 {
66         os << "\\sqrt{" << cell(0) << '}';
67 }
68
69
70 void MathSqrtInset::normalize(NormalStream & os) const
71 {
72         os << "[sqrt " << cell(0) << ']';
73 }
74
75 void MathSqrtInset::maple(MapleStream & os) const
76 {
77         os << "sqrt(" << cell(0) << ')';
78 }
79
80 void MathSqrtInset::mathematica(MathematicaStream & os) const
81 {
82         os << "Sqrt[" << cell(0) << ']';
83 }
84
85
86 void MathSqrtInset::octave(OctaveStream & os) const
87 {
88         os << "sqrt(" << cell(0) << ')';
89 }
90
91
92 void MathSqrtInset::mathmlize(MathMLStream & os) const
93 {
94         os << MTag("msqrt") << cell(0) << ETag("msqrt");
95 }