]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathDots.C
6673d0483897673a040a044166d5cac2473afc8f
[lyx.git] / src / mathed / InsetMathDots.C
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 namespace lyx {
22
23
24 using std::string;
25 using std::auto_ptr;
26
27
28 InsetMathDots::InsetMathDots(latexkeys const * key)
29         : key_(key)
30 {}
31
32
33 auto_ptr<InsetBase> InsetMathDots::doClone() const
34 {
35         return auto_ptr<InsetBase>(new InsetMathDots(*this));
36 }
37
38
39 bool InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const
40 {
41         dim = theFontMetrics(mi.base.font).dimension('M');
42         dh_ = 0;
43         if (key_->name == "cdots" || key_->name == "dotsb"
44                         || key_->name == "dotsm" || key_->name == "dotsi")
45                 dh_ = dim.asc / 2;
46         else if (key_->name == "dotsc")
47                 dh_ = dim.asc / 4;
48         else if (key_->name == "vdots") {
49                 dim.wid = (dim.wid / 2) + 1;
50                 dh_ = dim.asc;
51         }
52         else if (key_->name == "ddots")
53                 dh_ = dim.asc;
54         if (dim_ == dim)
55                 return false;
56         dim_ = dim;
57         return true;
58 }
59
60
61 void InsetMathDots::draw(PainterInfo & pain, int x, int y) const
62 {
63         mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(),
64                 key_->name);
65         if (key_->name == "vdots" || key_->name == "ddots")
66                 ++x;
67         if (key_->name != "vdots")
68                 --y;
69         mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(),
70                 key_->name);
71         setPosCache(pain, x, y);
72 }
73
74
75 docstring InsetMathDots::name() const
76 {
77         return key_->name;
78 }
79
80
81 } // namespace lyx