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