]> git.lyx.org Git - lyx.git/blob - src/mathed/math_binaryopinset.C
don't #include too much stuff in .h
[lyx.git] / src / mathed / math_binaryopinset.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include "math_binaryopinset.h"
6 #include "Painter.h"
7 #include "support/LOstream.h"
8 #include "support.h"
9 #include "math_mathmlstream.h"
10
11
12 MathBinaryOpInset::MathBinaryOpInset(char op)
13         : MathNestInset(2), op_(op)
14 {}
15
16
17 MathInset * MathBinaryOpInset::clone() const
18 {   
19         return new MathBinaryOpInset(*this);
20 }
21
22
23 int MathBinaryOpInset::opwidth() const
24 {
25         return mathed_char_width(LM_TC_CONST, mi_, op_);
26 }
27
28
29 void MathBinaryOpInset::metrics(MathMetricsInfo const & mi) const
30 {
31         mi_ = mi;
32         xcell(0).metrics(mi);
33         xcell(1).metrics(mi);
34         width_   = xcell(0).width() + xcell(1).width() + opwidth();
35         ascent_  = std::max(xcell(0).ascent(),  xcell(1).ascent());
36         descent_ = std::max(xcell(0).descent(), xcell(1).descent());
37 }
38
39
40 void MathBinaryOpInset::draw(Painter & pain, int x, int y) const
41
42         xcell(0).draw(pain, x, y); 
43         drawChar(pain, LM_TC_CONST, mi_, x + xcell(0).width() , y, op_);
44         xcell(1).draw(pain, x + width() - xcell(1).width(), y); 
45 }
46
47
48 void MathBinaryOpInset::write(MathWriteInfo & os) const
49 {
50         os << '{' << cell(0) << op_ << cell(1) << '}';
51 }
52
53
54 void MathBinaryOpInset::writeNormal(NormalStream & os) const
55 {
56         os << "[binop " << op_ << ' ' << cell(0) << ' ' << cell(1) << ']';
57 }