2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_braceinset.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-10-29 15:45:24 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "math_braceinset.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "math_data.h"
|
2001-11-08 12:06:56 +00:00
|
|
|
|
#include "math_mathmlstream.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "math_support.h"
|
2003-09-05 17:23:11 +00:00
|
|
|
|
#include "support/std_ostream.h"
|
2001-10-29 15:45:24 +00:00
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
using std::max;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
auto_ptr<InsetBase> MathBraceInset::clone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new MathBraceInset(*this));
|
2001-10-29 15:45:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void MathBraceInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
2001-10-29 15:45:24 +00:00
|
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(0).metrics(mi);
|
2002-07-11 11:27:24 +00:00
|
|
|
|
Dimension t;
|
|
|
|
|
mathed_char_dim(mi.base.font, '{', t);
|
2003-05-27 13:55:03 +00:00
|
|
|
|
wid_ = t.wid;
|
|
|
|
|
dim_.asc = max(cell(0).ascent(), t.asc);
|
|
|
|
|
dim_.des = max(cell(0).descent(), t.des);
|
|
|
|
|
dim_.wid = cell(0).width() + 2 * wid_;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
dim = dim_;
|
2001-10-29 15:45:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void MathBraceInset::draw(PainterInfo & 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, '{');
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(0).draw(pi, x + wid_, y);
|
2003-05-28 13:22:36 +00:00
|
|
|
|
drawChar(pi, font, x + dim_.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
|
|
|
|
|
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathBraceInset::maple(MapleStream & os) const
|
2002-07-30 17:51:19 +00:00
|
|
|
|
{
|
|
|
|
|
os << cell(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathBraceInset::octave(OctaveStream & os) const
|
2002-07-30 17:51:19 +00:00
|
|
|
|
{
|
|
|
|
|
os << cell(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathBraceInset::mathmlize(MathMLStream & os) const
|
|
|
|
|
{
|
|
|
|
|
os << MTag("mrow") << cell(0) << ETag("mrow");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathBraceInset::mathematica(MathematicaStream & os) const
|
2002-07-30 17:51:19 +00:00
|
|
|
|
{
|
|
|
|
|
os << cell(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-09 13:38:27 +00:00
|
|
|
|
void MathBraceInset::infoize(std::ostream & os) const
|
|
|
|
|
{
|
|
|
|
|
os << "Nested Block: ";
|
|
|
|
|
}
|