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