5 #include "math_binaryopinset.h"
7 #include "support/LOstream.h"
8 #include "math_support.h"
9 #include "math_mathmlstream.h"
12 MathBinaryOpInset::MathBinaryOpInset(char op)
13 : MathNestInset(2), op_(op)
17 MathInset * MathBinaryOpInset::clone() const
19 return new MathBinaryOpInset(*this);
23 int MathBinaryOpInset::opwidth() const
25 return mathed_char_width(LM_TC_CONST, mi_, op_);
29 void MathBinaryOpInset::metrics(MathMetricsInfo const & mi) const
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());
40 void MathBinaryOpInset::draw(Painter & pain, int x, int y) const
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);
48 void MathBinaryOpInset::write(WriteStream & os) const
50 os << '{' << cell(0) << op_ << cell(1) << '}';
54 void MathBinaryOpInset::normalize(NormalStream & os) const
56 os << "[binop " << op_ << ' ' << cell(0) << ' ' << cell(1) << ']';