]> git.lyx.org Git - lyx.git/blob - src/mathed/math_spaceinset.C
oh well
[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 char const * latex_mathspace[] = {
13         "!", ",", ":", ";", "quad", "qquad", "lyxnegspace"
14 };
15
16
17
18 MathSpaceInset::MathSpaceInset(int sp)
19         : space_(sp)
20 {}
21
22
23 MathInset * MathSpaceInset::clone() const
24 {
25         return new MathSpaceInset(*this);
26 }
27
28
29 void MathSpaceInset::metrics(MathMetricsInfo const &) const
30 {
31         switch (space_) {
32                 case 0: width_ = 6; break;
33                 case 1: width_ = 6; break;
34                 case 2: width_ = 8; break;
35                 case 3: width_ = 10; break;
36                 case 4: width_ = 20; break;
37                 case 5: width_ = 40; break;
38                 case 6: width_ = -2; break;
39                 default: width_ = 6; break;
40         }
41         ascent_  = 4;
42         descent_ = 0;
43 }
44
45
46 void MathSpaceInset::draw(Painter & pain, int x, int y) const
47 {
48
49 // Sadly, HP-UX CC can't handle that kind of initialization.
50 // XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
51         if (space_ == 6)
52                 return;
53
54         int xp[4];
55         int yp[4];
56
57         xp[0] = ++x;             yp[0] = y - 3;
58         xp[1] = x;                   yp[1] = y;
59         xp[2] = x + width_ - 2;  yp[2] = y;
60         xp[3] = x + width_ - 2;  yp[3] = y - 3;
61
62         pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math);
63 }
64
65
66 void MathSpaceInset::incSpace()
67 {
68         space_ = (space_ + 1) % 6;
69 }
70
71
72 void MathSpaceInset::maplize(MapleStream & os) const
73 {
74         os << ' ';
75 }
76
77
78 void MathSpaceInset::octavize(OctaveStream & os) const
79 {
80         os << ' ';
81 }
82
83
84 void MathSpaceInset::normalize(NormalStream & os) const
85 {
86         os << "[space " << space_ << "] ";
87 }
88
89
90 void MathSpaceInset::write(WriteStream & os) const
91 {
92         if (space_ >= 0 && space_ < 7)
93                 os << '\\' << latex_mathspace[space_] << ' ';
94 }