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
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* 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"
|
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"
|
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
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
|
|
|
|
|
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-04-29 13:39:47 +00:00
|
|
|
|
auto_ptr<Inset> InsetMathDots::doClone() const
|
2001-02-13 13:28:32 +00:00
|
|
|
|
{
|
2007-04-29 13:39:47 +00:00
|
|
|
|
return auto_ptr<Inset>(new InsetMathDots(*this));
|
2002-03-21 17:42:56 +00:00
|
|
|
|
}
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
|
|
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool 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
|
|
|
|
}
|
2002-07-17 10:25:33 +00:00
|
|
|
|
else if (key_->name == "ddots")
|
2004-04-08 15:20:05 +00:00
|
|
|
|
dh_ = dim.asc;
|
2006-11-28 15:15:49 +00:00
|
|
|
|
if (dim_ == dim)
|
|
|
|
|
return false;
|
2004-04-08 15:20:05 +00:00
|
|
|
|
dim_ = dim;
|
2006-11-28 15:15:49 +00:00
|
|
|
|
return true;
|
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
|
|
|
|
{
|
2003-05-28 13:22:36 +00:00
|
|
|
|
mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(),
|
|
|
|
|
key_->name);
|
2002-07-17 10:25:33 +00:00
|
|
|
|
if (key_->name == "vdots" || key_->name == "ddots")
|
2001-04-25 15:43:57 +00:00
|
|
|
|
++x;
|
2002-07-17 10:25:33 +00:00
|
|
|
|
if (key_->name != "vdots")
|
2001-04-25 15:43:57 +00:00
|
|
|
|
--y;
|
2003-05-28 13:22:36 +00:00
|
|
|
|
mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(),
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|