2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
|
* \file InsetMathSqrt.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 "InsetMathSqrt.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 "TextPainter.h"
|
2007-04-26 17:34:20 +00:00
|
|
|
|
#include "Color.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "frontends/Painter.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathSqrt::InsetMathSqrt()
|
|
|
|
|
: InsetMathNest(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
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
|
Inset * InsetMathSqrt::clone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
|
{
|
2007-08-30 18:03:17 +00:00
|
|
|
|
return new InsetMathSqrt(*this);
|
2001-02-13 13:28:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
|
void InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & dim) const
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2004-01-30 11:41:12 +00:00
|
|
|
|
cell(0).metrics(mi, dim);
|
|
|
|
|
dim.asc += 4;
|
|
|
|
|
dim.des += 2;
|
|
|
|
|
dim.wid += 12;
|
|
|
|
|
metricsMarkers(dim);
|
2007-09-23 22:39:49 +00:00
|
|
|
|
// Cache the inset dimension.
|
|
|
|
|
setDimCache(mi, dim);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathSqrt::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);
|
2007-09-23 22:39:49 +00:00
|
|
|
|
Dimension const dim = dimension(*pi.base.bv);
|
|
|
|
|
int const a = dim.ascent();
|
|
|
|
|
int const d = dim.descent();
|
2007-05-19 10:52:47 +00:00
|
|
|
|
int xp[3];
|
|
|
|
|
int yp[3];
|
2007-09-23 22:39:49 +00:00
|
|
|
|
pi.pain.line(x + dim.width(), y - a + 1,
|
|
|
|
|
x + 8, y - a + 1, Color::math);
|
2007-05-19 10:52:47 +00:00
|
|
|
|
xp[0] = x + 8; yp[0] = y - a + 1;
|
|
|
|
|
xp[1] = x + 5; yp[1] = y + d - 1;
|
|
|
|
|
xp[2] = x; yp[2] = y + (d - a)/2;
|
|
|
|
|
pi.pain.lines(xp, yp, 3, Color::math);
|
2002-07-30 13:56:02 +00:00
|
|
|
|
drawMarkers(pi, x, y);
|
2001-02-13 13:28:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathSqrt::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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathSqrt::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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathSqrt::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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathSqrt::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
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathSqrt::maple(MapleStream & os) const
|
2001-11-07 10:21:51 +00:00
|
|
|
|
{
|
2001-11-07 17:30:26 +00:00
|
|
|
|
os << "sqrt(" << cell(0) << ')';
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathSqrt::mathematica(MathematicaStream & os) const
|
2002-07-01 11:17:14 +00:00
|
|
|
|
{
|
|
|
|
|
os << "Sqrt[" << cell(0) << ']';
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathSqrt::octave(OctaveStream & os) const
|
2002-04-25 05:58:55 +00:00
|
|
|
|
{
|
|
|
|
|
os << "sqrt(" << cell(0) << ')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void InsetMathSqrt::mathmlize(MathStream & os) const
|
2001-11-07 17:30:26 +00:00
|
|
|
|
{
|
2001-11-09 08:35:57 +00:00
|
|
|
|
os << MTag("msqrt") << cell(0) << ETag("msqrt");
|
2001-11-07 10:21:51 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|