]> git.lyx.org Git - lyx.git/blob - src/mathed/math_sqrtinset.C
small cleanup, doxygen, formatting changes
[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 const h = ascent;
39         int const d = descent;
40         int const h2 = Height() / 2;
41         int const w2 = (Height() > 4 * hmax_) ? hmax_ : hmax_ / 2; 
42         int xp[4];
43         int yp[4];
44         xp[0] = x + hmax_ + wbody_; yp[0] = y - h;
45         xp[1] = x + hmax_;          yp[1] = y - h;
46         xp[2] = x + w2;             yp[2] = y + d;
47         xp[3] = x;                  yp[3] = y + d - h2;
48         pain.lines(xp, yp, 4, LColor::mathline);
49 }
50
51
52 void
53 MathSqrtInset::Metrics()
54 {
55         MathParInset::Metrics();
56         ascent += 4;
57         descent += 2;
58         int a;
59         int b;
60         hmax_ = mathed_char_height(LM_TC_VAR, size(), 'I', a, b);
61         if (hmax_ < 10) hmax_ = 10;
62         wbody_ = width + 4;
63         width += hmax_ + 4;
64 }
65
66
67 void MathSqrtInset::Write(ostream & os, bool fragile)
68 {
69         os << '\\' << name << '{';
70         MathParInset::Write(os, fragile); 
71         os << '}';
72 }