2 * \file InsetMathDots.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alejandro Aguilar Sierra
9 * Full author contact details are available in file CREDITS.
14 #include "InsetMathDots.h"
16 #include "Dimension.h"
17 #include "LaTeXFeatures.h"
18 #include "MathStream.h"
19 #include "MathSupport.h"
20 #include "MathParser.h"
21 #include "MetricsInfo.h"
23 #include "frontends/FontMetrics.h"
24 #include "support/lassert.h"
28 InsetMathDots::InsetMathDots(latexkeys const * key)
33 Inset * InsetMathDots::clone() const
35 return new InsetMathDots(*this);
39 void InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const
41 dim = theFontMetrics(mi.base.font).dimension('M');
43 if (key_->name == "cdots" || key_->name == "dotsb"
44 || key_->name == "dotsm" || key_->name == "dotsi")
46 else if (key_->name == "dotsc")
48 else if (key_->name == "vdots") {
49 dim.wid = (dim.wid / 2) + 1;
52 else if (key_->name == "ddots" || key_->name == "adots" || key_->name == "iddots")
57 void InsetMathDots::draw(PainterInfo & pi, int x, int y) const
59 Dimension const dim = dimension(*pi.base.bv);
60 if (key_->name == "adots" || key_->name == "iddots")
62 mathed_draw_deco(pi, x + 2, y - dh_, dim.width() - 2, dim.ascent(),
64 if (key_->name == "vdots" || key_->name == "ddots" || key_->name == "adots" || key_->name == "iddots")
66 if (key_->name == "adots" || key_->name == "iddots")
68 else if (key_->name != "vdots")
70 mathed_draw_deco(pi, x + 2, y - dh_, dim.width() - 2, dim.ascent(),
72 setPosCache(pi, x, y);
76 docstring InsetMathDots::name() const
82 void InsetMathDots::validate(LaTeXFeatures & features) const
84 if (!key_->requires.empty())
85 features.require(key_->requires);
89 void InsetMathDots::mathmlize(MathStream & os) const
91 // which symbols we support is decided by what is listed in
92 // lib/symbols as generating a dots inset
93 docstring const & n = key_->name;
95 if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots")
97 else if (n == "adots" || n == "iddots")
99 else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm")
101 else if (n == "ddots")
103 else if (n == "vdots")
106 LASSERT(false, ent = "…");
107 os << MTag("mi") << from_ascii(ent) << ETag("mi");
111 void InsetMathDots::htmlize(HtmlStream & os) const
113 // which symbols we support is decided by what is listed in
114 // lib/symbols as generating a dots inset
115 docstring const & n = key_->name;
117 if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots")
119 else if (n == "adots" || n == "iddots")
121 else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm")
123 else if (n == "ddots")
125 else if (n == "vdots")
128 LASSERT(false, ent = "#x02026;");
129 os << from_ascii(ent);