7 #include "math_charinset.h"
10 #include "support/LOstream.h"
11 #include "mathed/support.h"
12 #include "math_parser.h"
16 MathCharInset::MathCharInset(char c)
17 : char_(c), code_(nativeCode(c))
19 //lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
23 MathCharInset::MathCharInset(char c, MathTextCodes t)
24 : char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t)
26 //lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
30 MathTextCodes MathCharInset::nativeCode(char c) const
34 //if (strchr("0123456789;:!|[]().,?+/-*<>=", c)
39 MathInset * MathCharInset::clone() const
41 return new MathCharInset(*this);
45 int MathCharInset::ascent() const
47 return mathed_char_ascent(code_, mi_, char_);
51 int MathCharInset::descent() const
53 return mathed_char_descent(code_, mi_, char_);
57 int MathCharInset::width() const
59 return mathed_char_width(code_, mi_, char_);
63 void MathCharInset::metrics(MathMetricsInfo const & mi) const
69 void MathCharInset::draw(Painter & pain, int x, int y) const
71 //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
72 drawChar(pain, code_, mi_, x, y, char_);
76 void MathCharInset::writeHeader(std::ostream & os) const
78 if (math_font_name(code_))
79 os << '\\' << math_font_name(code_) << '{';
83 void MathCharInset::writeTrailer(std::ostream & os) const
85 if (math_font_name(code_))
90 void MathCharInset::writeRaw(std::ostream & os) const
96 void MathCharInset::write(MathWriteInfo & os) const
104 void MathCharInset::writeNormal(std::ostream & os) const
106 os << "[char " << char_ << " " << "mathalpha" << "]";
110 bool MathCharInset::isRelOp() const
112 return char_ == '=' || char_ == '<' || char_ == '>';
116 void MathCharInset::handleFont(MathTextCodes t)
118 code_ = (code_ == t) ? LM_TC_VAR : t;