2 * \file math_binominset.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "math_binominset.h"
14 #include "math_data.h"
15 #include "math_support.h"
16 #include "math_mathmlstream.h"
23 MathBinomInset::MathBinomInset(bool choose)
28 auto_ptr<InsetBase> MathBinomInset::clone() const
30 return auto_ptr<InsetBase>(new MathBinomInset(*this));
34 int MathBinomInset::dw() const
36 int w = dim_.height() / 5;
45 void MathBinomInset::metrics(MetricsInfo & mi, Dimension & dim) const
47 ScriptChanger dummy(mi.base);
50 dim_.asc = cell(0).height() + 4 + 5;
51 dim_.des = cell(1).height() + 4 - 5;
52 dim_.wid = max(cell(0).width(), cell(1).width()) + 2 * dw() + 4;
57 void MathBinomInset::draw(PainterInfo & pi, int x, int y) const
59 int m = x + dim_.width() / 2;
60 ScriptChanger dummy(pi.base);
61 cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 3 - 5);
62 cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 3 - 5);
63 mathed_draw_deco(pi, x, y - dim_.ascent(), dw(), dim_.height(), "(");
64 mathed_draw_deco(pi, x + dim_.width() - dw(), y - dim_.ascent(),
65 dw(), dim_.height(), ")");
69 void MathBinomInset::write(WriteStream & os) const
72 os << '{' << cell(0) << " \\choose " << cell(1) << '}';
74 os << "\\binom{" << cell(0) << "}{" << cell(1) << '}';
78 void MathBinomInset::normalize(NormalStream & os) const
80 os << "[binom " << cell(0) << ' ' << cell(1) << ']';