mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 13:46:43 +00:00
ff13a3e736
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2666 a592a061-630c-0410-9148-cb99ea01b6c8
72 lines
1.4 KiB
C
72 lines
1.4 KiB
C
#ifdef __GNUG__
|
|
#pragma implementation
|
|
#endif
|
|
|
|
#include "math_binominset.h"
|
|
#include "support.h"
|
|
#include "support/LOstream.h"
|
|
|
|
|
|
MathBinomInset::MathBinomInset()
|
|
{}
|
|
|
|
|
|
MathInset * MathBinomInset::clone() const
|
|
{
|
|
return new MathBinomInset(*this);
|
|
}
|
|
|
|
|
|
int MathBinomInset::dw() const
|
|
{
|
|
int w = height()/5;
|
|
if (w > 15)
|
|
w = 15;
|
|
if (w < 6)
|
|
w = 6;
|
|
return w;
|
|
}
|
|
|
|
|
|
void MathBinomInset::metrics(MathStyles st) const
|
|
{
|
|
size_ = smallerStyleFrac(st);
|
|
xcell(0).metrics(size_);
|
|
xcell(1).metrics(size_);
|
|
ascent_ = xcell(0).height() + 4 + 5;
|
|
descent_ = xcell(1).height() + 4 - 5;
|
|
width_ = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
|
|
}
|
|
|
|
|
|
void MathBinomInset::draw(Painter & pain, int x, int y) const
|
|
{
|
|
xo(x);
|
|
yo(y);
|
|
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(), ")");
|
|
}
|
|
|
|
|
|
void MathBinomInset::write(std::ostream & os, bool fragile) const
|
|
{
|
|
os << '{';
|
|
cell(0).write(os, fragile);
|
|
os << " \\choose ";
|
|
cell(1).write(os, fragile);
|
|
os << '}';
|
|
}
|
|
|
|
|
|
void MathBinomInset::writeNormal(std::ostream & os) const
|
|
{
|
|
os << "[binom ";
|
|
cell(0).writeNormal(os);
|
|
os << " ";
|
|
cell(1).writeNormal(os);
|
|
os << "] ";
|
|
}
|