]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathDots.cpp
InsetMathHull.cpp: whitespace
[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
16 #include "MathStream.h"
17 #include "MathSupport.h"
18 #include "MathParser.h"
19 #include "MetricsInfo.h"
20
21 #include "frontends/FontMetrics.h"
22
23
24 namespace lyx {
25
26 InsetMathDots::InsetMathDots(latexkeys const * key)
27         : key_(key)
28 {}
29
30
31 Inset * InsetMathDots::clone() const
32 {
33         return new InsetMathDots(*this);
34 }
35
36
37 void InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const
38 {
39         dim = theFontMetrics(mi.base.font).dimension('M');
40         dh_ = 0;
41         if (key_->name == "cdots" || key_->name == "dotsb"
42                         || key_->name == "dotsm" || key_->name == "dotsi")
43                 dh_ = dim.asc / 2;
44         else if (key_->name == "dotsc")
45                 dh_ = dim.asc / 4;
46         else if (key_->name == "vdots") {
47                 dim.wid = (dim.wid / 2) + 1;
48                 dh_ = dim.asc;
49         }
50         else if (key_->name == "ddots")
51                 dh_ = dim.asc;
52 }
53
54
55 void InsetMathDots::draw(PainterInfo & pain, int x, int y) const
56 {
57         Dimension const dim = dimension(*pain.base.bv);
58         mathed_draw_deco(pain, x + 2, y - dh_, dim.width() - 2, dim.ascent(),
59                 key_->name);
60         if (key_->name == "vdots" || key_->name == "ddots")
61                 ++x;
62         if (key_->name != "vdots")
63                 --y;
64         mathed_draw_deco(pain, x + 2, y - dh_, dim.width() - 2, dim.ascent(),
65                 key_->name);
66         setPosCache(pain, x, y);
67 }
68
69
70 docstring InsetMathDots::name() const
71 {
72         return key_->name;
73 }
74
75
76 } // namespace lyx