2 * \file math_binaryopinset.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alejandro Aguilar Sierra
9 * Full author contact details are available in file CREDITS.
14 #include "math_binaryopinset.h"
15 #include "PainterInfo.h"
16 #include "support/LOstream.h"
17 #include "math_support.h"
18 #include "math_mathmlstream.h"
24 MathBinaryOpInset::MathBinaryOpInset(char op)
25 : MathNestInset(2), op_(op)
29 auto_ptr<InsetBase> MathBinaryOpInset::clone() const
31 return auto_ptr<InsetBase>(new MathBinaryOpInset(*this));
35 int MathBinaryOpInset::opwidth() const
37 return mathed_char_width(LM_TC_CONST, mi_, op_);
41 #warning Andre, have a look here. (Lgb)
43 // That this is not declared in class MathBinaryOpInset makes
44 // Doxygen give warnings. (Lgb)
45 void MathBinaryOpInset::metrics(MetricsInfo & mi, Dimension & dim) const
50 width_ = cell(0).width() + cell(1).width() + opwidth();
51 ascent_ = max(cell(0).ascent(), cell(1).ascent());
52 descent_ = max(cell(0).descent(), cell(1).descent());
56 void MathBinaryOpInset::draw(PainterInfo & pain, int x, int y) const
58 cell(0).draw(pain, x, y);
59 drawChar(pain, LM_TC_CONST, mi_, x + cell(0).width() , y, op_);
60 cell(1).draw(pain, x + width() - cell(1).width(), y);
64 void MathBinaryOpInset::write(WriteStream & os) const
66 os << '{' << cell(0) << op_ << cell(1) << '}';
70 void MathBinaryOpInset::normalize(NormalStream & os) const
72 os << "[binop " << op_ << ' ' << cell(0) << ' ' << cell(1) << ']';