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