]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathSymbol.cpp
nullptr
[lyx.git] / src / mathed / InsetMathSymbol.cpp
index d354d016a5d0cce4f7e48f3e9fd42d90542e5cbb..291dabb3b9d037e85d1ce57b8ea69dfb7295abc6 100644 (file)
 
 #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))
 {}
 
 
@@ -58,16 +57,23 @@ docstring InsetMathSymbol::name() const
 }
 
 
+/// 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;
@@ -82,16 +88,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 +118,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() << ']';
@@ -177,7 +156,7 @@ void InsetMathSymbol::mathematica(MathematicaStream & os) const
 }
 
 
-void InsetMathSymbol::mathmlize(MathStream & ms) const
+void InsetMathSymbol::mathmlize(MathMLStream & ms) const
 {
        // FIXME We may need to do more interesting things
        // with MathMLtype.
@@ -226,7 +205,7 @@ void InsetMathSymbol::octave(OctaveStream & os) const
 }
 
 
-void InsetMathSymbol::write(WriteStream & os) const
+void InsetMathSymbol::write(TeXMathStream & os) const
 {
        unique_ptr<MathEnsurer> ensurer;
        if (currentMode() != TEXT_MODE)
@@ -242,6 +221,7 @@ void InsetMathSymbol::write(WriteStream & os) const
                return;
 
        os.pendingSpace(true);
+       writeLimits(os);
 }