]> git.lyx.org Git - lyx.git/blob - src/mathed/math_exintinset.C
small up/down tweaking
[lyx.git] / src / mathed / math_exintinset.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include <config.h>
6
7 #include "math_exintinset.h"
8 #include "math_support.h"
9 #include "math_mathmlstream.h"
10 #include "math_streamstr.h"
11 #include "math_symbolinset.h"
12 #include "debug.h"
13
14 #include <boost/scoped_ptr.hpp>
15
16
17 MathExIntInset::MathExIntInset(string const & name)
18         : MathNestInset(4), symbol_(name)
19 {}
20
21 // 0 - core
22 // 1 - diff
23 // 2 - lower
24 // 3 - upper
25
26
27 MathInset * MathExIntInset::clone() const
28 {
29         return new MathExIntInset(*this);
30 }
31
32
33 void MathExIntInset::symbol(string const & symbol)
34 {
35         symbol_ = symbol;
36 }
37
38
39 bool MathExIntInset::hasScripts() const
40 {
41         // take empty upper bound as "no scripts"
42         return !cell(3).empty();
43 }
44
45
46
47 void MathExIntInset::normalize(NormalStream & os) const
48 {
49         os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
50            << cell(2) << ' ' << cell(3) << ']';
51 }
52
53
54 void MathExIntInset::metrics(MathMetricsInfo &) const
55 {
56         lyxerr << "should not happen\n";
57 }
58
59
60 void MathExIntInset::draw(MathPainterInfo &, int, int) const
61 {
62         lyxerr << "should not happen\n";
63 }
64
65
66 void MathExIntInset::maplize(MapleStream & os) const
67 {
68         os << symbol_ << '(';
69         if (cell(0).size())
70                 os << cell(0);
71         else
72                 os << '1';
73         os << ',' << cell(1);
74         if (hasScripts())
75                 os << '=' << cell(2) << ".." << cell(3);
76         os << ')';
77 }
78
79
80 void MathExIntInset::maximize(MaximaStream & os) const
81 {
82         if ( symbol_ == "int" )
83                 os << "integrate(";
84         else
85                 os << symbol_ << '(';
86
87         if (cell(0).size())
88                 os << cell(0) << ',';
89         else
90                 os << '1' << ',';
91         if (hasScripts())
92                 os << cell(1) << ',' << cell(2) << ',' << cell(3) << ')';
93         else
94                 os << cell(1) << ')';
95 }
96
97 void MathExIntInset::mathematicize(MathematicaStream & os) const
98 {
99         if ( symbol_ == "int" )
100                 os << "Integrate[";
101         else if (symbol_ == "sum")
102                 os << "Sum[";
103         else
104                 os << symbol_ << '[';
105
106         if (cell(0).size())
107                 os << cell(0) << ',';
108         else
109                 os << '1' << ',';
110         if (hasScripts())
111                 os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
112         else
113                 os << cell(1) << ']';
114 }
115
116
117 void MathExIntInset::mathmlize(MathMLStream & os) const
118 {
119         boost::scoped_ptr<MathSymbolInset> sym(new MathSymbolInset(symbol_));
120         //if (hasScripts())
121         //      mathmlize(sym, os);
122         //else
123                 sym->mathmlize(os);
124         os << cell(0) << "<mo> &InvisibleTimes; </mo>"
125            << MTag("mrow") << "<mo> &DifferentialD; </mo>"
126            << cell(1) << ETag("mrow");
127 }
128
129
130 void MathExIntInset::write(WriteStream &) const
131 {
132         lyxerr << "should not happen\n";
133 }