2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2006-09-17 09:14:18 +00:00
|
|
|
|
* \file InsetMathBrace.C
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* 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>
|
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "InsetMathBrace.h"
|
|
|
|
|
#include "MathData.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
|
#include "MathStream.h"
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "MathSupport.h"
|
2003-09-16 09:01:15 +00:00
|
|
|
|
#include "LColor.h"
|
2006-12-04 10:45:43 +00:00
|
|
|
|
|
|
|
|
|
#include "frontends/FontMetrics.h"
|
2005-07-17 10:31:44 +00:00
|
|
|
|
#include "frontends/Painter.h"
|
2001-10-29 15:45:24 +00:00
|
|
|
|
|
2006-12-04 10:45:43 +00:00
|
|
|
|
#include "support/std_ostream.h"
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathBrace::InsetMathBrace()
|
|
|
|
|
: InsetMathNest(1)
|
2001-10-29 15:45:24 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathBrace::InsetMathBrace(MathArray const & ar)
|
|
|
|
|
: InsetMathNest(1)
|
2002-07-11 07:56:14 +00:00
|
|
|
|
{
|
|
|
|
|
cell(0) = ar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
auto_ptr<InsetBase> InsetMathBrace::doClone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2006-09-16 18:11:38 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new InsetMathBrace(*this));
|
2001-10-29 15:45:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool InsetMathBrace::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);
|
2006-12-04 10:45:43 +00:00
|
|
|
|
Dimension t = theFontMetrics(mi.base.font).dimension('{');
|
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);
|
2006-11-28 15:15:49 +00:00
|
|
|
|
if (dim_ == dim)
|
|
|
|
|
return false;
|
2004-04-07 16:54:15 +00:00
|
|
|
|
dim_ = dim;
|
2006-11-28 15:15:49 +00:00
|
|
|
|
return true;
|
2001-10-29 15:45:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathBrace::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);
|
2006-12-04 10:45:43 +00:00
|
|
|
|
Dimension t = theFontMetrics(font).dimension('{');
|
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
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathBrace::write(WriteStream & os) const
|
2001-11-09 08:35:57 +00:00
|
|
|
|
{
|
|
|
|
|
os << '{' << cell(0) << '}';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathBrace::normalize(NormalStream & os) const
|
2001-11-09 08:35:57 +00:00
|
|
|
|
{
|
|
|
|
|
os << "[block " << cell(0) << ']';
|
|
|
|
|
}
|
2002-07-09 13:38:27 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathBrace::maple(MapleStream & os) const
|
2002-07-30 17:51:19 +00:00
|
|
|
|
{
|
|
|
|
|
os << cell(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathBrace::octave(OctaveStream & os) const
|
2002-07-30 17:51:19 +00:00
|
|
|
|
{
|
|
|
|
|
os << cell(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void InsetMathBrace::mathmlize(MathStream & os) const
|
2002-07-30 17:51:19 +00:00
|
|
|
|
{
|
|
|
|
|
os << MTag("mrow") << cell(0) << ETag("mrow");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathBrace::mathematica(MathematicaStream & os) const
|
2002-07-30 17:51:19 +00:00
|
|
|
|
{
|
|
|
|
|
os << cell(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void InsetMathBrace::infoize(odocstream & os) const
|
2002-07-09 13:38:27 +00:00
|
|
|
|
{
|
|
|
|
|
os << "Nested Block: ";
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|