#include "support/debug.h"
#include "support/docstream.h"
-#include "support/lyxlib.h"
#include "support/textutils.h"
#include "support/unique_ptr.h"
+using namespace std;
namespace lyx {
InsetMathSymbol::InsetMathSymbol(latexkeys const * l)
- : sym_(l), h_(0), kerning_(0), scriptable_(false)
+ : sym_(l)
{}
InsetMathSymbol::InsetMathSymbol(char const * name)
- : sym_(in_word_set(from_ascii(name))), h_(0),
- kerning_(0), scriptable_(false)
+ : sym_(in_word_set(from_ascii(name)))
{}
InsetMathSymbol::InsetMathSymbol(docstring const & name)
- : sym_(in_word_set(name)), h_(0), kerning_(0), scriptable_(false)
+ : sym_(in_word_set(name))
{}
}
+/// The default limits value
+Limits InsetMathSymbol::defaultLimits(bool display) const
+{
+ if (allowsLimitsChange() && sym_->extra != "func" && display)
+ return LIMITS;
+ else
+ return NO_LIMITS;
+}
+
+
void InsetMathSymbol::metrics(MetricsInfo & mi, Dimension & dim) const
{
- mathedSymbolDim(mi.base, dim, sym_);
+ // set dim
+ // FIXME: this should depend on BufferView
+ // set negative kerning_ so that a subscript is moved leftward
+ kerning_ = -mathedSymbolDim(mi.base, dim, sym_);
if (sym_->draw != sym_->name) {
- // set dim
- // FIXME: this should depend on BufferView
- // set kerning_
- kerning_ = mathed_char_kerning(mi.base.font,
- mathedSymbol(mi.base, sym_).back());
-
// align character vertically
// FIXME: this should depend on BufferView
h_ = 0;
dim.asc += h_;
dim.des -= h_;
}
-
- // set scriptable_
- //FIXME: get rid of that? Only "funclim" probably, along with
- // class==MC_OP. The issue is to implement \limits properly.
- scriptable_ = false;
- if (mi.base.font.style() == DISPLAY_STYLE)
- if (sym_->inset == "cmex" || sym_->inset == "esint" ||
- sym_->extra == "funclim" ||
- (sym_->inset == "stmry" && sym_->extra == "mathop"))
- scriptable_ = true;
}
}
-bool InsetMathSymbol::isScriptable() const
-{
- return scriptable_;
-}
-
-
-bool InsetMathSymbol::takesLimits() const
-{
- return
- sym_->inset == "cmex" ||
- sym_->inset == "lyxboldsymb" ||
- sym_->inset == "esint" ||
- sym_->extra == "funclim" ||
- (sym_->inset == "stmry" && sym_->extra == "mathop");
-}
-
-
void InsetMathSymbol::normalize(NormalStream & os) const
{
os << "[symbol " << name() << ']';
}
-void InsetMathSymbol::mathmlize(MathStream & ms) const
+void InsetMathSymbol::mathmlize(MathMLStream & ms) const
{
// FIXME We may need to do more interesting things
// with MathMLtype.
}
-void InsetMathSymbol::write(WriteStream & os) const
+void InsetMathSymbol::write(TeXMathStream & os) const
{
unique_ptr<MathEnsurer> ensurer;
if (currentMode() != TEXT_MODE)
return;
os.pendingSpace(true);
+ writeLimits(os);
}