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