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