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)), needbs_(false)
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), needbs_(false)
26 //lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
30 MathCharInset::MathCharInset(char c, MathTextCodes t, bool needbs)
31 : char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t), needbs_(needbs)
33 //lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
37 MathTextCodes MathCharInset::nativeCode(char c) const
41 if (strchr("#$%{|}", c))
43 //if (strchr("0123456789;:!|[]().,?+/-*<>=", c)
48 MathInset * MathCharInset::clone() const
50 return new MathCharInset(*this);
54 int MathCharInset::ascent() const
56 return mathed_char_ascent(code_, size(), char_);
60 int MathCharInset::descent() const
62 return mathed_char_descent(code_, size(), char_);
66 int MathCharInset::width() const
68 return mathed_char_width(code_, size(), char_);
72 void MathCharInset::metrics(MathStyles st) const
78 void MathCharInset::draw(Painter & pain, int x, int y) const
82 //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
83 drawChar(pain, code_, size_, x, y, char_);
87 void MathCharInset::writeHeader(std::ostream & os) const
89 if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
90 os << '\\' << math_font_name[code_ - LM_TC_RM] << '{';
94 void MathCharInset::writeTrailer(std::ostream & os) const
96 if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
101 void MathCharInset::writeRaw(std::ostream & os) const
109 void MathCharInset::write(std::ostream & os, bool) const
117 void MathCharInset::writeNormal(std::ostream & os) const
125 bool MathCharInset::isRelOp() const
127 return char_ == '=' || char_ == '<' || char_ == '>';
131 void MathCharInset::handleFont(MathTextCodes t)
133 code_ = (code_ == t) ? LM_TC_VAR : t;