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_, size(), char_);
51 int MathCharInset::descent() const
53 return mathed_char_descent(code_, size(), char_);
57 int MathCharInset::width() const
59 return mathed_char_width(code_, size(), char_);
63 void MathCharInset::metrics(MathStyles st) const
69 void MathCharInset::draw(Painter & pain, int x, int y) const
73 //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
74 drawChar(pain, code_, size_, x, y, char_);
78 void MathCharInset::writeHeader(std::ostream & os) const
80 if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
81 os << '\\' << math_font_name[code_ - LM_TC_RM] << '{';
85 void MathCharInset::writeTrailer(std::ostream & os) const
87 if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
92 void MathCharInset::writeRaw(std::ostream & os) const
98 void MathCharInset::write(std::ostream & os, bool) const
106 void MathCharInset::writeNormal(std::ostream & os) const
112 bool MathCharInset::isRelOp() const
114 return char_ == '=' || char_ == '<' || char_ == '>';
118 void MathCharInset::handleFont(MathTextCodes t)
120 code_ = (code_ == t) ? LM_TC_VAR : t;