2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
|
* \file InsetMathBrace.cpp
|
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"
|
2007-11-05 23:46:17 +00:00
|
|
|
|
|
2007-04-26 16:05:57 +00:00
|
|
|
|
#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"
|
2007-11-05 23:46:17 +00:00
|
|
|
|
#include "MetricsInfo.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
|
|
|
|
|
2007-11-05 23:46:17 +00:00
|
|
|
|
#include <ostream>
|
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
|
using namespace std;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathBrace::InsetMathBrace()
|
|
|
|
|
: InsetMathNest(1)
|
2001-10-29 15:45:24 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 16:05:57 +00:00
|
|
|
|
InsetMathBrace::InsetMathBrace(MathData const & ar)
|
2006-09-16 18:11:38 +00:00
|
|
|
|
: InsetMathNest(1)
|
2002-07-11 07:56:14 +00:00
|
|
|
|
{
|
|
|
|
|
cell(0) = ar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
|
Inset * InsetMathBrace::clone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2007-08-30 18:03:17 +00:00
|
|
|
|
return new InsetMathBrace(*this);
|
2001-10-29 15:45:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
|
void InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
|
2001-10-29 15:45:24 +00:00
|
|
|
|
{
|
2007-09-24 13:52:04 +00:00
|
|
|
|
Dimension dim0;
|
|
|
|
|
cell(0).metrics(mi, dim0);
|
2006-12-04 10:45:43 +00:00
|
|
|
|
Dimension t = theFontMetrics(mi.base.font).dimension('{');
|
2007-12-12 19:28:07 +00:00
|
|
|
|
dim.asc = max(dim0.asc, t.asc);
|
|
|
|
|
dim.des = max(dim0.des, t.des);
|
2007-09-24 13:52:04 +00:00
|
|
|
|
dim.wid = dim0.width() + 2 * t.wid;
|
2004-04-07 16:54:15 +00:00
|
|
|
|
metricsMarkers(dim);
|
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
|
|
|
|
{
|
2007-10-28 18:51:54 +00:00
|
|
|
|
FontInfo font = pi.base.font;
|
2007-10-25 12:41:02 +00:00
|
|
|
|
font.setColor(Color_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);
|
2007-09-24 13:52:04 +00:00
|
|
|
|
Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
|
|
|
|
|
pi.pain.text(x + t.wid + dim0.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
|