1 #include "math_symbolinset.h"
2 #include "math_parser.h"
4 #include "support/LOstream.h"
9 MathSymbolInset::MathSymbolInset(const latexkeys * l)
13 MathInset * MathSymbolInset::clone() const
15 return new MathSymbolInset(*this);
19 void MathSymbolInset::write(MathWriteInfo & os) const
21 os << '\\' << sym_->name << ' ';
25 void MathSymbolInset::writeNormal(ostream & os) const
27 os << "[" << sym_->name << "] ";
31 MathTextCodes MathSymbolInset::code() const
52 MathTextCodes MathSymbolInset::code2() const
54 if (sym_->token == LM_TK_CMEX)
55 return LM_TC_BOLDSYMB;
61 void MathSymbolInset::metrics(MathMetricsInfo const & st) const
64 MathTextCodes Code = code();
65 if (sym_->latex_font_id > 0 && math_font_available(Code)) {
66 mathed_char_dim(Code, size(), sym_->latex_font_id,
67 ascent_, descent_, width_);
68 if (Code == LM_TC_CMEX) {
76 if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
77 mathed_char_dim(code2(), size(), sym_->id, ascent_, descent_, width_);
79 mathed_string_dim(LM_TC_TEX, size(), sym_->name, ascent_, descent_, width_);
83 void MathSymbolInset::draw(Painter & pain, int x, int y) const
87 MathTextCodes Code = code();
88 if (sym_->latex_font_id > 0 && math_font_available(Code))
89 drawChar(pain, Code, size(), x, y - h_, sym_->latex_font_id);
90 else if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
91 drawChar(pain, code2(), size(), x, y, sym_->id);
93 drawStr(pain, LM_TC_TEX, size(), x, y, sym_->name);
97 bool MathSymbolInset::isRelOp() const
99 return sym_->type == LMB_RELATION;
103 bool MathSymbolInset::isScriptable() const
105 return size() == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
109 bool MathSymbolInset::takesLimits() const
111 return sym_->token == LM_TK_CMEX;