7 #include "math_stringinset.h"
8 #include "math_mathmlstream.h"
11 #include "math_support.h"
12 #include "math_parser.h"
16 MathStringInset::MathStringInset()
17 : str_(), code_(LM_TC_MIN)
20 MathStringInset::MathStringInset(string const & s, MathTextCodes t)
25 MathInset * MathStringInset::clone() const
27 return new MathStringInset(*this);
31 int MathStringInset::ascent() const
33 return mathed_string_ascent(code_, mi_, str_);
37 int MathStringInset::descent() const
39 return mathed_string_descent(code_, mi_, str_);
43 int MathStringInset::width() const
45 return mathed_string_width(code_, mi_, str_);
49 void MathStringInset::metrics(MathMetricsInfo const & mi) const
55 void MathStringInset::draw(Painter & pain, int x, int y) const
57 //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
58 drawStr(pain, code_, mi_, x, y, str_);
62 void MathStringInset::write(WriteStream & os) const
64 if (math_font_name(code_))
65 os << '\\' << math_font_name(code_) << '{' << str_.c_str() << '}';
71 void MathStringInset::normalize(NormalStream & os) const
73 os << "[string " << str_.c_str() << ' ' << "mathalpha" << "]";
77 void MathStringInset::maplize(MapleStream & os) const
79 if (code_ != LM_TC_VAR || str_.size() <= 1) {
84 // insert '*' between adjacent chars if type is LM_TC_VAR
86 for (string::size_type i = 1; i < str_.size(); ++i)
91 void MathStringInset::octavize(OctaveStream & os) const
93 if (code_ != LM_TC_VAR || str_.size() <= 1) {
98 // insert '*' between adjacent chars if type is LM_TC_VAR
100 for (string::size_type i = 1; i < str_.size(); ++i)
101 os << '*' << str_[i];
105 void MathStringInset::mathmlize(MathMLStream & os) const
107 if (code_ == LM_TC_VAR)
108 os << "<mi> " << str_.c_str() << " </mi>";
109 else if (code_ == LM_TC_CONST)
110 os << "<mn> " << str_.c_str() << " </mn>";
111 else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
112 os << "<mtext> " << str_.c_str() << " </mtext>";