7 #include "math_binominset.h"
8 #include "math_support.h"
9 #include "support/LOstream.h"
10 #include "math_mathmlstream.h"
16 MathBinomInset::MathBinomInset(bool choose)
21 MathInset * MathBinomInset::clone() const
23 return new MathBinomInset(*this);
27 int MathBinomInset::dw() const
38 void MathBinomInset::metrics(MathMetricsInfo & mi) const
40 MathScriptChanger(mi.base);
43 ascent_ = xcell(0).height() + 4 + 5;
44 descent_ = xcell(1).height() + 4 - 5;
45 width_ = max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
49 void MathBinomInset::draw(MathPainterInfo & pi, int x, int y) const
51 int m = x + width() / 2;
52 MathScriptChanger(pi.base);
53 xcell(0).draw(pi, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
54 xcell(1).draw(pi, m - xcell(1).width() / 2, y + xcell(1).ascent() + 3 - 5);
55 mathed_draw_deco(pi, x, y - ascent_, dw(), height(), "(");
56 mathed_draw_deco(pi, x + width() - dw(), y - ascent_, dw(), height(), ")");
60 void MathBinomInset::write(WriteStream & os) const
63 os << '{' << cell(0) << " \\choose " << cell(1) << '}';
65 os << "\\binom{" << cell(0) << "}{" << cell(1) << '}';
69 void MathBinomInset::normalize(NormalStream & os) const
71 os << "[binom " << cell(0) << ' ' << cell(1) << ']';