4 #include "math_binominset.h"
5 #include "math_support.h"
6 #include "support/LOstream.h"
7 #include "math_mathmlstream.h"
13 MathBinomInset::MathBinomInset(bool choose)
18 MathInset * MathBinomInset::clone() const
20 return new MathBinomInset(*this);
24 int MathBinomInset::dw() const
35 void MathBinomInset::metrics(MetricsInfo & mi) const
37 ScriptChanger dummy(mi.base);
40 dim_.a = cell(0).height() + 4 + 5;
41 dim_.d = cell(1).height() + 4 - 5;
42 dim_.w = max(cell(0).width(), cell(1).width()) + 2 * dw() + 4;
46 void MathBinomInset::draw(PainterInfo & pi, int x, int y) const
48 int m = x + width() / 2;
49 ScriptChanger dummy(pi.base);
50 cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 3 - 5);
51 cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 3 - 5);
52 mathed_draw_deco(pi, x, y - ascent(), dw(), height(), "(");
53 mathed_draw_deco(pi, x + width() - dw(), y - ascent(), dw(), height(), ")");
57 void MathBinomInset::write(WriteStream & os) const
60 os << '{' << cell(0) << " \\choose " << cell(1) << '}';
62 os << "\\binom{" << cell(0) << "}{" << cell(1) << '}';
66 void MathBinomInset::normalize(NormalStream & os) const
68 os << "[binom " << cell(0) << ' ' << cell(1) << ']';