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