4 #include "math_binaryopinset.h"
5 #include "MathPainterInfo.h"
6 #include "support/LOstream.h"
7 #include "math_support.h"
8 #include "math_mathmlstream.h"
14 MathBinaryOpInset::MathBinaryOpInset(char op)
15 : MathNestInset(2), op_(op)
19 MathInset * MathBinaryOpInset::clone() const
21 return new MathBinaryOpInset(*this);
25 int MathBinaryOpInset::opwidth() const
27 return mathed_char_width(LM_TC_CONST, mi_, op_);
31 void MathBinaryOpInset::metrics(MathMetricsInfo & mi) const
36 width_ = cell(0).width() + cell(1).width() + opwidth();
37 ascent_ = max(cell(0).ascent(), cell(1).ascent());
38 descent_ = max(cell(0).descent(), cell(1).descent());
42 void MathBinaryOpInset::draw(MathPainterInfo & pain, int x, int y) const
44 cell(0).draw(pain, x, y);
45 drawChar(pain, LM_TC_CONST, mi_, x + cell(0).width() , y, op_);
46 cell(1).draw(pain, x + width() - cell(1).width(), y);
50 void MathBinaryOpInset::write(WriteStream & os) const
52 os << '{' << cell(0) << op_ << cell(1) << '}';
56 void MathBinaryOpInset::normalize(NormalStream & os) const
58 os << "[binop " << op_ << ' ' << cell(0) << ' ' << cell(1) << ']';