2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_xarrowinset.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.
|
|
|
|
|
*/
|
|
|
|
|
|
2002-02-05 13:27:34 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "math_xarrowinset.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "math_data.h"
|
2002-02-05 13:27:34 +00:00
|
|
|
|
#include "math_mathmlstream.h"
|
|
|
|
|
#include "math_streamstr.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "math_support.h"
|
2002-02-05 13:27:34 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
|
|
|
|
|
2002-02-05 13:27:34 +00:00
|
|
|
|
|
|
|
|
|
MathXArrowInset::MathXArrowInset(string const & name)
|
2003-02-05 11:44:14 +00:00
|
|
|
|
: MathFracbaseInset(), name_(name)
|
2002-02-05 13:27:34 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
auto_ptr<InsetBase> MathXArrowInset::clone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new MathXArrowInset(*this));
|
2002-02-05 13:27:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void MathXArrowInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
2002-02-05 13:27:34 +00:00
|
|
|
|
{
|
2003-03-21 14:20:48 +00:00
|
|
|
|
ScriptChanger dummy(mi.base);
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(0).metrics(mi);
|
2003-02-05 11:44:14 +00:00
|
|
|
|
cell(1).metrics(mi);
|
2003-05-27 13:55:03 +00:00
|
|
|
|
dim_.wid = std::max(cell(0).width(), cell(1).width()) + 10;
|
|
|
|
|
dim_.asc = cell(0).height() + 10;
|
|
|
|
|
dim_.des = cell(1).height();
|
2003-06-02 10:03:27 +00:00
|
|
|
|
dim = dim_;
|
2002-02-05 13:27:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void MathXArrowInset::draw(PainterInfo & pi, int x, int y) const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2003-03-21 14:20:48 +00:00
|
|
|
|
ScriptChanger dummy(pi.base);
|
2003-02-05 11:44:14 +00:00
|
|
|
|
cell(0).draw(pi, x + 5, y - 10);
|
|
|
|
|
cell(1).draw(pi, x + 5, y + cell(1).height());
|
2003-05-28 13:22:36 +00:00
|
|
|
|
mathed_draw_deco(pi, x + 1, y - 7, pi.width - 2, 5, name_);
|
2002-02-05 13:27:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathXArrowInset::write(WriteStream & os) const
|
|
|
|
|
{
|
2003-02-05 11:44:14 +00:00
|
|
|
|
os << '\\' << name_;
|
|
|
|
|
if (cell(1).size())
|
|
|
|
|
os << '[' << cell(1) << ']';
|
|
|
|
|
os << '{' << cell(0) << '}';
|
2002-02-05 13:27:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathXArrowInset::normalize(NormalStream & os) const
|
|
|
|
|
{
|
2003-02-05 11:44:14 +00:00
|
|
|
|
os << "[xarrow " << name_ << ' ' << cell(0) << ' ' << cell(1) << ']';
|
2002-02-05 13:27:34 +00:00
|
|
|
|
}
|