]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathHull.cpp
Make undo action no-ops when the buffer is read-only
[lyx.git] / src / mathed / InsetMathHull.cpp
index fb52049f2ec00f84074c4c9b7b10ab2db996af59..8fd2bdd24a3ac49cd7ba6236efd634ee3ed342ce 100644 (file)
@@ -589,13 +589,9 @@ void InsetMathHull::drawBackground(PainterInfo & pi, int x, int y) const
                    dim.wid, dim.asc + dim.des, backgroundColor(pi));
                return;
        }
-       // If there are numbers, the margins around the (displayed)
-       // equation have to be cleared.
-       if (numberedType())
-               pi.pain.fillRectangle(pi.leftx, y - dim.asc,
-                               pi.rightx - pi.leftx, dim.height(), pi.background_color);
+
        pi.pain.fillRectangle(x + 1, y - dim.asc + 1, dim.wid - 2,
-                       dim.asc + dim.des - 1, pi.backgroundColor(this));
+                             dim.height() - 1, pi.backgroundColor(this));
 }
 
 
@@ -626,11 +622,6 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
        }
 
        // First draw the numbers
-       ColorCode color = pi.selected && lyxrc.use_system_colors
-                               ? Color_selectiontext : standardColor();
-       bool const really_change_color = pi.base.font.color() == Color_none;
-       Changer dummy0 = really_change_color ? pi.base.font.changeColor(color)
-               : noChange();
        if (numberedType()) {
                BufferParams::MathNumber const math_number = buffer().params().getMathNumber();
                for (row_type row = 0; row < nrows(); ++row) {
@@ -639,18 +630,37 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
                        Dimension dimnl;
                        mathed_string_dim(pi.base.font, nl, dimnl);
                        if (math_number == BufferParams::LEFT) {
+                               ColorCode const col = pi.selected_left
+                                       ? Color_selectiontext
+                                       : pi.base.font.color();
+                               Changer dummy0 = pi.base.font.changeColor(col);
                                if (dimnl.wid > x - pi.leftx)
                                        yy += rowinfo(row).descent + dimnl.asc;
+                               pi.pain.fillRectangle(pi.leftx, yy - dimnl.asc,
+                                       dimnl.width(), dimnl.height(),
+                                       pi.selected_left ? Color_selection : pi.background_color);
                                pi.draw(pi.leftx, yy, nl);
                        } else {
+                               ColorCode const col = pi.selected_right
+                                       ? Color_selectiontext
+                                       : pi.base.font.color();
+                               Changer dummy0 = pi.base.font.changeColor(col);
                                if (dimnl.wid > pi.rightx - x - dim.wid)
                                        yy += rowinfo(row).descent + dimnl.asc;
+                               pi.pain.fillRectangle(pi.rightx - dimnl.wid, yy - dimnl.asc,
+                                       dimnl.width(), dimnl.height(),
+                                       pi.selected_right ? Color_selection : pi.background_color);
                                pi.draw(pi.rightx - dimnl.wid, yy, nl);
                        }
                }
        }
 
        // Then the equations
+       ColorCode color = pi.selected && lyxrc.use_system_colors
+               ? Color_selectiontext : standardColor();
+       bool const really_change_color = pi.base.font.color() == Color_none;
+       Changer dummy0 = really_change_color ? pi.base.font.changeColor(color)
+               : noChange();
        Changer dummy1 = pi.base.changeFontSet(standardFont());
        Changer dummy2 = pi.base.font.changeStyle(display() ? DISPLAY_STYLE
                                                            : TEXT_STYLE);
@@ -978,7 +988,7 @@ bool InsetMathHull::outerDisplay() const
 }
 
 
-Inset::RowFlags InsetMathHull::rowFlags() const
+int InsetMathHull::rowFlags() const
 {
        switch (type_) {
        case hullUnknown:
@@ -2527,22 +2537,26 @@ void InsetMathHull::htmlize(HtmlStream & os) const
 // and we simply do not have that in InsetMathGrid.
 void InsetMathHull::mathmlize(MathMLStream & ms) const
 {
-       bool const havenumbers = haveNumbers();
-       bool const havetable = havenumbers || nrows() > 1 || ncols() > 1;
+       bool const havetable = haveNumbers() || nrows() > 1 || ncols() > 1;
 
     if (havetable) {
-        if (getType() == hullSimple)
-            ms << MTag("mtable");
-        else if (getType() >= hullAlign && getType() <= hullXXAlignAt)
-            ms << MTag("mtable", "displaystyle='true' columnalign='right left'");
-        else
-            ms << MTag("mtable", "displaystyle='true'");
+        if (getType() == hullSimple) {
+               ms << MTag("mtable");
+        } else if (getType() >= hullAlign && getType() <= hullXXAlignAt) {
+            string alignment;
+            for (col_type col = 0; col < ncols(); ++col) {
+                alignment += (col % 2) ? "left " : "right ";
+            }
+            ms << MTag("mtable", "displaystyle='true' columnalign='" + alignment + "'");
+           } else {
+               ms << MTag("mtable", "displaystyle='true'");
+        }
     }
 
        char const * const celltag = havetable ? "mtd" : "mrow";
        // FIXME There does not seem to be wide support at the moment
        // for mlabeledtr, so we have to use just mtr for now.
-       // char const * const rowtag = havenumbers ? "mlabeledtr" : "mtr";
+       // char const * const rowtag = haveNumbers() ? "mlabeledtr" : "mtr";
        char const * const rowtag = "mtr";
        for (row_type row = 0; row < nrows(); ++row) {
                if (havetable)
@@ -2553,12 +2567,12 @@ void InsetMathHull::mathmlize(MathMLStream & ms) const
                           << ETag(celltag);
                }
                // fleqn?
-               if (havenumbers) {
+               if (haveNumbers()) {
                        ms << MTag("mtd");
                        docstring const & num = numbers_[row];
                        if (!num.empty())
                                ms << MTagInline("mtext") << '(' << num << ')' << ETagInline("mtext");
-                 ms << ETag("mtd");
+                   ms << ETag("mtd");
                }
                if (havetable)
                        ms << ETag(rowtag);