]> git.lyx.org Git - lyx.git/blob - src/mathed/math_sqrtinset.C
IU of drawing phase one without 'semantic changes' as requested by John
[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, Dimension & dim) const
21 {
22         cell(0).metrics(mi, dim_);
23         dim_.asc += 4;
24         dim_.des += 2;
25         dim_.wid += 12;
26         metricsMarkers(1);
27         dim = dim_;
28 }
29
30
31 void MathSqrtInset::draw(PainterInfo & pi, int x, int y) const
32 {
33         cell(0).draw(pi, x + 10, y);
34         int const a = dim_.ascent();
35         int const d = dim_.descent();
36         int xp[4];
37         int yp[4];
38         xp[0] = x + dim_.width(); yp[0] = y - a + 1;
39         xp[1] = x + 8;            yp[1] = y - a + 1;
40         xp[2] = x + 5;            yp[2] = y + d - 1;
41         xp[3] = x;                yp[3] = y + (d - a)/2;
42         pi.pain.lines(xp, yp, 4, LColor::math);
43         drawMarkers(pi, x, y);
44 }
45
46
47 void MathSqrtInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
48 {
49         cell(0).metricsT(mi, dim);
50         dim.asc += 1;
51         dim.wid += 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 }