]> git.lyx.org Git - lyx.git/blob - src/mathed/math_sqrtinset.C
Finish the task of removing all cruft from the header files.
[lyx.git] / src / mathed / math_sqrtinset.C
1 /**
2  * \file math_sqrtinset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "math_sqrtinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "textpainter.h"
17 #include "frontends/Painter.h"
18
19 using std::auto_ptr;
20
21
22 MathSqrtInset::MathSqrtInset()
23         : MathNestInset(1)
24 {}
25
26
27 auto_ptr<InsetBase> MathSqrtInset::clone() const
28 {
29         return auto_ptr<InsetBase>(new MathSqrtInset(*this));
30 }
31
32
33 void MathSqrtInset::metrics(MetricsInfo & mi, Dimension & dim) const
34 {
35         cell(0).metrics(mi, dim_);
36         dim_.asc += 4;
37         dim_.des += 2;
38         dim_.wid += 12;
39         metricsMarkers(1);
40         dim = dim_;
41 }
42
43
44 void MathSqrtInset::draw(PainterInfo & pi, int x, int y) const
45 {
46         cell(0).draw(pi, x + 10, y);
47         int const a = dim_.ascent();
48         int const d = dim_.descent();
49         int xp[4];
50         int yp[4];
51         xp[0] = x + dim_.width(); yp[0] = y - a + 1;
52         xp[1] = x + 8;            yp[1] = y - a + 1;
53         xp[2] = x + 5;            yp[2] = y + d - 1;
54         xp[3] = x;                yp[3] = y + (d - a)/2;
55         pi.pain.lines(xp, yp, 4, LColor::math);
56         drawMarkers(pi, x, y);
57 }
58
59
60 void MathSqrtInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
61 {
62         cell(0).metricsT(mi, dim);
63         dim.asc += 1;
64         dim.wid += 2;
65 }
66
67
68 void MathSqrtInset::drawT(TextPainter & pain, int x, int y) const
69 {
70         cell(0).drawT(pain, x + 2, y);
71         pain.horizontalLine(x + 2, y - cell(0).ascent(), cell(0).width(), '_');
72         pain.verticalLine  (x + 1, y - cell(0).ascent() + 1, cell(0).height());
73         pain.draw(x, y + cell(0).descent(), '\\');
74 }
75
76
77 void MathSqrtInset::write(WriteStream & os) const
78 {
79         os << "\\sqrt{" << cell(0) << '}';
80 }
81
82
83 void MathSqrtInset::normalize(NormalStream & os) const
84 {
85         os << "[sqrt " << cell(0) << ']';
86 }
87
88 void MathSqrtInset::maple(MapleStream & os) const
89 {
90         os << "sqrt(" << cell(0) << ')';
91 }
92
93 void MathSqrtInset::mathematica(MathematicaStream & os) const
94 {
95         os << "Sqrt[" << cell(0) << ']';
96 }
97
98
99 void MathSqrtInset::octave(OctaveStream & os) const
100 {
101         os << "sqrt(" << cell(0) << ')';
102 }
103
104
105 void MathSqrtInset::mathmlize(MathMLStream & os) const
106 {
107         os << MTag("msqrt") << cell(0) << ETag("msqrt");
108 }