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 "metricsinfo.h"
16 #include "support/std_ostream.h"
17 #include "math_support.h"
18 #include "math_mathmlstream.h"
24 MathBinaryOpInset::MathBinaryOpInset(char op)
25 : MathNestInset(2), op_(op)
29 std::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_);
42 #warning Andre, have a look here. (Lgb)
45 // That this is not declared in class MathBinaryOpInset makes
46 // Doxygen give warnings. (Lgb)
47 void MathBinaryOpInset::metrics(MetricsInfo & mi, Dimension & dim) const
52 width_ = cell(0).width() + cell(1).width() + opwidth();
53 ascent_ = max(cell(0).ascent(), cell(1).ascent());
54 descent_ = max(cell(0).descent(), cell(1).descent());
59 void MathBinaryOpInset::draw(PainterInfo & pain, int x, int y) const
61 cell(0).draw(pain, x, y);
62 drawChar(pain, LM_TC_CONST, mi_, x + cell(0).width() , y, op_);
63 cell(1).draw(pain, x + width() - cell(1).width(), y);
67 void MathBinaryOpInset::write(WriteStream & os) const
69 os << '{' << cell(0) << op_ << cell(1) << '}';
73 void MathBinaryOpInset::normalize(NormalStream & os) const
75 os << "[binop " << op_ << ' ' << cell(0) << ' ' << cell(1) << ']';