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