2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
|
* \file InsetMathStackrel.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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "InsetMathStackrel.h"
|
2007-04-25 16:11:45 +00:00
|
|
|
|
#include "MathArray.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
|
#include "MathStream.h"
|
2001-08-08 17:26:30 +00:00
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
InsetMathStackrel::InsetMathStackrel()
|
2001-08-08 17:26:30 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
auto_ptr<InsetBase> InsetMathStackrel::doClone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2006-09-16 18:11:38 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new InsetMathStackrel(*this));
|
2001-08-08 17:26:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool InsetMathStackrel::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);
|
2006-11-28 15:15:49 +00:00
|
|
|
|
if (dim_ == dim)
|
|
|
|
|
return false;
|
2004-01-30 11:41:12 +00:00
|
|
|
|
dim_ = dim;
|
2006-11-28 15:15:49 +00:00
|
|
|
|
return true;
|
2001-08-08 17:26:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathStackrel::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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathStackrel::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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathStackrel::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
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|