-#include <config.h>
+/**
+ * \file math_dotsinset.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alejandro Aguilar Sierra
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
#include "math_dotsinset.h"
#include "math_mathmlstream.h"
-#include "math_streamstr.h"
#include "math_support.h"
+#include "math_parser.h"
+
+
+using std::string;
+using std::auto_ptr;
-MathDotsInset::MathDotsInset(string const & name)
- : name_(name)
+MathDotsInset::MathDotsInset(latexkeys const * key)
+ : key_(key)
{}
-MathInset * MathDotsInset::clone() const
+auto_ptr<InsetBase> MathDotsInset::doClone() const
{
- return new MathDotsInset(*this);
+ return auto_ptr<InsetBase>(new MathDotsInset(*this));
}
-void MathDotsInset::metrics(MathMetricsInfo const & mi) const
+void MathDotsInset::metrics(MetricsInfo & mi, Dimension & dim) const
{
- LyXFont font;
- whichFont(font, LM_TC_VAR, mi);
- mathed_char_dim(font, 'M', ascent_, descent_, width_);
- if (name_ == "ldots" || name_ == "dotsm")
- dh_ = 0;
- else if (name_ == "cdots" || name_ == "dotsb"
- || name_ == "dotsm" || name_ == "dotsi")
- dh_ = ascent_ / 2;
- else if (name_ == "dotsc")
- dh_ = ascent_ / 4;
- else if (name_ == "vdots")
- width_ /= 2;
- else if (name_ == "ddots")
- dh_ = ascent_;
+ mathed_char_dim(mi.base.font, 'M', dim);
+ dh_ = 0;
+ if (key_->name == "cdots" || key_->name == "dotsb"
+ || key_->name == "dotsm" || key_->name == "dotsi")
+ dh_ = dim.asc / 2;
+ else if (key_->name == "dotsc")
+ dh_ = dim.asc / 4;
+ else if (key_->name == "vdots") {
+ dim.wid = (dim.wid / 2) + 1;
+ dh_ = dim.asc;
+ }
+ else if (key_->name == "ddots")
+ dh_ = dim.asc;
+ dim_ = dim;
}
-void MathDotsInset::draw(Painter & pain, int x, int y) const
+void MathDotsInset::draw(PainterInfo & pain, int x, int y) const
{
- mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, name_);
- if (name_ == "vdots" || name_ == "ddots")
+ mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(),
+ key_->name);
+ if (key_->name == "vdots" || key_->name == "ddots")
++x;
- if (name_ != "vdots")
+ if (key_->name != "vdots")
--y;
- mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, name_);
-}
-
-
-void MathDotsInset::write(WriteStream & os) const
-{
- os << '\\' << name_ << ' ';
+ mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(),
+ key_->name);
+ setPosCache(pain, x, y);
}
-void MathDotsInset::normalize(NormalStream & os) const
+string MathDotsInset::name() const
{
- os << "[" << name_ << "] ";
+ return key_->name;
}