5 #include "math_spaceinset.h"
6 #include "math_support.h"
8 #include "frontends/Painter.h"
9 #include "math_mathmlstream.h"
13 char const * latex_mathspace[] = {
14 "!", ",", ":", ";", "quad", "qquad", "lyxnegspace", "lyxposspace"
20 MathSpaceInset::MathSpaceInset(int sp)
25 MathSpaceInset::MathSpaceInset(string const & name)
28 for (int i = 0; i < 8; ++i)
29 if (latex_mathspace[i] == name)
35 MathInset * MathSpaceInset::clone() const
37 return new MathSpaceInset(*this);
41 void MathSpaceInset::metrics(MathMetricsInfo &) const
44 case 0: dim_.w = 6; break;
45 case 1: dim_.w = 6; break;
46 case 2: dim_.w = 8; break;
47 case 3: dim_.w = 10; break;
48 case 4: dim_.w = 20; break;
49 case 5: dim_.w = 40; break;
50 case 6: dim_.w = -2; break;
51 case 7: dim_.w = 2; break;
52 default: dim_.w = 6; break;
59 void MathSpaceInset::draw(MathPainterInfo & pain, int x, int y) const
62 // Sadly, HP-UX CC can't handle that kind of initialization.
63 // XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
70 xp[0] = ++x; yp[0] = y - 3;
72 xp[2] = x + width() - 2; yp[2] = y;
73 xp[3] = x + width() - 2; yp[3] = y - 3;
75 pain.pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math);
79 void MathSpaceInset::incSpace()
81 space_ = (space_ + 1) % 6;
85 void MathSpaceInset::maplize(MapleStream & os) const
90 void MathSpaceInset::mathematicize(MathematicaStream & os) const
96 void MathSpaceInset::octavize(OctaveStream & os) const
102 void MathSpaceInset::normalize(NormalStream & os) const
104 os << "[space " << int(space_) << ' ' << latex_mathspace[space_] << "] ";
108 void MathSpaceInset::write(WriteStream & os) const
110 if (space_ >= 0 && space_ < 8)
111 os << '\\' << latex_mathspace[space_] << ' ';