]> git.lyx.org Git - lyx.git/blob - src/mathed/math_dotsinset.C
architectural changes to tex2lyx
[lyx.git] / src / mathed / math_dotsinset.C
1 #include <config.h>
2
3 #include "math_dotsinset.h"
4 #include "math_mathmlstream.h"
5 #include "math_streamstr.h"
6 #include "math_support.h"
7 #include "math_parser.h"
8
9 using std::auto_ptr;
10
11
12 MathDotsInset::MathDotsInset(latexkeys const * key)
13         : key_(key)
14 {}
15
16
17 auto_ptr<InsetBase> MathDotsInset::clone() const
18 {
19         return auto_ptr<InsetBase>(new MathDotsInset(*this));
20 }
21
22
23 void MathDotsInset::metrics(MetricsInfo & mi, Dimension & dim) const
24 {
25         mathed_char_dim(mi.base.font, 'M', dim_);
26         dh_ = 0;
27         if (key_->name == "cdots" || key_->name == "dotsb"
28                         || key_->name == "dotsm" || key_->name == "dotsi")
29                 dh_ = dim_.asc / 2;
30         else if (key_->name == "dotsc")
31                 dh_ = dim_.asc / 4;
32         else if (key_->name == "vdots") {
33                 dim_.wid = (dim_.wid / 2) + 1;
34                 dh_ = dim_.asc;
35         }
36         else if (key_->name == "ddots")
37                 dh_ = dim_.asc;
38         dim = dim_;
39 }
40
41
42 void MathDotsInset::draw(PainterInfo & pain, int x, int y) const
43 {
44         mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(),
45                 key_->name);
46         if (key_->name == "vdots" || key_->name == "ddots")
47                 ++x;
48         if (key_->name != "vdots")
49                 --y;
50         mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(),
51                 key_->name);
52 }
53
54
55 string MathDotsInset::name() const
56 {
57         return key_->name;
58 }