2003-08-19 13:00:56 +00:00
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
* \file InsetMathDots.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 Alejandro Aguilar Sierra
|
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.
|
|
|
|
*/
|
|
|
|
|
2001-12-05 08:04:20 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "InsetMathDots.h"
|
2007-11-05 23:46:17 +00:00
|
|
|
|
2016-09-30 14:50:09 +00:00
|
|
|
#include "Dimension.h"
|
2008-10-18 14:15:56 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
#include "MathStream.h"
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "MathSupport.h"
|
|
|
|
#include "MathParser.h"
|
2007-11-05 23:46:17 +00:00
|
|
|
#include "MetricsInfo.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2006-12-04 10:45:43 +00:00
|
|
|
#include "frontends/FontMetrics.h"
|
2009-12-25 21:42:07 +00:00
|
|
|
#include "support/lassert.h"
|
2003-07-25 17:11:25 +00:00
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
namespace lyx {
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathDots::InsetMathDots(latexkeys const * key)
|
2015-10-10 19:04:28 +00:00
|
|
|
: dh_(0), key_(key)
|
2001-06-25 00:06:33 +00:00
|
|
|
{}
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
Inset * InsetMathDots::clone() const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2007-08-30 18:03:17 +00:00
|
|
|
return new InsetMathDots(*this);
|
2002-03-21 17:42:56 +00:00
|
|
|
}
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
void InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const
|
2002-03-19 16:55:58 +00:00
|
|
|
{
|
2006-12-04 10:45:43 +00:00
|
|
|
dim = theFontMetrics(mi.base.font).dimension('M');
|
2002-12-09 09:52:43 +00:00
|
|
|
dh_ = 0;
|
|
|
|
if (key_->name == "cdots" || key_->name == "dotsb"
|
2002-07-17 10:25:33 +00:00
|
|
|
|| key_->name == "dotsm" || key_->name == "dotsi")
|
2004-04-08 15:20:05 +00:00
|
|
|
dh_ = dim.asc / 2;
|
2002-07-17 10:25:33 +00:00
|
|
|
else if (key_->name == "dotsc")
|
2004-04-08 15:20:05 +00:00
|
|
|
dh_ = dim.asc / 4;
|
2002-11-25 10:15:13 +00:00
|
|
|
else if (key_->name == "vdots") {
|
2004-04-08 15:20:05 +00:00
|
|
|
dim.wid = (dim.wid / 2) + 1;
|
|
|
|
dh_ = dim.asc;
|
2002-11-25 10:15:13 +00:00
|
|
|
}
|
2009-06-18 20:04:27 +00:00
|
|
|
else if (key_->name == "ddots" || key_->name == "adots" || key_->name == "iddots")
|
2004-04-08 15:20:05 +00:00
|
|
|
dh_ = dim.asc;
|
2002-03-21 17:42:56 +00:00
|
|
|
}
|
2002-03-19 16:55:58 +00:00
|
|
|
|
|
|
|
|
2016-08-16 12:29:58 +00:00
|
|
|
void InsetMathDots::draw(PainterInfo & pi, int x, int y) const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2016-08-16 12:29:58 +00:00
|
|
|
Dimension const dim = dimension(*pi.base.bv);
|
2009-06-18 20:04:27 +00:00
|
|
|
if (key_->name == "adots" || key_->name == "iddots")
|
|
|
|
--y;
|
2016-08-16 12:29:58 +00:00
|
|
|
mathed_draw_deco(pi, x + 2, y - dh_, dim.width() - 2, dim.ascent(),
|
2009-06-18 20:04:27 +00:00
|
|
|
key_->name);
|
|
|
|
if (key_->name == "vdots" || key_->name == "ddots" || key_->name == "adots" || key_->name == "iddots")
|
2001-04-25 15:43:57 +00:00
|
|
|
++x;
|
2009-06-18 20:04:27 +00:00
|
|
|
if (key_->name == "adots" || key_->name == "iddots")
|
|
|
|
++y;
|
|
|
|
else if (key_->name != "vdots")
|
2001-04-25 15:43:57 +00:00
|
|
|
--y;
|
2016-08-16 12:29:58 +00:00
|
|
|
mathed_draw_deco(pi, x + 2, y - dh_, dim.width() - 2, dim.ascent(),
|
2003-05-28 13:22:36 +00:00
|
|
|
key_->name);
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
docstring InsetMathDots::name() const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2002-08-05 07:09:11 +00:00
|
|
|
return key_->name;
|
2001-04-25 15:43:57 +00:00
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
2008-10-18 14:15:56 +00:00
|
|
|
void InsetMathDots::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
|
|
|
if (!key_->requires.empty())
|
2014-12-29 20:46:30 +00:00
|
|
|
features.require(key_->requires);
|
2008-10-18 14:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-31 15:46:39 +00:00
|
|
|
void InsetMathDots::mathmlize(MathStream & os) const
|
2009-12-16 17:12:58 +00:00
|
|
|
{
|
2009-12-25 21:42:07 +00:00
|
|
|
// which symbols we support is decided by what is listed in
|
|
|
|
// lib/symbols as generating a dots inset
|
|
|
|
docstring const & n = key_->name;
|
|
|
|
std::string ent;
|
|
|
|
if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots")
|
|
|
|
ent = "…";
|
2010-03-30 22:14:00 +00:00
|
|
|
else if (n == "adots" || n == "iddots")
|
2009-12-25 21:42:07 +00:00
|
|
|
ent = "⋰";
|
|
|
|
else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm")
|
|
|
|
ent = "⋯";
|
|
|
|
else if (n == "ddots")
|
|
|
|
ent = "⋱";
|
|
|
|
else if (n == "vdots")
|
|
|
|
ent = "⋮";
|
|
|
|
else
|
|
|
|
LASSERT(false, ent = "…");
|
2009-12-25 23:18:38 +00:00
|
|
|
os << MTag("mi") << from_ascii(ent) << ETag("mi");
|
2009-12-16 17:12:58 +00:00
|
|
|
}
|
|
|
|
|
2010-03-30 22:14:00 +00:00
|
|
|
|
|
|
|
void InsetMathDots::htmlize(HtmlStream & os) const
|
|
|
|
{
|
|
|
|
// which symbols we support is decided by what is listed in
|
|
|
|
// lib/symbols as generating a dots inset
|
|
|
|
docstring const & n = key_->name;
|
|
|
|
std::string ent;
|
|
|
|
if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots")
|
|
|
|
ent = "…";
|
|
|
|
else if (n == "adots" || n == "iddots")
|
|
|
|
ent = "⋰";
|
|
|
|
else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm")
|
|
|
|
ent = "⋯";
|
|
|
|
else if (n == "ddots")
|
|
|
|
ent = "⋱";
|
|
|
|
else if (n == "vdots")
|
|
|
|
ent = "⋮";
|
|
|
|
else
|
|
|
|
LASSERT(false, ent = "#x02026;");
|
|
|
|
os << from_ascii(ent);
|
|
|
|
}
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|