1 #include "math_symbolinset.h"
2 #include "math_parser.h"
3 #include "math_mathmlstream.h"
4 #include "math_support.h"
8 MathSymbolInset::MathSymbolInset(const latexkeys * l)
13 MathInset * MathSymbolInset::clone() const
15 return new MathSymbolInset(*this);
19 MathTextCodes MathSymbolInset::code() const
40 MathTextCodes MathSymbolInset::code2() const
42 if (sym_->token == LM_TK_CMEX)
43 return LM_TC_BOLDSYMB;
49 string MathSymbolInset::name() const
55 void MathSymbolInset::metrics(MathMetricsInfo const & mi) const
58 MathTextCodes c = code();
59 if (sym_->latex_font_id > 0 && math_font_available(c)) {
60 mathed_char_dim(c, mi_, sym_->latex_font_id, ascent_, descent_, width_);
61 if (c == LM_TC_CMEX) {
62 h_ = 4 * descent_ / 5;
67 if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
68 mathed_char_dim(code2(), mi_, sym_->id, ascent_, descent_, width_);
70 mathed_string_dim(LM_TC_TEX, mi_, sym_->name, ascent_, descent_, width_);
73 width_ += mathed_char_width(LM_TC_TEX, mi_, 'I');
77 void MathSymbolInset::draw(Painter & pain, int x, int y) const
80 x += mathed_char_width(LM_TC_TEX, mi_, 'I') / 2;
81 MathTextCodes Code = code();
82 if (sym_->latex_font_id > 0 && math_font_available(Code))
83 drawChar(pain, Code, mi_, x, y - h_, sym_->latex_font_id);
84 else if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
85 drawChar(pain, code2(), mi_, x, y, sym_->id);
87 drawStr(pain, LM_TC_TEX, mi_, x, y, sym_->name);
91 bool MathSymbolInset::isRelOp() const
93 return sym_->type == LMB_RELATION;
97 bool MathSymbolInset::isScriptable() const
99 return mi_.style == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
103 bool MathSymbolInset::takesLimits() const
105 return sym_->token == LM_TK_CMEX;
109 void MathSymbolInset::normalize(NormalStream & os) const
111 os << "[symbol " << name().c_str() << "]";
115 void MathSymbolInset::maplize(MapleStream & os) const
117 if (name() == "cdot")
120 os << name().c_str();
124 void MathSymbolInset::mathmlize(MathMLStream & os) const
126 os << name().c_str();
130 void MathSymbolInset::octavize(OctaveStream & os) const
132 if (name() == "cdot")
135 os << name().c_str();
139 void MathSymbolInset::write(WriteStream & os) const
141 os << '\\' << name().c_str() << ' ';