]> git.lyx.org Git - lyx.git/blob - src/mathed/math_sqrtinset.C
several smallish changes/bugfixes/left overs from Porto
[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         ascent_  = xcell(0).ascent()  + 4;
27         descent_ = xcell(0).descent() + 2;
28         width_   = xcell(0).width()   + 12;
29 }
30
31
32 void MathSqrtInset::draw(MathPainterInfo & pain, int x, int y) const
33 {
34         xcell(0).draw(pain, x + 10, y);
35         int const a = ascent_;
36         int const d = descent_;
37         int xp[4];
38         int yp[4];
39         xp[0] = x + 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         pain.pain.lines(xp, yp, 4, LColor::math);
44 }
45
46
47 void MathSqrtInset::metricsT(TextMetricsInfo const & mi) const
48 {
49         xcell(0).metricsT(mi);
50         ascent_  = xcell(0).ascent()  + 1;
51         descent_ = xcell(0).descent();
52         width_   = xcell(0).width()   + 2;
53 }
54
55
56 void MathSqrtInset::drawT(TextPainter & pain, int x, int y) const
57 {
58         xcell(0).drawT(pain, x + 2, y);
59         pain.horizontalLine(x + 2, y - xcell(0).ascent(), xcell(0).width(), '_');
60         pain.verticalLine  (x + 1, y - xcell(0).ascent() + 1, xcell(0).height());
61         pain.draw(x, y + xcell(0).descent(), '\\');
62 }
63
64
65 void MathSqrtInset::write(WriteStream & os) const
66 {
67         os << "\\sqrt{" << cell(0) << '}';
68 }
69
70
71 void MathSqrtInset::normalize(NormalStream & os) const
72 {
73         os << "[sqrt " << cell(0) << ']';
74 }
75
76
77 void MathSqrtInset::maplize(MapleStream & os) const
78 {
79         os << "sqrt(" << cell(0) << ')';
80 }
81
82
83 void MathSqrtInset::octavize(OctaveStream & os) const
84 {
85         os << "sqrt(" << cell(0) << ')';
86 }
87
88
89 void MathSqrtInset::mathmlize(MathMLStream & os) const
90 {
91         os << MTag("msqrt") << cell(0) << ETag("msqrt");
92 }