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