#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "math_binominset.h"
#include "math_support.h"
#include "support/LOstream.h"
#include "math_mathmlstream.h"
-MathBinomInset::MathBinomInset()
+using std::max;
+using std::auto_ptr;
+
+
+MathBinomInset::MathBinomInset(bool choose)
+ : choose_(choose)
{}
-MathInset * MathBinomInset::clone() const
-{
- return new MathBinomInset(*this);
+auto_ptr<InsetBase> MathBinomInset::clone() const
+{
+ return auto_ptr<InsetBase>(new MathBinomInset(*this));
}
int MathBinomInset::dw() const
{
- int w = height()/5;
+ int w = dim_.height() / 5;
if (w > 15)
w = 15;
if (w < 6)
}
-void MathBinomInset::metrics(MathMetricsInfo const & st) const
+void MathBinomInset::metrics(MetricsInfo & mi, Dimension & dim) const
{
- MathMetricsInfo mi = st;
- smallerStyleFrac(mi);
- xcell(0).metrics(mi);
- xcell(1).metrics(mi);
- ascent_ = xcell(0).height() + 4 + 5;
- descent_ = xcell(1).height() + 4 - 5;
- width_ = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
+ ScriptChanger dummy(mi.base);
+ cell(0).metrics(mi);
+ cell(1).metrics(mi);
+ dim_.asc = cell(0).height() + 4 + 5;
+ dim_.des = cell(1).height() + 4 - 5;
+ dim_.wid = max(cell(0).width(), cell(1).width()) + 2 * dw() + 4;
+ dim = dim_;
}
-void MathBinomInset::draw(Painter & pain, int x, int y) const
+void MathBinomInset::draw(PainterInfo & pi, int x, int y) const
{
- int m = x + width() / 2;
- xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
- xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent() + 3 - 5);
- mathed_draw_deco(pain, x, y - ascent_, dw(), height(), "(");
- mathed_draw_deco(pain, x + width() - dw(), y - ascent_, dw(), height(), ")");
+ int m = x + dim_.width() / 2;
+ ScriptChanger dummy(pi.base);
+ cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 3 - 5);
+ cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 3 - 5);
+ mathed_draw_deco(pi, x, y - dim_.ascent(), dw(), dim_.height(), "(");
+ mathed_draw_deco(pi, x + dim_.width() - dw(), y - dim_.ascent(),
+ dw(), dim_.height(), ")");
}
void MathBinomInset::write(WriteStream & os) const
{
- os << '{' << cell(0) << " \\choose " << cell(1) << '}';
+ if (choose_)
+ os << '{' << cell(0) << " \\choose " << cell(1) << '}';
+ else
+ os << "\\binom{" << cell(0) << "}{" << cell(1) << '}';
}