]> git.lyx.org Git - lyx.git/blob - src/mathed/math_sqrtinset.C
enable direct input of #1...#9; some whitespace changes
[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 "Painter.h"
9
10
11 MathSqrtInset::MathSqrtInset()
12         : MathNestInset(1)
13 {}
14
15
16 MathInset * MathSqrtInset::clone() const
17 {   
18         return new MathSqrtInset(*this);
19 }
20
21
22 void MathSqrtInset::metrics(MathMetricsInfo const & mi) const
23 {
24         xcell(0).metrics(mi);
25         ascent_  = xcell(0).ascent()  + 4;
26         descent_ = xcell(0).descent() + 2;
27         width_   = xcell(0).width()   + 12;
28 }
29
30
31 void MathSqrtInset::draw(Painter & pain, int x, int y) const
32
33         xcell(0).draw(pain, x + 10, y); 
34         int const a = ascent_;
35         int const d = descent_;
36         int xp[4];
37         int yp[4];
38         xp[0] = x + 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         pain.lines(xp, yp, 4, LColor::math);
43 }
44
45
46 void MathSqrtInset::write(WriteStream & os) const
47 {
48         os << "\\sqrt{" << cell(0) << '}';
49 }
50
51
52 void MathSqrtInset::normalize(NormalStream & os) const
53 {
54         os << "[sqrt " << cell(0) << ']';
55 }
56
57
58 void MathSqrtInset::maplize(MapleStream & os) const
59 {
60         os << "sqrt(" << cell(0) << ')';
61 }
62
63
64 void MathSqrtInset::mathmlize(MathMLStream & os) const
65 {
66         os << MTag("msqrt") << cell(0) << ETag("msqrt");
67 }