5 #include "math_charinset.h"
8 #include "support/LOstream.h"
9 #include "mathed/support.h"
10 #include "math_parser.h"
14 MathCharInset::MathCharInset(char c, MathTextCodes t)
21 MathInset * MathCharInset::clone() const
23 return new MathCharInset(*this);
27 int MathCharInset::ascent() const
29 return mathed_char_ascent(code_, size(), char_);
33 int MathCharInset::descent() const
35 return mathed_char_descent(code_, size(), char_);
39 int MathCharInset::width() const
41 return mathed_char_width(code_, size(), char_);
45 void MathCharInset::metrics(MathStyles st) const
51 void MathCharInset::draw(Painter & pain, int x, int y) const
55 drawChar(pain, code_, size_, x, y, char_);
59 void MathCharInset::write(std::ostream & os, bool) const
63 if (MathIsSymbol(code_)) {
64 latexkeys const * l = lm_get_key_by_id(char_, LM_TK_SYM);
67 l = lm_get_key_by_id(char_, LM_TK_BIGSYM);
70 os << '\\' << l->name << ' ';
72 lyxerr << "Could not find the LaTeX name for "
73 << char_ << " and code_ " << code_ << "!" << std::endl;
76 if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
77 os << '\\' << math_font_name[code_ - LM_TC_RM] << '{';
79 // Is there a standard logical XOR?
80 if ((code_ == LM_TC_TEX && char_ != '{' && char_ != '}') ||
81 (code_ == LM_TC_SPECIAL))
89 if (char_ == '}' && code_ == LM_TC_TEX && brace < 0)
90 lyxerr <<"Math warning: Unexpected closing brace.\n";
95 if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
100 void MathCharInset::writeNormal(std::ostream & os) const
103 cell(0).writeNormal(os);