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