]> git.lyx.org Git - lyx.git/blob - src/mathed/math_spaceinset.C
remove LyXParagraph Clone use newly added copy constructor instead, some whitespace...
[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 MathSpaceInset::draw(Painter & pain, int x, int y)
28
29         
30 // XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
31         
32 // Sadly, HP-UX CC can't handle that kind of initialization.
33         
34         int xp[4];
35         int yp[4];
36         
37         xp[0] = ++x;            yp[0] = y - 3;
38         xp[1] = x;                 yp[1] = y;
39         xp[2] = x + width - 2;  yp[2] = y;
40         xp[3] = x + width - 2;  yp[3] = y - 3;
41         
42         pain.lines(xp, yp, 4, (space_) ? LColor::latex : LColor::math);
43 }
44
45
46 void MathSpaceInset::Write(ostream & os, bool /* fragile */)
47 {
48         if (space_ >= 0 && space_ < 6) {
49                 os << '\\' << latex_mathspace[space_] << ' ';
50         }
51 }
52
53
54 void MathSpaceInset::WriteNormal(ostream & os)
55 {
56         os << "[space " << space_ << "] ";
57 }
58
59
60 void MathSpaceInset::Metrics()
61 {
62         width = space_ ? space_ * 2 : 2;
63         if (space_ > 3)
64                 width *= 2;
65         if (space_ == 5)
66                 width *= 2;
67         width += 4;
68         ascent = 4;
69         descent = 0;
70 }
71
72
73 void MathSpaceInset::SetSpace(int sp)
74
75         space_ = sp;
76         Metrics();
77 }
78
79
80 int MathSpaceInset::GetSpace()
81 {
82         return space_;
83 }