]> git.lyx.org Git - lyx.git/blob - src/mathed/math_spaceinset.C
mathed cleanup, change mask for tmpdir
[lyx.git] / src / mathed / math_spaceinset.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "math_spaceinset.h"
8 #include "LColor.h"
9 #include "Painter.h"
10 #include "mathed/support.h"
11 #include "support/LOstream.h"
12
13 using std::ostream;
14
15
16 MathSpaceInset::MathSpaceInset(int sp, short ot, short st)
17         : MathedInset("", ot, st), space_(sp)
18 {}
19
20
21 MathedInset * MathSpaceInset::Clone()
22 {
23         return new MathSpaceInset(space_, GetType(), GetStyle());
24 }
25
26
27 void
28 MathSpaceInset::draw(Painter & pain, int x, int y)
29
30         
31 // XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
32         
33 // Sadly, HP-UX CC can't handle that kind of initialization.
34         
35         int xp[4];
36         int yp[4];
37         
38         xp[0] = ++x;            yp[0] = y - 3;
39         xp[1] = x;                 yp[1] = y;
40         xp[2] = x + width - 2;  yp[2] = y;
41         xp[3] = x + width - 2;  yp[3] = y - 3;
42         
43         pain.lines(xp, yp, 4, (space_) ? LColor::latex : LColor::math);
44 }
45
46
47 void
48 MathSpaceInset::Write(ostream & os, bool /* fragile */)
49 {
50         if (space_ >= 0 && space_ < 6) {
51                 os << '\\' << latex_mathspace[space_] << ' ';
52         }
53 }
54
55
56 void MathSpaceInset::Metrics()
57 {
58         width = space_ ? space_ * 2 : 2;
59         if (space_ > 3) width *= 2;
60         if (space_ == 5) width *= 2;
61         width += 4;
62         ascent = 4;
63         descent = 0;
64 }
65
66
67 void MathSpaceInset::SetSpace(int sp)
68
69         space_ = sp;
70         Metrics();
71 }
72
73
74 int MathSpaceInset::GetSpace()
75 {
76         return space_;
77 }