]> git.lyx.org Git - lyx.git/blob - src/mathed/math_spaceinset.C
iterators for MathArray; cosmetics;
[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) const
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 void MathSpaceInset::writeNormal(std::ostream & os) const
49 {
50         os << "[space " << space_ << "] ";
51 }
52
53
54 void MathSpaceInset::metrics(MathStyles st) const
55 {
56         size_  = st;
57         width_ = space_ ? space_ * 2 : 2;
58         if (space_ > 3)
59                 width_ *= 2;
60         if (space_ == 5)
61                 width_ *= 2;
62         width_  += 4;
63         ascent_  = 4;
64         descent_ = 0;
65 }
66
67
68 void MathSpaceInset::incSpace()
69 {
70         space_ = (space_ + 1) % 6;
71 }