]> git.lyx.org Git - lyx.git/blob - src/mathed/math_sqrtinset.C
everything is an inset. sizeof(MathInset) == 36 on IA32
[lyx.git] / src / mathed / math_sqrtinset.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include "math_sqrtinset.h"
6 #include "LColor.h"
7 #include "Painter.h"
8 #include "support/LOstream.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(MathStyles st)
23 {
24         xcell(0).metrics(st);
25         size_    = st;
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(Painter & pain, int x, int y)
33
34         xo(x);
35         yo(y);
36         xcell(0).draw(pain, x + 10, y); 
37         int const a = ascent_;
38         int const d = descent_;
39         int xp[4];
40         int yp[4];
41         xp[0] = x + width_; yp[0] = y - a + 1;
42         xp[1] = x + 8;      yp[1] = y - a + 1;
43         xp[2] = x + 5;      yp[2] = y + d - 1;
44         xp[3] = x;          yp[3] = y + (d - a)/2;
45         pain.lines(xp, yp, 4, LColor::mathline);
46 }
47
48
49 void MathSqrtInset::write(std::ostream & os, bool fragile) const
50 {
51         os << "\\sqrt{";
52         cell(0).write(os, fragile); 
53         os << '}';
54 }
55
56
57 void MathSqrtInset::writeNormal(std::ostream & os) const
58 {
59         os << "[sqrt ";
60         cell(0).writeNormal(os); 
61         os << "] ";
62 }