9 #include "math_charinset.h"
12 #include "support/LOstream.h"
13 #include "math_support.h"
14 #include "math_parser.h"
16 #include "math_mathmlstream.h"
17 #include "LaTeXFeatures.h"
23 MathCharInset::MathCharInset(char c)
24 : char_(c), code_(nativeCode(c))
26 //lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
30 MathCharInset::MathCharInset(char c, MathTextCodes t)
31 : char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t)
33 //lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
37 MathTextCodes MathCharInset::nativeCode(char c)
41 //if (strchr("0123456789;:!|[]().,?+/-*<>=", c)
46 MathInset * MathCharInset::clone() const
48 return new MathCharInset(*this);
52 void MathCharInset::metrics(MathMetricsInfo const & mi) const
55 mathed_char_dim(code_, mi_, char_, ascent_, descent_, width_);
59 void MathCharInset::draw(Painter & pain, int x, int y) const
61 //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
62 drawChar(pain, code_, mi_, x, y, char_);
66 void MathCharInset::writeHeader(ostream & os) const
68 if (math_font_name(code_))
69 os << '\\' << math_font_name(code_) << '{';
73 void MathCharInset::writeTrailer(ostream & os) const
75 if (math_font_name(code_))
80 void MathCharInset::writeRaw(ostream & os) const
86 void MathCharInset::write(WriteStream & os) const
90 writeTrailer(os.os());
94 void MathCharInset::normalize(NormalStream & os) const
96 os << "[char " << char_ << " " << "mathalpha" << "]";
100 bool MathCharInset::isRelOp() const
102 return char_ == '=' || char_ == '<' || char_ == '>';
106 void MathCharInset::handleFont(MathTextCodes t)
108 code_ = (code_ == t) ? LM_TC_VAR : t;
112 void MathCharInset::validate(LaTeXFeatures & features) const
114 // Make sure amssymb is put in preamble if Blackboard Bold or
116 if ((code_ == LM_TC_BB) || (code_ == LM_TC_EUFRAK))
117 features.require("amssymb");
121 bool MathCharInset::match(MathInset * p) const
123 MathCharInset const * q = p->asCharInset();
124 return q && char_ == q->char_ && code_ == q->code_;