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"
20 MathCharInset::MathCharInset(char c)
21 : char_(c), code_(nativeCode(c))
23 //lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
27 MathCharInset::MathCharInset(char c, MathTextCodes t)
28 : char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t)
30 //lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
34 MathTextCodes MathCharInset::nativeCode(char c)
38 //if (strchr("0123456789;:!|[]().,?+/-*<>=", c)
43 MathInset * MathCharInset::clone() const
45 return new MathCharInset(*this);
49 void MathCharInset::metrics(MathMetricsInfo const & mi) const
52 mathed_char_dim(code_, mi_, char_, ascent_, descent_, width_);
56 void MathCharInset::draw(Painter & pain, int x, int y) const
58 //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
59 drawChar(pain, code_, mi_, x, y, char_);
63 void MathCharInset::writeHeader(std::ostream & os) const
65 if (math_font_name(code_))
66 os << '\\' << math_font_name(code_) << '{';
70 void MathCharInset::writeTrailer(std::ostream & os) const
72 if (math_font_name(code_))
77 void MathCharInset::writeRaw(std::ostream & os) const
83 void MathCharInset::write(WriteStream & os) const
87 writeTrailer(os.os());
91 void MathCharInset::normalize(NormalStream & os) const
93 os << "[char " << char_ << " " << "mathalpha" << "]";
97 bool MathCharInset::isRelOp() const
99 return char_ == '=' || char_ == '<' || char_ == '>';
103 void MathCharInset::handleFont(MathTextCodes t)
105 code_ = (code_ == t) ? LM_TC_VAR : t;
109 void MathCharInset::validate(LaTeXFeatures & features) const
111 // Make sure amssymb is put in preamble if Blackboard Bold or
113 if ( (code_ == LM_TC_BB) || (code_ == LM_TC_EUFRAK) )
114 features.require("amssymb");
118 bool MathCharInset::match(MathInset * p) const
120 MathCharInset const * q = p->asCharInset();
121 return q && char_ == q->char_ && code_ == q->code_;