]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathString.cpp
28e0aac7efb425bbfe6081742fcef5e77e6ca119
[lyx.git] / src / mathed / InsetMathString.cpp
1 /**
2  * \file InsetMathString.cpp
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 "InsetMathString.h"
14 #include "MathStream.h"
15 #include "MathStream.h"
16 #include "MathSupport.h"
17
18
19 namespace lyx {
20
21 InsetMathString::InsetMathString(docstring const & s)
22         : str_(s)
23 {}
24
25
26 Inset * InsetMathString::clone() const
27 {
28         return new InsetMathString(*this);
29 }
30
31
32 bool InsetMathString::metrics(MetricsInfo & mi, Dimension & dim) const
33 {
34         mathed_string_dim(mi.base.font, str_, dim);
35         if (dim_ == dim)
36                 return false;
37         dim_ = dim;
38         return true;
39 }
40
41
42 void InsetMathString::draw(PainterInfo & pi, int x, int y) const
43 {
44         pi.draw(x, y, str_);
45 }
46
47
48 void InsetMathString::normalize(NormalStream & os) const
49 {
50         os << "[string " << str_ << ' ' << "mathalpha" << ']';
51 }
52
53
54 void InsetMathString::maple(MapleStream & os) const
55 {
56         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
57                 os << ' ' << str_ << ' ';
58                 return;
59         }
60
61         // insert '*' between adjacent chars if type is LM_TC_VAR
62         os << str_[0];
63         for (size_t i = 1; i < str_.size(); ++i)
64                 os << str_[i];
65 }
66
67
68 void InsetMathString::mathematica(MathematicaStream & os) const
69 {
70         os << ' ' << str_ << ' ';
71 }
72
73
74 void InsetMathString::octave(OctaveStream & os) const
75 {
76         if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
77                 os << ' ' << str_ << ' ';
78                 return;
79         }
80
81         // insert '*' between adjacent chars if type is LM_TC_VAR
82         os << str_[0];
83         for (size_t i = 1; i < str_.size(); ++i)
84                 os << str_[i];
85 }
86
87
88 void InsetMathString::mathmlize(MathStream & os) const
89 {
90 /*
91         if (code_ == LM_TC_VAR)
92                 os << "<mi> " << str_ << " </mi>";
93         else if (code_ == LM_TC_CONST)
94                 os << "<mn> " << str_ << " </mn>";
95         else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
96                 os << "<mtext> " << str_ <<  " </mtext>";
97         else
98 */
99                 os << str_;
100 }
101
102
103 void InsetMathString::write(WriteStream & os) const
104 {
105         os << str_;
106 }
107
108
109 } // namespace lyx