]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathDots.cpp
d90b0bdbd332fca2a207c07bd808e827355e1f54
[lyx.git] / src / mathed / InsetMathDots.cpp
1 /**
2  * \file InsetMathDots.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "InsetMathDots.h"
15 #include "MathStream.h"
16 #include "MathSupport.h"
17 #include "MathParser.h"
18
19 #include "frontends/FontMetrics.h"
20
21
22 namespace lyx {
23
24 InsetMathDots::InsetMathDots(latexkeys const * key)
25         : key_(key)
26 {}
27
28
29 Inset * InsetMathDots::clone() const
30 {
31         return new InsetMathDots(*this);
32 }
33
34
35 void InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const
36 {
37         dim = theFontMetrics(mi.base.font).dimension('M');
38         dh_ = 0;
39         if (key_->name == "cdots" || key_->name == "dotsb"
40                         || key_->name == "dotsm" || key_->name == "dotsi")
41                 dh_ = dim.asc / 2;
42         else if (key_->name == "dotsc")
43                 dh_ = dim.asc / 4;
44         else if (key_->name == "vdots") {
45                 dim.wid = (dim.wid / 2) + 1;
46                 dh_ = dim.asc;
47         }
48         else if (key_->name == "ddots")
49                 dh_ = dim.asc;
50         dim = dim_;
51 }
52
53
54 void InsetMathDots::draw(PainterInfo & pain, int x, int y) const
55 {
56         mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(),
57                 key_->name);
58         if (key_->name == "vdots" || key_->name == "ddots")
59                 ++x;
60         if (key_->name != "vdots")
61                 --y;
62         mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(),
63                 key_->name);
64         setPosCache(pain, x, y);
65 }
66
67
68 docstring InsetMathDots::name() const
69 {
70         return key_->name;
71 }
72
73
74 } // namespace lyx