]> git.lyx.org Git - lyx.git/blob - src/mathed/math_dotsinset.C
preview as preview can...
[lyx.git] / src / mathed / math_dotsinset.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "math_dotsinset.h"
8 #include "math_mathmlstream.h"
9 #include "math_streamstr.h"
10 #include "math_support.h"
11
12
13 MathDotsInset::MathDotsInset(string const & name)
14         : name_(name)
15 {}
16
17
18 MathInset * MathDotsInset::clone() const
19 {
20         return new MathDotsInset(*this);
21 }
22
23
24 void MathDotsInset::metrics(MathMetricsInfo & mi) const
25 {
26         mathed_char_dim(mi.base.font, 'M', ascent_, descent_, width_);
27         if (name_ == "ldots" || name_ == "dotsm") 
28                 dh_ = 0;
29         else if (name_ == "cdots" || name_ == "dotsb"
30                         || name_ == "dotsm" || name_ == "dotsi")
31                 dh_ = ascent_ / 2;
32         else if (name_ == "dotsc")
33                 dh_ = ascent_ / 4;
34         else if (name_ == "vdots")
35                 width_ /= 2;
36         else if (name_ == "ddots")
37                 dh_ = ascent_;
38 }
39
40
41 void MathDotsInset::draw(MathPainterInfo & pain, int x, int y) const
42 {
43         mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, name_);
44         if (name_ == "vdots" || name_ == "ddots")
45                 ++x;
46         if (name_ != "vdots")
47                 --y;
48         mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, name_);
49 }
50
51
52 void MathDotsInset::write(WriteStream & os) const
53 {
54         os << '\\' << name_ << ' ';
55 }
56
57
58 void MathDotsInset::normalize(NormalStream & os) const
59 {
60         os << "[" << name_ << "] ";
61 }