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