]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_gridinset.C
make \newcommand{\bb}[1]{\mathbf{#1}} work for read/write/display.
[lyx.git] / src / mathed / math_gridinset.C
index ce2d94bee5782cdb510ee4fdd849ff2c74322062..d18713b0ec4a754cc2cdaf1acafc775a24ad1969 100644 (file)
@@ -90,6 +90,12 @@ MathGridInset::MathGridInset(col_type m, row_type n, char v, string const & h)
 }
 
 
+MathInset * MathGridInset::clone() const
+{
+       return new MathGridInset(*this);
+}
+
+
 MathInset::idx_type MathGridInset::index(row_type row, col_type col) const
 {
        return col + ncols() * row;
@@ -487,26 +493,20 @@ int MathGridInset::cellYOffset(idx_type idx) const
 }
 
 
-bool MathGridInset::idxUp(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxUp(idx_type & idx) const
 {
-       //return false;
        if (idx < ncols())
                return false;
-       int x = cellXOffset(idx) + xcell(idx).pos2x(pos);
        idx -= ncols();
-       pos = xcell(idx).x2pos(x - cellXOffset(idx));
        return true;
 }
 
        
-bool MathGridInset::idxDown(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxDown(idx_type & idx) const
 {
-       //return false;
        if (idx >= ncols() * (nrows() - 1))
                return false;
-       int x = cellXOffset(idx) + xcell(idx).pos2x(pos);
        idx += ncols();
-       pos = xcell(idx).x2pos(x - cellXOffset(idx));
        return true;
 }
        
@@ -543,7 +543,7 @@ bool MathGridInset::idxFirst(idx_type & idx, pos_type & pos) const
                        idx = (nrows() - 1) * ncols();
                        break;
                default: 
-                       idx = (nrows() / 2) * ncols();
+                       idx = ((nrows() - 1) / 2) * ncols();
        }
        pos = 0;
        return true;
@@ -560,7 +560,7 @@ bool MathGridInset::idxLast(idx_type & idx, pos_type & pos) const
                        idx = nargs() - 1;
                        break;
                default:
-                       idx = (nrows() / 2 + 1) * ncols() - 1;
+                       idx = ((nrows() - 1) / 2 + 1) * ncols() - 1;
        }
        pos = cell(idx).size();
        return true;