]> git.lyx.org Git - lyx.git/blob - src/mathed/math_stringinset.C
Finish the task of removing all cruft from the header files.
[lyx.git] / src / mathed / math_stringinset.C
1 /**
2  * \file math_stringinset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "math_stringinset.h"
14 #include "math_mathmlstream.h"
15 #include "math_streamstr.h"
16 #include "math_support.h"
17
18 using std::auto_ptr;
19
20
21 MathStringInset::MathStringInset(string const & s)
22         : str_(s)
23 {}
24
25
26 auto_ptr<InsetBase> MathStringInset::clone() const
27 {
28         return auto_ptr<InsetBase>(new MathStringInset(*this));
29 }
30
31
32 void MathStringInset::metrics(MetricsInfo & mi, Dimension & dim) const
33 {
34         mathed_string_dim(mi.base.font, str_, dim);
35 }
36
37
38 void MathStringInset::draw(PainterInfo & 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::maple(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::mathematica(MathematicaStream & os) const
66 {
67         os << ' ' << str_ << ' ';
68 }
69
70
71 void MathStringInset::octave(OctaveStream & os) const
72 {
73         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
74                 os << ' ' << str_ << ' ';
75                 return;
76         }
77
78         // insert '*' between adjacent chars if type is LM_TC_VAR
79         os << str_[0];
80         for (string::size_type i = 1; i < str_.size(); ++i)
81                 os << str_[i];
82 }
83
84
85 void MathStringInset::mathmlize(MathMLStream & os) const
86 {
87 /*
88         if (code_ == LM_TC_VAR)
89                 os << "<mi> " << str_ << " </mi>";
90         else if (code_ == LM_TC_CONST)
91                 os << "<mn> " << str_ << " </mn>";
92         else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
93                 os << "<mtext> " << str_ <<  " </mtext>";
94         else
95 */
96                 os << str_;
97 }
98
99
100 void MathStringInset::write(WriteStream & os) const
101 {
102         os << str_;
103 }