2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
|
* \file InsetMathXArrow.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.
|
|
|
|
|
*/
|
|
|
|
|
|
2002-02-05 13:27:34 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "InsetMathXArrow.h"
|
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 "MathStream.h"
|
|
|
|
|
#include "MathSupport.h"
|
2002-02-05 13:27:34 +00:00
|
|
|
|
|
2006-04-13 10:31:32 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
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
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
InsetMathXArrow::InsetMathXArrow(docstring const & name)
|
2006-09-16 18:11:38 +00:00
|
|
|
|
: InsetMathFracBase(), name_(name)
|
2002-02-05 13:27:34 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
auto_ptr<Inset> InsetMathXArrow::doClone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2007-04-29 13:39:47 +00:00
|
|
|
|
return auto_ptr<Inset>(new InsetMathXArrow(*this));
|
2002-02-05 13:27:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool InsetMathXArrow::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);
|
2004-04-08 15:59:34 +00:00
|
|
|
|
dim.wid = std::max(cell(0).width(), cell(1).width()) + 10;
|
|
|
|
|
dim.asc = cell(0).height() + 10;
|
|
|
|
|
dim.des = cell(1).height();
|
|
|
|
|
metricsMarkers(dim);
|
2006-11-28 15:15:49 +00:00
|
|
|
|
if (dim_ == dim)
|
|
|
|
|
return false;
|
2004-04-08 15:59:34 +00:00
|
|
|
|
dim_ = dim;
|
2006-11-28 15:15:49 +00:00
|
|
|
|
return true;
|
2002-02-05 13:27:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathXArrow::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());
|
2004-04-08 15:59:34 +00:00
|
|
|
|
mathed_draw_deco(pi, x + 1, y - 7, width() - 2, 5, name_);
|
|
|
|
|
drawMarkers(pi, x, y);
|
2002-02-05 13:27:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathXArrow::write(WriteStream & os) const
|
2002-02-05 13:27:34 +00:00
|
|
|
|
{
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathXArrow::normalize(NormalStream & os) const
|
2002-02-05 13:27:34 +00:00
|
|
|
|
{
|
2003-02-05 11:44:14 +00:00
|
|
|
|
os << "[xarrow " << name_ << ' ' << cell(0) << ' ' << cell(1) << ']';
|
2002-02-05 13:27:34 +00:00
|
|
|
|
}
|
2006-04-13 10:31:32 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathXArrow::validate(LaTeXFeatures & features) const
|
2006-04-13 10:31:32 +00:00
|
|
|
|
{
|
|
|
|
|
features.require("amsmath");
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathNest::validate(features);
|
2006-04-13 10:31:32 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|