2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_sqrtinset.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-02-13 13:28:32 +00:00
|
|
|
|
#include "math_sqrtinset.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"
|
2002-03-19 16:55:58 +00:00
|
|
|
|
#include "textpainter.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "frontends/Painter.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
MathSqrtInset::MathSqrtInset()
|
2001-08-03 17:10:22 +00:00
|
|
|
|
: MathNestInset(1)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{}
|
2001-02-26 12:53:35 +00:00
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
auto_ptr<InsetBase> MathSqrtInset::clone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new MathSqrtInset(*this));
|
2001-02-13 13:28:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void MathSqrtInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2003-05-28 13:22:36 +00:00
|
|
|
|
cell(0).metrics(mi, dim_);
|
|
|
|
|
dim_.asc += 4;
|
|
|
|
|
dim_.des += 2;
|
|
|
|
|
dim_.wid += 12;
|
|
|
|
|
metricsMarkers(1);
|
2003-06-02 10:03:27 +00:00
|
|
|
|
dim = dim_;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void MathSqrtInset::draw(PainterInfo & pi, int x, int y) const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(0).draw(pi, x + 10, y);
|
2003-05-28 13:22:36 +00:00
|
|
|
|
int const a = dim_.ascent();
|
|
|
|
|
int const d = dim_.descent();
|
2001-02-16 09:25:43 +00:00
|
|
|
|
int xp[4];
|
|
|
|
|
int yp[4];
|
2003-05-28 13:22:36 +00:00
|
|
|
|
xp[0] = x + dim_.width(); yp[0] = y - a + 1;
|
|
|
|
|
xp[1] = x + 8; yp[1] = y - a + 1;
|
|
|
|
|
xp[2] = x + 5; yp[2] = y + d - 1;
|
|
|
|
|
xp[3] = x; yp[3] = y + (d - a)/2;
|
2002-07-30 13:56:02 +00:00
|
|
|
|
pi.pain.lines(xp, yp, 4, LColor::math);
|
|
|
|
|
drawMarkers(pi, x, y);
|
2001-02-13 13:28:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-28 13:22:36 +00:00
|
|
|
|
void MathSqrtInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
|
2002-03-19 16:55:58 +00:00
|
|
|
|
{
|
2003-05-28 13:22:36 +00:00
|
|
|
|
cell(0).metricsT(mi, dim);
|
|
|
|
|
dim.asc += 1;
|
|
|
|
|
dim.wid += 2;
|
2002-03-19 16:55:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-21 06:57:13 +00:00
|
|
|
|
void MathSqrtInset::drawT(TextPainter & pain, int x, int y) const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(0).drawT(pain, x + 2, y);
|
|
|
|
|
pain.horizontalLine(x + 2, y - cell(0).ascent(), cell(0).width(), '_');
|
|
|
|
|
pain.verticalLine (x + 1, y - cell(0).ascent() + 1, cell(0).height());
|
|
|
|
|
pain.draw(x, y + cell(0).descent(), '\\');
|
2002-03-19 16:55:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
|
void MathSqrtInset::write(WriteStream & os) const
|
2001-02-28 11:56:36 +00:00
|
|
|
|
{
|
2001-10-19 11:25:48 +00:00
|
|
|
|
os << "\\sqrt{" << cell(0) << '}';
|
2001-02-28 11:56:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
|
void MathSqrtInset::normalize(NormalStream & os) const
|
2001-04-25 15:43:57 +00:00
|
|
|
|
{
|
2001-11-09 08:35:57 +00:00
|
|
|
|
os << "[sqrt " << cell(0) << ']';
|
2001-04-25 15:43:57 +00:00
|
|
|
|
}
|
2001-11-07 10:21:51 +00:00
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathSqrtInset::maple(MapleStream & os) const
|
2001-11-07 10:21:51 +00:00
|
|
|
|
{
|
2001-11-07 17:30:26 +00:00
|
|
|
|
os << "sqrt(" << cell(0) << ')';
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathSqrtInset::mathematica(MathematicaStream & os) const
|
2002-07-01 11:17:14 +00:00
|
|
|
|
{
|
|
|
|
|
os << "Sqrt[" << cell(0) << ']';
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathSqrtInset::octave(OctaveStream & os) const
|
2002-04-25 05:58:55 +00:00
|
|
|
|
{
|
|
|
|
|
os << "sqrt(" << cell(0) << ')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
|
void MathSqrtInset::mathmlize(MathMLStream & os) const
|
|
|
|
|
{
|
2001-11-09 08:35:57 +00:00
|
|
|
|
os << MTag("msqrt") << cell(0) << ETag("msqrt");
|
2001-11-07 10:21:51 +00:00
|
|
|
|
}
|