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-16 09:01:15 +00:00
|
|
|
|
#include "LColor.h"
|
2003-09-05 17:23:11 +00:00
|
|
|
|
#include "support/std_ostream.h"
|
2005-07-17 10:31:44 +00:00
|
|
|
|
#include "frontends/Painter.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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
auto_ptr<InsetBase> MathBraceInset::doClone() 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);
|
2004-04-07 16:54:15 +00:00
|
|
|
|
dim.asc = max(cell(0).ascent(), t.asc);
|
|
|
|
|
dim.des = max(cell(0).descent(), t.des);
|
2004-04-13 06:27:29 +00:00
|
|
|
|
dim.wid = cell(0).width() + 2 * t.wid;
|
2004-04-07 16:54:15 +00:00
|
|
|
|
metricsMarkers(dim);
|
|
|
|
|
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);
|
2004-04-13 06:27:29 +00:00
|
|
|
|
Dimension t;
|
|
|
|
|
mathed_char_dim(font, '{', t);
|
2005-07-17 10:31:44 +00:00
|
|
|
|
pi.pain.text(x, y, '{', font);
|
2004-04-13 06:27:29 +00:00
|
|
|
|
cell(0).draw(pi, x + t.wid, y);
|
2005-07-17 10:31:44 +00:00
|
|
|
|
pi.pain.text(x + t.wid + cell(0).width(), y, '}', font);
|
2004-04-07 16:54:15 +00:00
|
|
|
|
drawMarkers(pi, x, 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: ";
|
|
|
|
|
}
|