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