]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathExFunc.cpp
#include cosmetics
[lyx.git] / src / mathed / InsetMathExFunc.cpp
1 /**
2  * \file InsetMathExFunc.cpp
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 "InsetMathExFunc.h"
14
15 #include "MathData.h"
16 #include "MathStream.h"
17 #include "MathSupport.h"
18 #include "MetricsInfo.h"
19
20 #include "support/docstream.h"
21
22
23 namespace lyx {
24
25 using std::string;
26
27
28 InsetMathExFunc::InsetMathExFunc(docstring const & name)
29         : InsetMathNest(1), name_(name)
30 {}
31
32
33 InsetMathExFunc::InsetMathExFunc(docstring const & name, MathData const & ar)
34         : InsetMathNest(1), name_(name)
35 {
36         cell(0) = ar;
37 }
38
39
40 Inset * InsetMathExFunc::clone() const
41 {
42         return new InsetMathExFunc(*this);
43 }
44
45
46 void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const
47 {
48         mathed_string_dim(mi.base.font, name_, dim);
49         // Cache the inset dimension. 
50         setDimCache(mi, dim);
51 }
52
53
54 void InsetMathExFunc::draw(PainterInfo & pi, int x, int y) const
55 {
56         drawStrBlack(pi, x, y, name_);
57 }
58
59
60 docstring InsetMathExFunc::name() const
61 {
62         return name_;
63 }
64
65
66 void InsetMathExFunc::maple(MapleStream & os) const
67 {
68         if (name_ == "det")
69                 os << "linalg[det](" << cell(0) << ')';
70         else
71                 os << name_ << '(' << cell(0) << ')';
72 }
73
74
75 void InsetMathExFunc::maxima(MaximaStream & os) const
76 {
77         if (name_ == "det")
78                 os << "determinant(" << cell(0) << ')';
79         else
80                 os << name_ << '(' << cell(0) << ')';
81 }
82
83
84 static string asMathematicaName(string const & name)
85 {
86         if (name == "sin")    return "Sin";
87         if (name == "sinh")   return "Sinh";
88         if (name == "arcsin") return "ArcSin";
89         if (name == "asin")   return "ArcSin";
90         if (name == "cos")    return "Cos";
91         if (name == "cosh")   return "Cosh";
92         if (name == "arccos") return "ArcCos";
93         if (name == "acos")   return "ArcCos";
94         if (name == "tan")    return "Tan";
95         if (name == "tanh")   return "Tanh";
96         if (name == "arctan") return "ArcTan";
97         if (name == "atan")   return "ArcTan";
98         if (name == "cot")    return "Cot";
99         if (name == "coth")   return "Coth";
100         if (name == "csc")    return "Csc";
101         if (name == "sec")    return "Sec";
102         if (name == "exp")    return "Exp";
103         if (name == "log")    return "Log";
104         if (name == "ln" )    return "Log";
105         if (name == "arg" )   return "Arg";
106         if (name == "det" )   return "Det";
107         if (name == "gcd" )   return "GCD";
108         if (name == "max" )   return "Max";
109         if (name == "min" )   return "Min";
110         if (name == "erf" )   return "Erf";
111         if (name == "erfc" )  return "Erfc";
112         return name;
113 }
114
115
116 static docstring asMathematicaName(docstring const & name)
117 {
118         return from_utf8(asMathematicaName(to_utf8(name)));
119 }
120
121
122 void InsetMathExFunc::mathematica(MathematicaStream & os) const
123 {
124         os << asMathematicaName(name_) << '[' << cell(0) << ']';
125 }
126
127
128 void InsetMathExFunc::mathmlize(MathStream & os) const
129 {
130         ++os.tab(); os.cr(); os.os() << '<' << name_ << '>';
131         os << cell(0);
132         os.cr(); --os.tab(); os.os() << "</" << name_ << '>';
133 }
134
135
136 void InsetMathExFunc::octave(OctaveStream & os) const
137 {
138         os << name_ << '(' << cell(0) << ')';
139 }
140
141
142 } // namespace lyx