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('X');
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 == "ddots" || key_->name == "adots"
49 || key_->name == "iddots" || key_->name == "vdots")
54 void InsetMathDots::draw(PainterInfo & pi, int x, int y) const
56 Dimension const dim = dimension(*pi.base.bv);
57 if (key_->name == "adots" || key_->name == "iddots")
59 else if (key_->name == "vdots")
60 x += (dim.width() - 2) / 2;
61 mathed_draw_deco(pi, x + 2, y - dh_, dim.width() - 2, dim.ascent(),
66 docstring InsetMathDots::name() const
72 void InsetMathDots::validate(LaTeXFeatures & features) const
74 if (!key_->required.empty())
75 features.require(key_->required);
79 void InsetMathDots::mathmlize(MathMLStream & ms) const
81 // which symbols we support is decided by what is listed in
82 // lib/symbols as generating a dots inset
83 docstring const & n = key_->name;
86 if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots")
88 else if (n == "adots" || n == "iddots")
90 else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm")
92 else if (n == "ddots")
94 else if (n == "vdots")
96 else LASSERT(false, ent = "…");
98 if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots")
100 else if (n == "adots" || n == "iddots")
102 else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm")
104 else if (n == "ddots")
106 else if (n == "vdots")
108 else LASSERT(false, ent = "…");
110 ms << MTag("mi") << from_ascii(ent) << ETag("mi");
114 void InsetMathDots::htmlize(HtmlStream & os) const
116 // which symbols we support is decided by what is listed in
117 // lib/symbols as generating a dots inset
118 docstring const & n = key_->name;
120 if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots")
122 else if (n == "adots" || n == "iddots")
124 else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm")
126 else if (n == "ddots")
128 else if (n == "vdots")
131 LASSERT(false, ent = "#x02026;");
132 os << from_ascii(ent);