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