7 #include "math_charinset.h"
10 #include "support/LOstream.h"
11 #include "mathed/support.h"
12 #include "math_parser.h"
18 char const * math_font_name[] = {
32 MathCharInset::MathCharInset(char c)
33 : char_(c), code_(nativeCode(c))
35 //lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
39 MathCharInset::MathCharInset(char c, MathTextCodes t)
40 : char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t)
42 //lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
46 MathTextCodes MathCharInset::nativeCode(char c) const
50 //if (strchr("0123456789;:!|[]().,?+/-*<>=", c)
55 MathInset * MathCharInset::clone() const
57 return new MathCharInset(*this);
61 int MathCharInset::ascent() const
63 return mathed_char_ascent(code_, mi_, char_);
67 int MathCharInset::descent() const
69 return mathed_char_descent(code_, mi_, char_);
73 int MathCharInset::width() const
75 return mathed_char_width(code_, mi_, char_);
79 void MathCharInset::metrics(MathMetricsInfo const & mi) const
85 void MathCharInset::draw(Painter & pain, int x, int y) const
87 //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
88 drawChar(pain, code_, mi_, x, y, char_);
92 void MathCharInset::writeHeader(std::ostream & os) const
94 if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
95 os << '\\' << math_font_name[code_ - LM_TC_RM] << '{';
99 void MathCharInset::writeTrailer(std::ostream & os) const
101 if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
106 void MathCharInset::writeRaw(std::ostream & os) const
112 void MathCharInset::write(MathWriteInfo & os) const
120 void MathCharInset::writeNormal(std::ostream & os) const
126 bool MathCharInset::isRelOp() const
128 return char_ == '=' || char_ == '<' || char_ == '>';
132 void MathCharInset::handleFont(MathTextCodes t)
134 code_ = (code_ == t) ? LM_TC_VAR : t;