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