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("#$%{|}", c))
36 //if (strchr("0123456789;:!|[]().,?+/-*<>=", c)
41 MathInset * MathCharInset::clone() const
43 return new MathCharInset(*this);
47 int MathCharInset::ascent() const
49 return mathed_char_ascent(code_, size(), char_);
53 int MathCharInset::descent() const
55 return mathed_char_descent(code_, size(), char_);
59 int MathCharInset::width() const
61 return mathed_char_width(code_, size(), char_);
65 void MathCharInset::metrics(MathStyles st) const
71 void MathCharInset::draw(Painter & pain, int x, int y) const
75 //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
76 drawChar(pain, code_, size_, x, y, char_);
80 void MathCharInset::writeHeader(std::ostream & os) const
82 if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
83 os << '\\' << math_font_name[code_ - LM_TC_RM] << '{';
87 void MathCharInset::writeTrailer(std::ostream & os) const
89 if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
94 void MathCharInset::writeRaw(std::ostream & os) const
100 void MathCharInset::write(std::ostream & os, bool) const
108 void MathCharInset::writeNormal(std::ostream & os) const
114 bool MathCharInset::isRelOp() const
116 return char_ == '=' || char_ == '<' || char_ == '>';
120 void MathCharInset::handleFont(MathTextCodes t)
122 code_ = (code_ == t) ? LM_TC_VAR : t;