7 #include "math_stringinset.h"
8 #include "math_mathmlstream.h"
9 #include "math_streamstr.h"
12 #include "math_support.h"
13 #include "math_parser.h"
19 MathStringInset::MathStringInset()
20 : str_(), code_(LM_TC_MIN)
23 MathStringInset::MathStringInset(string const & s, MathTextCodes t)
28 MathInset * MathStringInset::clone() const
30 return new MathStringInset(*this);
34 int MathStringInset::ascent() const
36 return mathed_string_ascent(code_, mi_, str_);
40 int MathStringInset::descent() const
42 return mathed_string_descent(code_, mi_, str_);
46 int MathStringInset::width() const
48 return mathed_string_width(code_, mi_, str_);
52 void MathStringInset::metrics(MathMetricsInfo const & mi) const
58 void MathStringInset::draw(Painter & pain, int x, int y) const
60 //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
61 drawStr(pain, code_, mi_, x, y, str_);
65 void MathStringInset::normalize(NormalStream & os) const
67 os << "[string " << str_ << ' ' << "mathalpha" << "]";
71 void MathStringInset::maplize(MapleStream & os) const
73 if (code_ != LM_TC_VAR || str_.size() <= 1) {
74 os << ' ' << str_ << ' ';
78 // insert '*' between adjacent chars if type is LM_TC_VAR
80 for (string::size_type i = 1; i < str_.size(); ++i)
85 void MathStringInset::octavize(OctaveStream & os) const
87 if (code_ != LM_TC_VAR || str_.size() <= 1) {
88 os << ' ' << str_ << ' ';
92 // insert '*' between adjacent chars if type is LM_TC_VAR
94 for (string::size_type i = 1; i < str_.size(); ++i)
99 void MathStringInset::mathmlize(MathMLStream & os) const
101 if (code_ == LM_TC_VAR)
102 os << "<mi> " << str_ << " </mi>";
103 else if (code_ == LM_TC_CONST)
104 os << "<mn> " << str_ << " </mn>";
105 else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
106 os << "<mtext> " << str_ << " </mtext>";
112 void MathStringInset::write(WriteStream & os) const
114 if (math_font_name(code_))
115 os << '\\' << math_font_name(code_) << '{' << str_ << '}';