]> git.lyx.org Git - lyx.git/blob - src/mathed/math_exfuncinset.C
architectural changes to tex2lyx
[lyx.git] / src / mathed / math_exfuncinset.C
1 #include <config.h>
2
3 #include "math_exfuncinset.h"
4 #include "math_support.h"
5 #include "math_mathmlstream.h"
6 #include "math_streamstr.h"
7
8 using std::auto_ptr;
9
10
11 MathExFuncInset::MathExFuncInset(string const & name)
12         : MathNestInset(1), name_(name)
13 {}
14
15
16 MathExFuncInset::MathExFuncInset(string const & name, MathArray const & ar)
17         : MathNestInset(1), name_(name)
18 {
19         cell(0) = ar;
20 }
21
22
23 auto_ptr<InsetBase> MathExFuncInset::clone() const
24 {
25         return auto_ptr<InsetBase>(new MathExFuncInset(*this));
26 }
27
28
29 void MathExFuncInset::metrics(MetricsInfo & mi, Dimension & /*dim*/) const
30 {
31         mathed_string_dim(mi.base.font, name_, dim_);
32 }
33
34
35 void MathExFuncInset::draw(PainterInfo & pi, int x, int y) const
36 {
37         drawStrBlack(pi, x, y, name_);
38 }
39
40
41 string MathExFuncInset::name() const
42 {
43         return name_;
44 }
45
46
47 void MathExFuncInset::maple(MapleStream & os) const
48 {
49         if (name_ == "det")
50                 os << "linalg[det](" << cell(0) << ')';
51         else
52                 os << name_ << '(' << cell(0) << ')';
53 }
54
55
56 void MathExFuncInset::maxima(MaximaStream & os) const
57 {
58         if (name_ == "det")
59                 os << "determinant(" << cell(0) << ')';
60         else
61                 os << name_ << '(' << cell(0) << ')';
62 }
63
64
65 string asMathematicaName(string const & name)
66 {
67         if (name == "sin")    return "Sin";
68         if (name == "sinh")   return "Sinh";
69         if (name == "arcsin") return "ArcSin";
70         if (name == "cos")    return "Cos";
71         if (name == "cosh")   return "Cosh";
72         if (name == "arcos")  return "ArcCos";
73         if (name == "tan")    return "Tan";
74         if (name == "tanh")   return "Tanh";
75         if (name == "arctan") return "ArcTan";
76         if (name == "cot")    return "Cot";
77         if (name == "coth")   return "Coth";
78         if (name == "csc")    return "Csc";
79         if (name == "sec")    return "Sec";
80         if (name == "exp")    return "Exp";
81         if (name == "log")    return "Log";
82         if (name == "ln" )    return "Log";
83         return name;
84 }
85
86
87 void MathExFuncInset::mathematica(MathematicaStream & os) const
88 {
89         os << asMathematicaName(name_) << '[' << cell(0) << ']';
90 }
91
92
93 void MathExFuncInset::mathmlize(MathMLStream & os) const
94 {
95         os << MTag(name_.c_str()) << cell(0) << ETag(name_.c_str());
96 }
97
98
99 void MathExFuncInset::octave(OctaveStream & os) const
100 {
101         os << name_ << '(' << cell(0) << ')';
102 }