]> git.lyx.org Git - lyx.git/blob - src/mathed/math_sqrtinset.C
architectural changes to tex2lyx
[lyx.git] / src / mathed / math_sqrtinset.C
1 #include "math_sqrtinset.h"
2 #include "math_mathmlstream.h"
3 #include "LColor.h"
4 #include "frontends/Painter.h"
5 #include "textpainter.h"
6
7 using std::auto_ptr;
8
9
10 MathSqrtInset::MathSqrtInset()
11         : MathNestInset(1)
12 {}
13
14
15 auto_ptr<InsetBase> MathSqrtInset::clone() const
16 {
17         return auto_ptr<InsetBase>(new MathSqrtInset(*this));
18 }
19
20
21 void MathSqrtInset::metrics(MetricsInfo & mi, Dimension & dim) const
22 {
23         cell(0).metrics(mi, dim_);
24         dim_.asc += 4;
25         dim_.des += 2;
26         dim_.wid += 12;
27         metricsMarkers(1);
28         dim = dim_;
29 }
30
31
32 void MathSqrtInset::draw(PainterInfo & pi, int x, int y) const
33 {
34         cell(0).draw(pi, x + 10, y);
35         int const a = dim_.ascent();
36         int const d = dim_.descent();
37         int xp[4];
38         int yp[4];
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);
45 }
46
47
48 void MathSqrtInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
49 {
50         cell(0).metricsT(mi, dim);
51         dim.asc += 1;
52         dim.wid += 2;
53 }
54
55
56 void MathSqrtInset::drawT(TextPainter & pain, int x, int y) const
57 {
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(), '\\');
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 void MathSqrtInset::maple(MapleStream & os) const
77 {
78         os << "sqrt(" << cell(0) << ')';
79 }
80
81 void MathSqrtInset::mathematica(MathematicaStream & os) const
82 {
83         os << "Sqrt[" << cell(0) << ']';
84 }
85
86
87 void MathSqrtInset::octave(OctaveStream & os) const
88 {
89         os << "sqrt(" << cell(0) << ')';
90 }
91
92
93 void MathSqrtInset::mathmlize(MathMLStream & os) const
94 {
95         os << MTag("msqrt") << cell(0) << ETag("msqrt");
96 }