3 #include "math_symbolinset.h"
4 #include "math_mathmlstream.h"
5 #include "math_streamstr.h"
6 #include "math_support.h"
7 #include "math_parser.h"
8 #include "LaTeXFeatures.h"
15 MathSymbolInset::MathSymbolInset(const latexkeys * l)
20 MathSymbolInset::MathSymbolInset(const char * name)
21 : sym_(in_word_set(name)), h_(0)
25 MathSymbolInset::MathSymbolInset(string const & name)
26 : sym_(in_word_set(name.c_str())), h_(0)
31 MathInset * MathSymbolInset::clone() const
33 return new MathSymbolInset(*this);
37 string MathSymbolInset::name() const
43 void MathSymbolInset::metrics(MathMetricsInfo & mi) const
45 //lyxerr << "metrics: symbol: '" << sym_->name
46 // << "' in font: '" << sym_->inset
47 // << "' drawn as: '" << sym_->draw
49 MathFontSetChanger dummy(mi.base, sym_->inset.c_str());
50 mathed_string_dim(mi.base.font, sym_->draw, ascent_, descent_, width_);
51 if (sym_->inset == "cmex") {
52 h_ = 4 * descent_ / 5;
58 scriptable_ = (mi.base.style == LM_ST_DISPLAY && sym_->inset == "cmex");
62 void MathSymbolInset::draw(MathPainterInfo & pi, int x, int y) const
64 //lyxerr << "metrics: symbol: '" << sym_->name
65 // << "' in font: '" << sym_->inset
66 // << "' drawn as: '" << sym_->draw
70 MathFontSetChanger dummy(pi.base, sym_->inset.c_str());
71 drawStr(pi, pi.base.font, x, y - h_, sym_->draw);
75 bool MathSymbolInset::isRelOp() const
77 return sym_->extra == "mathrel";
81 bool MathSymbolInset::isScriptable() const
87 bool MathSymbolInset::takesLimits() const
89 return sym_->inset == "cmex" || sym_->inset == "lyxboldsymb";
93 void MathSymbolInset::validate(LaTeXFeatures & features) const
95 if (sym_->inset == "msa" || sym_->inset == "msb")
96 features.require("amssymb");
100 void MathSymbolInset::normalize(NormalStream & os) const
102 os << "[symbol " << name() << "]";
106 void MathSymbolInset::maplize(MapleStream & os) const
108 if (name() == "cdot")
115 char const * MathMLtype(string const & s)
123 bool MathSymbolInset::match(MathInset * p) const
125 MathSymbolInset const * q = p->asSymbolInset();
126 return q && name() == q->name();
130 void MathSymbolInset::mathmlize(MathMLStream & os) const
132 char const * type = MathMLtype(sym_->extra);
133 os << '<' << type << "> ";
134 if (sym_->xmlname == "x") // unknown so far
138 os << " </" << type << '>';
142 void MathSymbolInset::octavize(OctaveStream & os) const
144 if (name() == "cdot")
151 void MathSymbolInset::write(WriteStream & os) const
153 os << '\\' << name() << ' ';
157 void MathSymbolInset::infoize(ostream & os) const
159 os << '\\' << name();