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.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-08-19 13:00:56 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "InsetMathSqrt.h"
|
2010-03-31 20:31:04 +00:00
|
|
|
|
2017-12-04 09:44:49 +00:00
|
|
|
#include "InsetMathRoot.h"
|
2007-04-26 16:05:57 +00:00
|
|
|
#include "MathData.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
#include "MathStream.h"
|
2017-03-31 16:50:14 +00:00
|
|
|
#include "MathSupport.h"
|
2016-06-04 08:41:13 +00:00
|
|
|
|
|
|
|
#include "LaTeXFeatures.h"
|
|
|
|
#include "MetricsInfo.h"
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "TextPainter.h"
|
2016-06-04 08:41:13 +00:00
|
|
|
|
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 {
|
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathSqrt::InsetMathSqrt(Buffer * buf)
|
|
|
|
: InsetMathNest(buf, 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
|
|
|
{
|
2017-12-04 09:44:49 +00:00
|
|
|
mathed_root_metrics(mi, cell(0), nullptr, 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
|
|
|
{
|
2017-12-04 09:44:49 +00:00
|
|
|
mathed_draw_root(pi, x, y, cell(0), nullptr, dimension(*pi.base.bv));
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-03 11:00:18 +00:00
|
|
|
void InsetMathSqrt::drawT(TextPainter & /*pain*/, int /*x*/, int /*y*/) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2007-09-24 13:52:04 +00:00
|
|
|
/*
|
2002-08-02 14:29:42 +00:00
|
|
|
cell(0).drawT(pain, x + 2, y);
|
2007-09-24 13:52:04 +00:00
|
|
|
Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
|
|
|
|
pain.horizontalLine(x + 2, y - dim0.ascent(), dim0.width(), '_');
|
|
|
|
pain.verticalLine (x + 1, y - dim0.ascent() + 1, dim0.height());
|
|
|
|
pain.draw(x, y + dim0.descent(), '\\');
|
|
|
|
*/
|
2002-03-19 16:55:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-26 19:04:36 +00:00
|
|
|
void InsetMathSqrt::write(TeXMathStream & os) const
|
2001-02-28 11:56:36 +00:00
|
|
|
{
|
2008-06-17 11:10:43 +00:00
|
|
|
MathEnsurer ensurer(os);
|
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) << ')';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-26 19:02:46 +00:00
|
|
|
void InsetMathSqrt::mathmlize(MathMLStream & ms) const
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2019-05-09 23:52:07 +00:00
|
|
|
ms << MTag("msqrt") << cell(0) << ETag("msqrt");
|
2001-11-07 10:21:51 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
2010-03-31 20:31:04 +00:00
|
|
|
void InsetMathSqrt::htmlize(HtmlStream & os) const
|
|
|
|
{
|
|
|
|
os << MTag("span", "class='sqrt'")
|
2022-12-23 01:16:08 +00:00
|
|
|
<< from_ascii("√")
|
2017-07-03 17:53:14 +00:00
|
|
|
<< MTag("span", "class='sqrtof'") << cell(0) << ETag("span")
|
2010-03-31 20:31:04 +00:00
|
|
|
<< ETag("span");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathSqrt::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
|
|
|
if (features.runparams().math_flavor == OutputParams::MathAsHTML)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet("span.sqrtof{border-top: thin solid black;}");
|
2010-03-31 21:24:16 +00:00
|
|
|
InsetMathNest::validate(features);
|
2010-03-31 20:31:04 +00:00
|
|
|
}
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|