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