]> git.lyx.org Git - lyx.git/blob - src/mathed/math_spaceinset.C
make \newcommand{\bb}[1]{\mathbf{#1}} work for read/write/display.
[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::metrics(MathMetricsInfo const &) const
25 {
26         width_ = space_ ? space_ * 2 : 2;
27         if (space_ > 3)
28                 width_ *= 2;
29         if (space_ == 5)
30                 width_ *= 2;
31         width_  += 4;
32         ascent_  = 4;
33         descent_ = 0;
34 }
35
36
37 void MathSpaceInset::draw(Painter & pain, int x, int y) const
38
39         
40 // XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
41         
42 // Sadly, HP-UX CC can't handle that kind of initialization.
43         
44         int xp[4];
45         int yp[4];
46         
47         xp[0] = ++x;             yp[0] = y - 3;
48         xp[1] = x;                   yp[1] = y;
49         xp[2] = x + width_ - 2;  yp[2] = y;
50         xp[3] = x + width_ - 2;  yp[3] = y - 3;
51         
52         pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math);
53 }
54
55
56 void MathSpaceInset::incSpace()
57 {
58         space_ = (space_ + 1) % 6;
59 }
60
61
62 void MathSpaceInset::maplize(MapleStream & os) const
63 {
64         os << ' ';
65 }
66
67
68 void MathSpaceInset::octavize(OctaveStream & os) const
69 {
70         os << ' ';
71 }
72
73
74 void MathSpaceInset::normalize(NormalStream & os) const
75 {
76         os << "[space " << space_ << "] ";
77 }
78
79
80 void MathSpaceInset::write(WriteStream & os) const
81 {
82         if (space_ >= 0 && space_ < 6)
83                 os << '\\' << latex_mathspace[space_] << ' ';
84 }
85
86