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