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::normalize(NormalStream & os) const
64 os << "[string " << str_.c_str() << ' ' << "mathalpha" << "]";
68 void MathStringInset::maplize(MapleStream & os) const
70 if (code_ != LM_TC_VAR || str_.size() <= 1) {
71 os << ' ' << str_.c_str() << ' ';
75 // insert '*' between adjacent chars if type is LM_TC_VAR
77 for (string::size_type i = 1; i < str_.size(); ++i)
82 void MathStringInset::octavize(OctaveStream & os) const
84 if (code_ != LM_TC_VAR || str_.size() <= 1) {
85 os << ' ' << str_.c_str() << ' ';
89 // insert '*' between adjacent chars if type is LM_TC_VAR
91 for (string::size_type i = 1; i < str_.size(); ++i)
96 void MathStringInset::mathmlize(MathMLStream & os) const
98 if (code_ == LM_TC_VAR)
99 os << "<mi> " << str_.c_str() << " </mi>";
100 else if (code_ == LM_TC_CONST)
101 os << "<mn> " << str_.c_str() << " </mn>";
102 else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
103 os << "<mtext> " << str_.c_str() << " </mtext>";
109 void MathStringInset::write(WriteStream & os) const
111 if (math_font_name(code_))
112 os << '\\' << math_font_name(code_) << '{' << str_.c_str() << '}';