2001-02-26 12:53:35 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
#include "math_sqrtinset.h"
|
2001-11-08 12:06:56 +00:00
|
|
|
#include "math_mathmlstream.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
#include "LColor.h"
|
2002-05-23 09:21:32 +00:00
|
|
|
#include "frontends/Painter.h"
|
2002-03-19 16:55:58 +00:00
|
|
|
#include "textpainter.h"
|
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
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
MathInset * MathSqrtInset::clone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2001-02-20 10:49:48 +00:00
|
|
|
return new MathSqrtInset(*this);
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
void MathSqrtInset::metrics(MetricsInfo & mi) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
cell(0).metrics(mi);
|
|
|
|
dim_.a = cell(0).ascent() + 4;
|
|
|
|
dim_.d = cell(0).descent() + 2;
|
|
|
|
dim_.w = cell(0).width() + 12;
|
2002-07-30 13:56:02 +00:00
|
|
|
metricsMarkers();
|
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);
|
2002-07-11 11:27:24 +00:00
|
|
|
int const a = ascent();
|
|
|
|
int const d = descent();
|
2001-02-16 09:25:43 +00:00
|
|
|
int xp[4];
|
|
|
|
int yp[4];
|
2002-07-11 11:27:24 +00:00
|
|
|
xp[0] = x + 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-21 06:57:13 +00:00
|
|
|
void MathSqrtInset::metricsT(TextMetricsInfo const & mi) const
|
2002-03-19 16:55:58 +00:00
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
cell(0).metricsT(mi);
|
|
|
|
dim_.a = cell(0).ascent() + 1;
|
|
|
|
dim_.d = cell(0).descent();
|
|
|
|
dim_.w = cell(0).width() + 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
|
|
|
}
|