]> git.lyx.org Git - lyx.git/blob - src/mathed/math_exintinset.C
more trivial tweaks to mathed bindings
[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::mathematicize(MathematicaStream & os) const
83 {
84         if ( symbol_ == "int" ) 
85                 os << "Integrate[";
86         else 
87                 if (symbol_ == "sum") 
88                         os << "Sum[";
89                 else 
90                         os << symbol_ << '[';
91         
92         if (cell(0).size())
93                 os << cell(0) << ',';
94         else
95                 os << '1' << ',';
96         if (hasScripts())
97                 os << '{' << cell(1) << ',' << cell(2) << ',' << cell(3) << "}]";
98         else 
99                 os << cell(1) << ']';
100 }
101
102
103 void MathExIntInset::mathmlize(MathMLStream & os) const
104 {
105         boost::scoped_ptr<MathSymbolInset> sym(new MathSymbolInset(symbol_));
106         //if (hasScripts())
107         //      mathmlize(sym, os);
108         //else
109                 sym->mathmlize(os);
110         os << cell(0) << "<mo> &InvisibleTimes; </mo>"
111            << MTag("mrow") << "<mo> &DifferentialD; </mo>"
112            << cell(1) << ETag("mrow");
113 }
114
115
116 void MathExIntInset::write(WriteStream &) const
117 {
118         lyxerr << "should not happen\n";
119 }