]> git.lyx.org Git - features.git/blobdiff - src/mathed/InsetMathSymbol.cpp
Implement properly \limits and \nolimits
[features.git] / src / mathed / InsetMathSymbol.cpp
index d354d016a5d0cce4f7e48f3e9fd42d90542e5cbb..276fab9ddcc8918836bdc3ab9725f5105fae1132 100644 (file)
 #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))
 {}
 
 
@@ -58,6 +58,14 @@ docstring InsetMathSymbol::name() const
 }
 
 
+/// The default limits value
+Limits InsetMathSymbol::defaultLimits() const
+{
+       return (allowsLimitsChange() && sym_->extra != "func")
+                       ? LIMITS : NO_LIMITS;
+}
+
+
 void InsetMathSymbol::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        mathedSymbolDim(mi.base, dim, sym_);
@@ -82,16 +90,6 @@ void InsetMathSymbol::metrics(MetricsInfo & mi, Dimension & dim) const
                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;
 }
 
 
@@ -122,23 +120,6 @@ MathClass InsetMathSymbol::mathClass() const
 }
 
 
-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() << ']';
@@ -242,6 +223,7 @@ void InsetMathSymbol::write(WriteStream & os) const
                return;
 
        os.pendingSpace(true);
+       writeLimits(os);
 }