]> git.lyx.org Git - lyx.git/blob - src/mathed/math_stringinset.C
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / math_stringinset.C
1 #include <config.h>
2
3
4 #include "math_stringinset.h"
5 #include "math_mathmlstream.h"
6 #include "math_streamstr.h"
7 #include "math_support.h"
8 #include "debug.h"
9
10
11 MathStringInset::MathStringInset(string const & s)
12         : str_(s)
13 {}
14
15
16 MathInset * MathStringInset::clone() const
17 {
18         return new MathStringInset(*this);
19 }
20
21
22 void MathStringInset::metrics(MathMetricsInfo & mi) const
23 {
24         mathed_string_dim(mi.base.font, str_, dim_);
25 }
26
27
28 void MathStringInset::draw(MathPainterInfo & pi, int x, int y) const
29 {
30         //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
31         drawStr(pi, pi.base.font, x, y, str_);
32 }
33
34
35 void MathStringInset::normalize(NormalStream & os) const
36 {
37         os << "[string " << str_ << ' ' << "mathalpha" << ']';
38 }
39
40
41 void MathStringInset::maple(MapleStream & os) const
42 {
43         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
44                 os << ' ' << str_ << ' ';
45                 return;
46         }
47
48         // insert '*' between adjacent chars if type is LM_TC_VAR
49         os << str_[0];
50         for (string::size_type i = 1; i < str_.size(); ++i)
51                 os << str_[i];
52 }
53
54
55 void MathStringInset::mathematica(MathematicaStream & os) const
56 {
57         os << ' ' << str_ << ' ';
58 }
59
60
61 void MathStringInset::octave(OctaveStream & os) const
62 {
63         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
64                 os << ' ' << str_ << ' ';
65                 return;
66         }
67
68         // insert '*' between adjacent chars if type is LM_TC_VAR
69         os << str_[0];
70         for (string::size_type i = 1; i < str_.size(); ++i)
71                 os << str_[i];
72 }
73
74
75 void MathStringInset::mathmlize(MathMLStream & os) const
76 {
77 /*
78         if (code_ == LM_TC_VAR)
79                 os << "<mi> " << str_ << " </mi>";
80         else if (code_ == LM_TC_CONST)
81                 os << "<mn> " << str_ << " </mn>";
82         else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
83                 os << "<mtext> " << str_ <<  " </mtext>";
84         else
85 */
86                 os << str_;
87 }
88
89
90 void MathStringInset::write(WriteStream & os) const
91 {
92         os << str_;
93 }