]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathMacro.cpp
Support the mathbbm font.
[lyx.git] / src / mathed / InsetMathMacro.cpp
index 3cabf6a818eea0136c9865e700da5cc1c999d0c2..144318130ae52bddf49208f234c6b78e2bd5f37d 100644 (file)
@@ -142,7 +142,7 @@ public:
        void afterDraw(PainterInfo const & pi) const
        {
                if (mathMacro_->editMetrics(pi.base.bv))
-                       pi.pain.enterMonochromeMode(Color_mathbg, Color_mathmacroblend);
+                       pi.pain.enterMonochromeMode(Color_mathmacroblend);
        }
        ///
        void metrics(MetricsInfo &, Dimension &) const {
@@ -371,6 +371,38 @@ bool InsetMathMacro::addToMathRow(MathRow & mrow, MetricsInfo & mi) const
        return has_contents;
 }
 
+/// Whether the inset allows \(no)limits
+bool InsetMathMacro::allowsLimitsChange() const
+{
+       // similar to the code in mathClass(), except that we search for
+       // the right-side class.
+       MathClass mc = MC_UNKNOWN;
+       if (MacroData const * m = macroBackup()) {
+               // If it is a global macro and is defined explicitly
+               if (m->symbol())
+                       mc = string_to_class(m->symbol()->extra);
+       }
+       // Otherwise guess from the expanded macro
+       if (mc == MC_UNKNOWN)
+               mc = d->expanded_.lastMathClass();
+
+       return mc == MC_OP;
+}
+
+
+Limits InsetMathMacro::defaultLimits() const
+{
+       if (d->expanded_.empty())
+               return NO_LIMITS;
+       // Guess from the expanded macro
+       InsetMath const * in = d->expanded_.back().nucleus();
+       Limits const lim = in->limits() == AUTO_LIMITS
+               ? in->defaultLimits() : in->limits();
+       LATTEST(lim != AUTO_LIMITS);
+       return lim;
+}
+
+
 void InsetMathMacro::beforeMetrics() const
 {
        d->macro_->lock();
@@ -386,7 +418,7 @@ void InsetMathMacro::afterMetrics() const
 void InsetMathMacro::beforeDraw(PainterInfo const & pi) const
 {
        if (d->editing_[pi.base.bv])
-               pi.pain.enterMonochromeMode(Color_mathbg, Color_mathmacroblend);
+               pi.pain.enterMonochromeMode(Color_mathmacroblend);
 }
 
 
@@ -744,7 +776,7 @@ void InsetMathMacro::draw(PainterInfo & pi, int x, int y) const
                        pi.pain.text(x, y, from_ascii(":"), labelFont);
                        x += strw2;
 
-                       // draw paramter
+                       // draw parameter
                        cell(i).draw(pi, x, y);
 
                        // next line
@@ -1155,6 +1187,9 @@ void InsetMathMacro::write(WriteStream & os) const
        // add space if there was no argument
        if (first)
                os.pendingSpace(true);
+
+       // write \(no)limits modifiers if relevant
+       writeLimits(os);
 }
 
 
@@ -1181,7 +1216,7 @@ void InsetMathMacro::mathmlize(MathStream & ms) const
        // macro_ is 0 if this is an unknown macro
        LATTEST(d->macro_ || d->displayMode_ != DISPLAY_NORMAL);
        if (d->macro_) {
-               docstring const xmlname = d->macro_->xmlname();
+               docstring const xmlname = (ms.xmlMode()) ? d->macro_->xmlname() : d->macro_->htmlname();
                if (!xmlname.empty()) {
                        char const * type = d->macro_->MathMLtype();
                        ms << "<" << from_ascii(ms.namespacedTag(type)) << ">"
@@ -1203,7 +1238,7 @@ void InsetMathMacro::htmlize(HtmlStream & os) const
        // macro_ is 0 if this is an unknown macro
        LATTEST(d->macro_ || d->displayMode_ != DISPLAY_NORMAL);
        if (d->macro_) {
-               docstring const xmlname = d->macro_->xmlname();
+               docstring const xmlname = d->macro_->htmlname();
                if (!xmlname.empty()) {
                        os << ' ' << xmlname << ' ';
                        return;