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"
14 #include "LaTeXFeatures.h"
20 MathStringInset::MathStringInset()
21 : str_(), code_(LM_TC_MIN)
24 MathStringInset::MathStringInset(string const & s, MathTextCodes t)
29 MathInset * MathStringInset::clone() const
31 return new MathStringInset(*this);
35 int MathStringInset::ascent() const
37 return mathed_string_ascent(font_, str_);
41 int MathStringInset::descent() const
43 return mathed_string_descent(font_, str_);
47 int MathStringInset::width() const
49 return mathed_string_width(font_, str_);
53 void MathStringInset::validate(LaTeXFeatures & features) const
55 //lyxerr << "stringinset amssymb" << endl;
56 if (code_ == LM_TC_MSA || code_ == LM_TC_MSB)
57 features.require("amssymb");
61 void MathStringInset::metrics(MathMetricsInfo const & mi) const
63 whichFont(font_, code_, mi);
67 void MathStringInset::draw(Painter & pain, int x, int y) const
69 //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
70 drawStr(pain, font_, x, y, str_);
74 void MathStringInset::normalize(NormalStream & os) const
76 os << "[string " << str_ << ' ' << "mathalpha" << "]";
80 void MathStringInset::maplize(MapleStream & os) const
82 if (code_ != LM_TC_VAR || str_.size() <= 1) {
83 os << ' ' << str_ << ' ';
87 // insert '*' between adjacent chars if type is LM_TC_VAR
89 for (string::size_type i = 1; i < str_.size(); ++i)
94 void MathStringInset::octavize(OctaveStream & os) const
96 if (code_ != LM_TC_VAR || str_.size() <= 1) {
97 os << ' ' << str_ << ' ';
101 // insert '*' between adjacent chars if type is LM_TC_VAR
103 for (string::size_type i = 1; i < str_.size(); ++i)
104 os << '*' << str_[i];
108 void MathStringInset::mathmlize(MathMLStream & os) const
110 if (code_ == LM_TC_VAR)
111 os << "<mi> " << str_ << " </mi>";
112 else if (code_ == LM_TC_CONST)
113 os << "<mn> " << str_ << " </mn>";
114 else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
115 os << "<mtext> " << str_ << " </mtext>";
121 void MathStringInset::write(WriteStream & os) const
123 if (math_font_name(code_))
124 os << '\\' << math_font_name(code_) << '{' << str_ << '}';