7 #include "math_charinset.h"
10 #include "support/LOstream.h"
11 #include "math_support.h"
12 #include "math_parser.h"
14 #include "math_mathmlstream.h"
17 MathCharInset::MathCharInset(char c)
18 : char_(c), code_(nativeCode(c))
20 //lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
24 MathCharInset::MathCharInset(char c, MathTextCodes t)
25 : char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t)
27 //lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
31 MathTextCodes MathCharInset::nativeCode(char c) const
35 //if (strchr("0123456789;:!|[]().,?+/-*<>=", c)
40 MathInset * MathCharInset::clone() const
42 return new MathCharInset(*this);
46 int MathCharInset::ascent() const
48 return mathed_char_ascent(code_, mi_, char_);
52 int MathCharInset::descent() const
54 return mathed_char_descent(code_, mi_, char_);
58 int MathCharInset::width() const
60 return mathed_char_width(code_, mi_, char_);
64 void MathCharInset::metrics(MathMetricsInfo const & mi) const
70 void MathCharInset::draw(Painter & pain, int x, int y) const
72 //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
73 drawChar(pain, code_, mi_, x, y, char_);
77 void MathCharInset::writeHeader(std::ostream & os) const
79 if (math_font_name(code_))
80 os << '\\' << math_font_name(code_) << '{';
84 void MathCharInset::writeTrailer(std::ostream & os) const
86 if (math_font_name(code_))
91 void MathCharInset::writeRaw(std::ostream & os) const
97 void MathCharInset::write(WriteStream & os) const
105 void MathCharInset::normalize(NormalStream & os) const
107 os << "[char " << char_ << " " << "mathalpha" << "]";
111 bool MathCharInset::isRelOp() const
113 return char_ == '=' || char_ == '<' || char_ == '>';
117 void MathCharInset::handleFont(MathTextCodes t)
119 code_ = (code_ == t) ? LM_TC_VAR : t;
123 bool MathCharInset::match(MathInset * p) const
125 MathCharInset const * q = p->asCharInset();
126 return q && char_ == q->char_ && code_ == q->code_;