]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_gridinset.C
Make Helge happy: no more crash on arrow up/down in math macro
[lyx.git] / src / mathed / math_gridinset.C
index a07aaf39a0f4bc83a90f30a511d6ec9abc555f8b..566b9e6473158818e347012f5b22b2b3c92d80b0 100644 (file)
@@ -478,22 +478,29 @@ void MathGridInset::metrics(MetricsInfo & mi, Dimension & dim) const
 
 
 void MathGridInset::draw(PainterInfo & pi, int x, int y) const
+{
+       drawWithMargin(pi, x, y, 0, 0);
+}
+
+void MathGridInset::drawWithMargin(PainterInfo & pi, int x, int y, 
+       int lmargin, int rmargin) const
 {
        for (idx_type idx = 0; idx < nargs(); ++idx)
-               cell(idx).draw(pi, x + cellXOffset(idx), y + cellYOffset(idx));
+               cell(idx).draw(pi, x + lmargin + cellXOffset(idx), 
+                       y + cellYOffset(idx));
 
        for (row_type row = 0; row <= nrows(); ++row)
                for (unsigned int i = 0; i < rowinfo_[row].lines_; ++i) {
                        int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_
                                - i * hlinesep() - hlinesep()/2 - rowsep()/2;
-                       pi.pain.line(x + 1, yy,
-                                    x + dim_.width() - 1, yy,
+                       pi.pain.line(x + lmargin + 1, yy,
+                                    x + dim_.width() - rmargin - 1, yy,
                                     LColor::foreground);
                }
 
        for (col_type col = 0; col <= ncols(); ++col)
                for (unsigned int i = 0; i < colinfo_[col].lines_; ++i) {
-                       int xx = x + colinfo_[col].offset_
+                       int xx = x + lmargin + colinfo_[col].offset_
                                - i * vlinesep() - vlinesep()/2 - colsep()/2;
                        pi.pain.line(xx, y - dim_.ascent() + 1,
                                     xx, y + dim_.descent() - 1,
@@ -1237,9 +1244,7 @@ bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd,
 {
        switch (cmd.action) {
        case LFUN_TABULAR_FEATURE: {
-               istringstream is(cmd.argument);
-               string s;
-               is >> s;
+               string const s = cmd.argument;
                if (nrows() <= 1 && (s == "delete-row" || s == "swap-row")) {
                        flag.enabled(false);
                        flag.message(N_("Only one row"));
@@ -1306,6 +1311,9 @@ bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd,
 #endif
                return true;
        }
+       case LFUN_CELL_SPLIT:
+               flag.enabled(true);
+               return true;
        default:
                return MathNestInset::getStatus(cur, cmd, flag);
        }