]> git.lyx.org Git - lyx.git/blob - src/mathed/math_stringinset.C
first shot at preview. It crashes. Don't know why. To see it work a bit, change
[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 "LColor.h"
11 #include "math_support.h"
12 #include "math_parser.h"
13 #include "LaTeXFeatures.h"
14 #include "debug.h"
15
16
17 MathStringInset::MathStringInset(string const & s)
18         : str_(s)
19 {}
20
21
22 MathInset * MathStringInset::clone() const
23 {
24         return new MathStringInset(*this);
25 }
26
27
28 void MathStringInset::metrics(MathMetricsInfo & mi) const
29 {
30         mathed_string_dim(mi.base.font, str_, ascent_, descent_, width_);
31 }
32
33
34 void MathStringInset::draw(MathPainterInfo & pi, int x, int y) const
35 {
36         //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
37         drawStr(pi, pi.base.font, x, y, str_);
38 }
39
40
41 void MathStringInset::normalize(NormalStream & os) const
42 {
43         os << "[string " << str_ << ' ' << "mathalpha" << "]";
44 }
45
46
47 void MathStringInset::maplize(MapleStream & os) const
48 {
49         if (/*code_ != LM_TC_VAR || */ str_.size() <= 1) {
50                 os << ' ' << str_ << ' ';
51                 return;
52         }
53
54         // insert '*' between adjacent chars if type is LM_TC_VAR
55         os << str_[0];
56         for (string::size_type i = 1; i < str_.size(); ++i)
57                 os << str_[i];
58 }
59
60
61 void MathStringInset::octavize(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 }