2 * \file InsetMathBinom.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 "InsetMathBinom.h"
15 #include "MathSupport.h"
16 #include "MathStream.h"
26 InsetMathBinom::InsetMathBinom(bool choose)
31 auto_ptr<InsetBase> InsetMathBinom::doClone() const
33 return auto_ptr<InsetBase>(new InsetMathBinom(*this));
37 int InsetMathBinom::dw() const
39 int w = dim_.height() / 5;
48 bool InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const
50 ScriptChanger dummy(mi.base);
53 dim.asc = cell(0).height() + 4 + 5;
54 dim.des = cell(1).height() + 4 - 5;
55 dim.wid = max(cell(0).width(), cell(1).width()) + 2 * dw() + 4;
57 bool const changed = dim_ != dim;
63 void InsetMathBinom::draw(PainterInfo & pi, int x, int y) const
65 int m = x + dim_.width() / 2;
66 ScriptChanger dummy(pi.base);
67 cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 3 - 5);
68 cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 3 - 5);
69 mathed_draw_deco(pi, x, y - dim_.ascent(), dw(), dim_.height(), from_ascii("("));
70 mathed_draw_deco(pi, x + dim_.width() - dw(), y - dim_.ascent(),
71 dw(), dim_.height(), from_ascii(")"));
72 drawMarkers2(pi, x, y);
76 bool InsetMathBinom::extraBraces() const
82 void InsetMathBinom::write(WriteStream & os) const
85 os << '{' << cell(0) << " \\choose " << cell(1) << '}';
87 os << "\\binom{" << cell(0) << "}{" << cell(1) << '}';
91 void InsetMathBinom::normalize(NormalStream & os) const
93 os << "[binom " << cell(0) << ' ' << cell(1) << ']';