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, dim_);
51 // correct height for broken cmex and wasy font
52 if (sym_->inset == "cmex" || sym_->inset == "wasy") {
59 // seperate things a bit
63 if (mi.base.style == LM_ST_DISPLAY)
64 if (sym_->inset == "cmex" || sym_->extra == "funclim")
69 void MathSymbolInset::draw(MathPainterInfo & pi, int x, int y) const
71 //lyxerr << "metrics: symbol: '" << sym_->name
72 // << "' in font: '" << sym_->inset
73 // << "' drawn as: '" << sym_->draw
78 MathFontSetChanger dummy(pi.base, sym_->inset.c_str());
79 drawStr(pi, pi.base.font, x, y - h_, sym_->draw);
83 bool MathSymbolInset::isRelOp() const
85 return sym_->extra == "mathrel";
89 bool MathSymbolInset::isScriptable() const
95 bool MathSymbolInset::takesLimits() const
98 sym_->inset == "cmex" ||
99 sym_->inset == "lyxboldsymb" ||
100 sym_->extra == "funclim";
104 void MathSymbolInset::validate(LaTeXFeatures & features) const
106 if (sym_->inset == "msa" || sym_->inset == "msb")
107 features.require("amssymb");
111 void MathSymbolInset::normalize(NormalStream & os) const
113 os << "[symbol " << name() << "]";
117 void MathSymbolInset::maplize(MapleStream & os) const
119 if (name() == "cdot")
121 else if (name() == "infty")
127 void MathSymbolInset::mathematicize(MathematicaStream & os) const
129 if ( name() == "pi") { os << "Pi"; return;}
130 if ( name() == "infty") { os << "Infinity"; return;}
135 char const * MathMLtype(string const & s)
143 bool MathSymbolInset::match(MathAtom const & at) const
145 MathSymbolInset const * q = at->asSymbolInset();
146 return q && name() == q->name();
150 void MathSymbolInset::mathmlize(MathMLStream & os) const
152 char const * type = MathMLtype(sym_->extra);
153 os << '<' << type << "> ";
154 if (sym_->xmlname == "x") // unknown so far
158 os << " </" << type << '>';
162 void MathSymbolInset::octavize(OctaveStream & os) const
164 if (name() == "cdot")
171 void MathSymbolInset::write(WriteStream & os) const
173 os << '\\' << name();
174 os.pendingSpace(true);
178 void MathSymbolInset::infoize(ostream & os) const
180 os << "Symbol: " << name();