]> git.lyx.org Git - features.git/blob - src/mathed/math_binaryopinset.C
write \mathrm{x}\mathrm{y} as \mathrm{xy} again
[features.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
10
11 MathBinaryOpInset::MathBinaryOpInset(char op)
12         : MathNestInset(2), op_(op)
13 {}
14
15
16 MathInset * MathBinaryOpInset::clone() const
17 {   
18         return new MathBinaryOpInset(*this);
19 }
20
21
22 int MathBinaryOpInset::opwidth() const
23 {
24         return mathed_char_width(LM_TC_CONST, mi_, op_);
25 }
26
27
28 void MathBinaryOpInset::metrics(MathMetricsInfo const & mi) const
29 {
30         mi_ = mi;
31         xcell(0).metrics(mi);
32         xcell(1).metrics(mi);
33         width_   = xcell(0).width() + xcell(1).width() + opwidth();
34         ascent_  = std::max(xcell(0).ascent(),  xcell(1).ascent());
35         descent_ = std::max(xcell(0).descent(), xcell(1).descent());
36 }
37
38
39 void MathBinaryOpInset::draw(Painter & pain, int x, int y) const
40
41         xcell(0).draw(pain, x, y); 
42         drawChar(pain, LM_TC_CONST, mi_, x + xcell(0).width() , y, op_);
43         xcell(1).draw(pain, x + width() - xcell(1).width(), y); 
44 }
45
46
47 void MathBinaryOpInset::write(MathWriteInfo & os) const
48 {
49         os << '{' << cell(0) << op_ << cell(1) << '}';
50 }
51
52
53 void MathBinaryOpInset::writeNormal(std::ostream & os) const
54 {
55         os << "[binop " << op_ << ' ';
56         cell(0).writeNormal(os); 
57         os << " ";
58         cell(1).writeNormal(os); 
59         os << "]";
60 }