]> git.lyx.org Git - lyx.git/blob - src/mathed/math_sqrtinset.C
LyX Drinkers Union: patch 1
[lyx.git] / src / mathed / math_sqrtinset.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "math_sqrtinset.h"
8 #include "LColor.h"
9 #include "Painter.h"
10 #include "support.h"
11 #include "support/LOstream.h"
12
13
14 MathSqrtInset::MathSqrtInset()
15         : MathInset("sqrt", LM_OT_SQRT, 1)
16 {}
17
18
19 MathInset * MathSqrtInset::Clone() const
20 {   
21         return new MathSqrtInset(*this);
22 }
23
24
25 void MathSqrtInset::Metrics(MathStyles st)
26 {
27         xcell(0).Metrics(st);
28         size_    = st;
29         ascent_  = xcell(0).ascent()  + 4;
30         descent_ = xcell(0).descent() + 2;
31         width_   = xcell(0).width()   + 12;
32 }
33
34
35 void MathSqrtInset::draw(Painter & pain, int x, int y)
36
37         xo(x);
38         yo(y);
39         xcell(0).draw(pain, x + 10, y); 
40         int const a = ascent_;
41         int const d = descent_;
42         int xp[4];
43         int yp[4];
44         xp[0] = x + width_; yp[0] = y - a + 1;
45         xp[1] = x + 8;      yp[1] = y - a + 1;
46         xp[2] = x + 5;      yp[2] = y + d - 1;
47         xp[3] = x;          yp[3] = y + (d - a)/2;
48         pain.lines(xp, yp, 4, LColor::mathline);
49 }
50
51
52 void MathSqrtInset::Write(std::ostream & os, bool fragile) const
53 {
54         os << '\\' << name_ << '{';
55         cell(0).Write(os, fragile); 
56         os << '}';
57 }
58
59
60 void MathSqrtInset::WriteNormal(std::ostream & os) const
61 {
62         os << "[sqrt ";
63         cell(0).WriteNormal(os); 
64         os << "] ";
65 }