2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_stackrelinset.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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2001-08-08 17:26:30 +00:00
|
|
|
|
#include "math_stackrelinset.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"
|
2001-08-08 17:26:30 +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-08-08 17:26:30 +00:00
|
|
|
|
MathStackrelInset::MathStackrelInset()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
auto_ptr<InsetBase> MathStackrelInset::doClone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new MathStackrelInset(*this));
|
2001-08-08 17:26:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void MathStackrelInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
2001-08-08 17:26:30 +00:00
|
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(1).metrics(mi);
|
2003-03-21 14:20:48 +00:00
|
|
|
|
FracChanger dummy(mi.base);
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(0).metrics(mi);
|
2004-01-30 11:41:12 +00:00
|
|
|
|
dim.wid = max(cell(0).width(), cell(1).width()) + 4;
|
|
|
|
|
dim.asc = cell(1).ascent() + cell(0).height() + 4;
|
|
|
|
|
dim.des = cell(1).descent();
|
|
|
|
|
metricsMarkers(dim);
|
|
|
|
|
dim_ = dim;
|
2001-08-08 17:26:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void MathStackrelInset::draw(PainterInfo & pi, int x, int y) const
|
2001-08-08 17:26:30 +00:00
|
|
|
|
{
|
2003-05-28 13:22:36 +00:00
|
|
|
|
int m = x + dim_.width() / 2;
|
2002-08-02 14:29:42 +00:00
|
|
|
|
int yo = y - cell(1).ascent() - cell(0).descent() - 1;
|
|
|
|
|
cell(1).draw(pi, m - cell(1).width() / 2, y);
|
2003-03-21 14:20:48 +00:00
|
|
|
|
FracChanger dummy(pi.base);
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(0).draw(pi, m - cell(0).width() / 2, yo);
|
2003-07-25 17:11:25 +00:00
|
|
|
|
drawMarkers(pi, x, y);
|
2001-08-08 17:26:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
|
void MathStackrelInset::write(WriteStream & os) const
|
2001-08-08 17:26:30 +00:00
|
|
|
|
{
|
2001-10-19 11:25:48 +00:00
|
|
|
|
os << "\\stackrel{" << cell(0) << "}{" << cell(1) << '}';
|
2001-08-08 17:26:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
|
void MathStackrelInset::normalize(NormalStream & os) const
|
2001-08-08 17:26:30 +00:00
|
|
|
|
{
|
2001-11-09 08:35:57 +00:00
|
|
|
|
os << "[stackrel " << cell(0) << ' ' << cell(1) << ']';
|
2001-08-08 17:26:30 +00:00
|
|
|
|
}
|