]> git.lyx.org Git - lyx.git/blob - src/mathed/math_sqrtinset.C
first go at mathed file cleanup
[lyx.git] / src / mathed / math_sqrtinset.C
1 #include <config.h>
2
3 #include "math_sqrtinset.h"
4 #include "math_iter.h"
5 #include "LColor.h"
6 #include "Painter.h"
7 #include "support.h"
8
9
10 MathSqrtInset::MathSqrtInset(short st)
11         : MathParInset(st, "sqrt", LM_OT_SQRT) {}
12
13
14 MathedInset * MathSqrtInset::Clone()
15 {   
16         MathSqrtInset * p = new MathSqrtInset(GetStyle());
17         MathedIter it(array);
18         p->SetData(it.Copy());
19         return p;
20 }
21
22
23 bool MathSqrtInset::Inside(int x, int y) 
24 {
25         return x >= xo - hmax
26                 && x <= xo + width - hmax
27                 && y <= yo + descent
28                 && y >= yo - ascent;
29 }
30
31
32 void
33 MathSqrtInset::draw(Painter & pain, int x, int y)
34
35         MathParInset::draw(pain, x + hmax + 2, y); 
36         int h = ascent;
37         int d = descent;
38         int h2 = Height() / 2;
39         int w2 = (Height() > 4 * hmax) ? hmax : hmax / 2; 
40         int xp[4], yp[4];
41         xp[0] = x + hmax + wbody; yp[0] = y - h;
42         xp[1] = x + hmax;         yp[1] = y - h;
43         xp[2] = x + w2;           yp[2] = y + d;
44         xp[3] = x;                yp[3] = y + d - h2;
45         pain.lines(xp, yp, 4, LColor::mathline);
46 }
47
48
49 void
50 MathSqrtInset::Metrics()
51 {
52         MathParInset::Metrics();
53         ascent += 4;
54         descent += 2;
55         int a, b;
56         hmax = mathed_char_height(LM_TC_VAR, size, 'I', a, b);
57         if (hmax < 10) hmax = 10;
58         wbody = width + 4;
59         width += hmax + 4;
60 }
61
62
63 void MathSqrtInset::Write(ostream & os, bool fragile)
64 {
65         os << '\\' << name << '{';
66         MathParInset::Write(os, fragile); 
67         os << '}';
68 }