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_, size(), char_);
67 int MathCharInset::descent() const
69 return mathed_char_descent(code_, size(), char_);
73 int MathCharInset::width() const
75 return mathed_char_width(code_, size(), char_);
79 void MathCharInset::metrics(MathMetricsInfo const & st) const
85 void MathCharInset::draw(Painter & pain, int x, int y) const
89 //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
90 drawChar(pain, code_, size_.size, x, y, char_);
94 void MathCharInset::writeHeader(std::ostream & os) const
96 if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
97 os << '\\' << math_font_name[code_ - LM_TC_RM] << '{';
101 void MathCharInset::writeTrailer(std::ostream & os) const
103 if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
108 void MathCharInset::writeRaw(std::ostream & os) const
114 void MathCharInset::write(MathWriteInfo & os) const
122 void MathCharInset::writeNormal(std::ostream & os) const
128 bool MathCharInset::isRelOp() const
130 return char_ == '=' || char_ == '<' || char_ == '>';
134 void MathCharInset::handleFont(MathTextCodes t)
136 code_ = (code_ == t) ? LM_TC_VAR : t;