]> git.lyx.org Git - lyx.git/blob - src/mathed/math_stringinset.C
Prepare mathed for unified two-stage drawing
[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 Dimension MathStringInset::metrics(MetricsInfo & mi) const
23 {
24         Dimension dim;
25         mathed_string_dim(mi.base.font, str_, dim);
26         return dim;
27 }
28
29
30 void MathStringInset::draw(PainterInfo & pi, int x, int y) const
31 {
32         //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
33         drawStr(pi, pi.base.font, x, y, str_);
34 }
35
36
37 void MathStringInset::normalize(NormalStream & os) const
38 {
39         os << "[string " << str_ << ' ' << "mathalpha" << ']';
40 }
41
42
43 void MathStringInset::maple(MapleStream & os) const
44 {
45         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
46                 os << ' ' << str_ << ' ';
47                 return;
48         }
49
50         // insert '*' between adjacent chars if type is LM_TC_VAR
51         os << str_[0];
52         for (string::size_type i = 1; i < str_.size(); ++i)
53                 os << str_[i];
54 }
55
56
57 void MathStringInset::mathematica(MathematicaStream & os) const
58 {
59         os << ' ' << str_ << ' ';
60 }
61
62
63 void MathStringInset::octave(OctaveStream & os) const
64 {
65         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
66                 os << ' ' << str_ << ' ';
67                 return;
68         }
69
70         // insert '*' between adjacent chars if type is LM_TC_VAR
71         os << str_[0];
72         for (string::size_type i = 1; i < str_.size(); ++i)
73                 os << str_[i];
74 }
75
76
77 void MathStringInset::mathmlize(MathMLStream & os) const
78 {
79 /*
80         if (code_ == LM_TC_VAR)
81                 os << "<mi> " << str_ << " </mi>";
82         else if (code_ == LM_TC_CONST)
83                 os << "<mn> " << str_ << " </mn>";
84         else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
85                 os << "<mtext> " << str_ <<  " </mtext>";
86         else
87 */
88                 os << str_;
89 }
90
91
92 void MathStringInset::write(WriteStream & os) const
93 {
94         os << str_;
95 }