5 #include "math_binaryopinset.h"
7 #include "support/LOstream.h"
11 MathBinaryOpInset::MathBinaryOpInset(char op)
12 : MathNestInset(2), op_(op)
16 MathInset * MathBinaryOpInset::clone() const
18 return new MathBinaryOpInset(*this);
22 int MathBinaryOpInset::opwidth() const
24 return mathed_char_width(LM_TC_CONST, mi_, op_);
28 void MathBinaryOpInset::metrics(MathMetricsInfo const & mi) const
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());
39 void MathBinaryOpInset::draw(Painter & pain, int x, int y) const
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);
47 void MathBinaryOpInset::write(MathWriteInfo & os) const
49 os << '{' << cell(0) << op_ << cell(1) << '}';
53 void MathBinaryOpInset::writeNormal(std::ostream & os) const
55 os << "[binop " << op_ << ' ';
56 cell(0).writeNormal(os);
58 cell(1).writeNormal(os);