8 #include "math_symbolinset.h"
9 #include "math_mathmlstream.h"
10 #include "math_streamstr.h"
11 #include "math_support.h"
12 #include "math_parser.h"
13 #include "LaTeXFeatures.h"
17 MathSymbolInset::MathSymbolInset(const latexkeys * l)
22 MathSymbolInset::MathSymbolInset(const char * name)
23 : sym_(in_word_set(name)), h_(0)
27 MathSymbolInset::MathSymbolInset(string const & name)
28 : sym_(in_word_set(name.c_str())), h_(0)
33 MathInset * MathSymbolInset::clone() const
35 return new MathSymbolInset(*this);
39 string MathSymbolInset::name() const
45 void MathSymbolInset::metrics(MathMetricsInfo & mi) const
47 //lyxerr << "metrics: symbol: '" << sym_->name
48 // << "' in font: '" << sym_->inset
49 // << "' drawn as: '" << sym_->draw
51 MathFontSetChanger dummy(mi.base, sym_->inset.c_str());
52 mathed_string_dim(mi.base.font, sym_->draw, dim_);
53 // correct height for broken cmex and wasy font
54 if (sym_->inset == "cmex" || sym_->inset == "wasy") {
61 // seperate things a bit
65 if (mi.base.style == LM_ST_DISPLAY)
66 if (sym_->inset == "cmex" || sym_->extra == "funclim")
71 void MathSymbolInset::draw(MathPainterInfo & pi, int x, int y) const
73 //lyxerr << "metrics: symbol: '" << sym_->name
74 // << "' in font: '" << sym_->inset
75 // << "' drawn as: '" << sym_->draw
80 MathFontSetChanger dummy(pi.base, sym_->inset.c_str());
81 drawStr(pi, pi.base.font, x, y - h_, sym_->draw);
85 bool MathSymbolInset::isRelOp() const
87 return sym_->extra == "mathrel";
91 bool MathSymbolInset::isScriptable() const
97 bool MathSymbolInset::takesLimits() const
100 sym_->inset == "cmex" ||
101 sym_->inset == "lyxboldsymb" ||
102 sym_->extra == "funclim";
106 void MathSymbolInset::validate(LaTeXFeatures & features) const
108 if (sym_->inset == "msa" || sym_->inset == "msb")
109 features.require("amssymb");
113 void MathSymbolInset::normalize(NormalStream & os) const
115 os << "[symbol " << name() << "]";
119 void MathSymbolInset::maplize(MapleStream & os) const
121 if (name() == "cdot")
123 else if (name() == "infty")
129 void MathSymbolInset::mathematicize(MathematicaStream & os) const
131 if ( name() == "pi") { os << "Pi"; return;}
132 if ( name() == "infty") { os << "Infinity"; return;}
137 char const * MathMLtype(string const & s)
145 bool MathSymbolInset::match(MathAtom const & at) const
147 MathSymbolInset const * q = at->asSymbolInset();
148 return q && name() == q->name();
152 void MathSymbolInset::mathmlize(MathMLStream & os) const
154 char const * type = MathMLtype(sym_->extra);
155 os << '<' << type << "> ";
156 if (sym_->xmlname == "x") // unknown so far
160 os << " </" << type << '>';
164 void MathSymbolInset::octavize(OctaveStream & os) const
166 if (name() == "cdot")
173 void MathSymbolInset::write(WriteStream & os) const
175 os << '\\' << name();
176 os.pendingSpace(true);
180 void MathSymbolInset::infoize(std::ostream & os) const
182 os << "Symbol: " << name();