2001-10-29 15:45:24 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "math_braceinset.h"
|
|
|
|
#include "math_parser.h"
|
2001-11-08 12:15:12 +00:00
|
|
|
#include "math_support.h"
|
2001-11-08 12:06:56 +00:00
|
|
|
#include "math_mathmlstream.h"
|
2002-07-09 14:00:59 +00:00
|
|
|
#include "support/LOstream.h"
|
2001-10-29 15:45:24 +00:00
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
using std::max;
|
|
|
|
|
|
|
|
|
2001-10-29 15:45:24 +00:00
|
|
|
MathBraceInset::MathBraceInset()
|
|
|
|
: MathNestInset(1)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2002-07-11 07:56:14 +00:00
|
|
|
MathBraceInset::MathBraceInset(MathArray const & ar)
|
|
|
|
: MathNestInset(1)
|
|
|
|
{
|
|
|
|
cell(0) = ar;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-29 15:45:24 +00:00
|
|
|
MathInset * MathBraceInset::clone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2001-10-29 15:45:24 +00:00
|
|
|
return new MathBraceInset(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
void MathBraceInset::metrics(MathMetricsInfo & mi) const
|
2001-10-29 15:45:24 +00:00
|
|
|
{
|
|
|
|
xcell(0).metrics(mi);
|
2002-07-11 11:27:24 +00:00
|
|
|
Dimension t;
|
|
|
|
mathed_char_dim(mi.base.font, '{', t);
|
|
|
|
wid_ = t.w;
|
|
|
|
dim_.a = max(xcell(0).ascent(), t.a);
|
|
|
|
dim_.d = max(xcell(0).descent(), t.a);
|
|
|
|
dim_.w = xcell(0).width() + 2 * wid_;
|
2001-10-29 15:45:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
void MathBraceInset::draw(MathPainterInfo & pi, int x, int y) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2002-05-30 07:09:54 +00:00
|
|
|
LyXFont font = pi.base.font;
|
|
|
|
font.setColor(LColor::latex);
|
|
|
|
drawChar(pi, font, x, y, '{');
|
|
|
|
xcell(0).draw(pi, x + wid_, y);
|
2002-07-11 11:27:24 +00:00
|
|
|
drawChar(pi, font, x + width() - wid_, y, '}');
|
2001-10-29 15:45:24 +00:00
|
|
|
}
|
2001-11-09 08:35:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
void MathBraceInset::write(WriteStream & os) const
|
|
|
|
{
|
|
|
|
os << '{' << cell(0) << '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathBraceInset::normalize(NormalStream & os) const
|
|
|
|
{
|
|
|
|
os << "[block " << cell(0) << ']';
|
|
|
|
}
|
2002-07-09 13:38:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
void MathBraceInset::infoize(std::ostream & os) const
|
|
|
|
{
|
|
|
|
os << "Nested Block: ";
|
|
|
|
}
|