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
|
|
|
|
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"
|
2003-10-06 15:43:21 +00:00
|
|
|
|
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)
|
2002-07-17 10:25:33 +00:00
|
|
|
: 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
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathDots::draw(PainterInfo & pain, int x, int y) const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2007-09-23 22:39:49 +00:00
|
|
|
Dimension const dim = dimension(*pain.base.bv);
|
2009-06-18 20:04:27 +00:00
|
|
|
if (key_->name == "adots" || key_->name == "iddots")
|
|
|
|
--y;
|
2007-09-23 22:39:49 +00:00
|
|
|
mathed_draw_deco(pain, 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;
|
2007-09-23 22:39:49 +00:00
|
|
|
mathed_draw_deco(pain, x + 2, y - dh_, dim.width() - 2, dim.ascent(),
|
2003-05-28 13:22:36 +00:00
|
|
|
key_->name);
|
2004-04-08 15:20:05 +00:00
|
|
|
setPosCache(pain, x, y);
|
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())
|
|
|
|
features.require(to_utf8(key_->requires));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|