]> git.lyx.org Git - lyx.git/blob - src/mathed/math_spaceinset.C
cosmetics: rename support.[Ch] into math_support.[Ch]
[lyx.git] / src / mathed / math_spaceinset.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include "math_spaceinset.h"
6 #include "math_support.h"
7 #include "LColor.h"
8 #include "Painter.h"
9 #include "math_mathmlstream.h"
10
11
12
13 MathSpaceInset::MathSpaceInset(int sp)
14         : space_(sp)
15 {}
16
17
18 MathInset * MathSpaceInset::clone() const
19 {
20         return new MathSpaceInset(*this);
21 }
22
23
24 void MathSpaceInset::write(MathWriteInfo & os) const
25 {
26         if (space_ >= 0 && space_ < 6)
27                 os << '\\' << latex_mathspace[space_] << ' ';
28 }
29
30
31 void MathSpaceInset::writeNormal(NormalStream & os) const
32 {
33         os << "[space " << space_ << "] ";
34 }
35
36
37 void MathSpaceInset::metrics(MathMetricsInfo const & mi) const
38 {
39         width_ = space_ ? space_ * 2 : 2;
40         if (space_ > 3)
41                 width_ *= 2;
42         if (space_ == 5)
43                 width_ *= 2;
44         width_  += 4;
45         ascent_  = 4;
46         descent_ = 0;
47 }
48
49
50 void MathSpaceInset::draw(Painter & pain, int x, int y) const
51
52         
53 // XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
54         
55 // Sadly, HP-UX CC can't handle that kind of initialization.
56         
57         int xp[4];
58         int yp[4];
59         
60         xp[0] = ++x;             yp[0] = y - 3;
61         xp[1] = x;                   yp[1] = y;
62         xp[2] = x + width_ - 2;  yp[2] = y;
63         xp[3] = x + width_ - 2;  yp[3] = y - 3;
64         
65         pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math);
66 }
67
68
69 void MathSpaceInset::incSpace()
70 {
71         space_ = (space_ + 1) % 6;
72 }