]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathGrid.cpp
* src/frontends/controllers/Dialog.{cpp,h}:
[lyx.git] / src / mathed / InsetMathGrid.cpp
index 53354fa623ae7b5c8baff7491b4e5dcd7ead18c3..a3b680dd34d21949e936d4009241ff5a29c3d10c 100644 (file)
 #include "BufferView.h"
 #include "CutAndPaste.h"
 #include "FuncStatus.h"
-#include "LColor.h"
-#include "cursor.h"
+#include "Color.h"
+#include "Cursor.h"
 #include "debug.h"
-#include "funcrequest.h"
+#include "FuncRequest.h"
 #include "gettext.h"
-#include "undo.h"
+#include "Undo.h"
 
 #include "frontends/Clipboard.h"
 #include "frontends/Painter.h"
 
-#include "insets/MailInset.h"
-
 #include "support/lstrings.h"
 
 #include <sstream>
@@ -50,31 +48,6 @@ using std::istream;
 using std::istringstream;
 using std::vector;
 
-class GridInsetMailer : public MailInset {
-public:
-       GridInsetMailer(InsetMathGrid & inset) : inset_(inset) {}
-       ///
-       virtual string const & name() const
-       {
-               static string const theName = "tabular";
-               return theName;
-       }
-       ///
-       virtual string const inset2string(Buffer const &) const
-       {
-               odocstringstream data;
-               //data << name() << " active_cell " << inset.getActCell() << '\n';
-               data << from_utf8(name()) << " active_cell " << 0 << '\n';
-               WriteStream ws(data);
-               inset_.write(ws);
-               return to_utf8(data.str());
-       }
-
-protected:
-       InsetBase & inset() const { return inset_; }
-       InsetMathGrid & inset_;
-};
-
 
 namespace {
 
@@ -184,9 +157,9 @@ InsetMathGrid::InsetMathGrid(col_type m, row_type n, char v, docstring const & h
 }
 
 
-auto_ptr<InsetBase> InsetMathGrid::doClone() const
+auto_ptr<Inset> InsetMathGrid::doClone() const
 {
-       return auto_ptr<InsetBase>(new InsetMathGrid(*this));
+       return auto_ptr<Inset>(new InsetMathGrid(*this));
 }
 
 
@@ -311,13 +284,13 @@ InsetMathGrid::row_type InsetMathGrid::row(idx_type idx) const
 }
 
 
-void InsetMathGrid::vcrskip(LyXLength const & crskip, row_type row)
+void InsetMathGrid::vcrskip(Length const & crskip, row_type row)
 {
        rowinfo_[row].crskip_ = crskip;
 }
 
 
-LyXLength InsetMathGrid::vcrskip(row_type row) const
+Length InsetMathGrid::vcrskip(row_type row) const
 {
        return rowinfo_[row].crskip_;
 }
@@ -333,7 +306,7 @@ void InsetMathGrid::metrics(MetricsInfo & mi) const
                int asc  = 0;
                int desc = 0;
                for (col_type col = 0; col < ncols(); ++col) {
-                       MathArray const & c = cell(index(row, col));
+                       MathData const & c = cell(index(row, col));
                        asc  = max(asc,  c.ascent());
                        desc = max(desc, c.descent());
                }
@@ -492,7 +465,7 @@ void InsetMathGrid::drawWithMargin(PainterInfo & pi, int x, int y,
                                - i * hlinesep() - hlinesep()/2 - rowsep()/2;
                        pi.pain.line(x + lmargin + 1, yy,
                                     x + dim_.width() - rmargin - 1, yy,
-                                    LColor::foreground);
+                                    Color::foreground);
                }
 
        for (col_type col = 0; col <= ncols(); ++col)
@@ -501,7 +474,7 @@ void InsetMathGrid::drawWithMargin(PainterInfo & pi, int x, int y,
                                - i * vlinesep() - vlinesep()/2 - colsep()/2;
                        pi.pain.line(xx, y - dim_.ascent() + 1,
                                     xx, y + dim_.descent() - 1,
-                                    LColor::foreground);
+                                    Color::foreground);
                }
        drawMarkers2(pi, x, y);
 }
@@ -519,7 +492,7 @@ void InsetMathGrid::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
                int asc  = 0;
                int desc = 0;
                for (col_type col = 0; col < ncols(); ++col) {
-                       MathArray const & c = cell(index(row, col));
+                       MathData const & c = cell(index(row, col));
                        asc  = max(asc,  c.ascent());
                        desc = max(desc, c.descent());
                }
@@ -614,7 +587,7 @@ docstring InsetMathGrid::eolString(row_type row, bool emptyline, bool fragile) c
 
        // make sure an upcoming '[' does not break anything
        if (row + 1 < nrows()) {
-               MathArray const & c = cell(index(row + 1, 0));
+               MathData const & c = cell(index(row + 1, 0));
                if (c.size() && c.front()->getChar() == '[')
                        //eol += "[0pt]";
                        eol += "{}";
@@ -640,7 +613,7 @@ void InsetMathGrid::addRow(row_type row)
 {
        rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
        cells_.insert
-               (cells_.begin() + (row + 1) * ncols(), ncols(), MathArray());
+               (cells_.begin() + (row + 1) * ncols(), ncols(), MathData());
        cellinfo_.insert
                (cellinfo_.begin() + (row + 1) * ncols(), ncols(), CellInfo());
 }
@@ -649,7 +622,7 @@ void InsetMathGrid::addRow(row_type row)
 void InsetMathGrid::appendRow()
 {
        rowinfo_.push_back(RowInfo());
-       //cells_.insert(cells_.end(), ncols(), MathArray());
+       //cells_.insert(cells_.end(), ncols(), MathData());
        for (col_type col = 0; col < ncols(); ++col) {
                cells_.push_back(cells_type::value_type());
                cellinfo_.push_back(CellInfo());
@@ -772,7 +745,7 @@ int InsetMathGrid::cellYOffset(idx_type idx) const
 }
 
 
-bool InsetMathGrid::idxUpDown(LCursor & cur, bool up) const
+bool InsetMathGrid::idxUpDown(Cursor & cur, bool up) const
 {
        if (up) {
                if (cur.row() == 0)
@@ -788,7 +761,7 @@ bool InsetMathGrid::idxUpDown(LCursor & cur, bool up) const
 }
 
 
-bool InsetMathGrid::idxLeft(LCursor & cur) const
+bool InsetMathGrid::idxLeft(Cursor & cur) const
 {
        // leave matrix if on the left hand edge
        if (cur.col() == 0)
@@ -799,7 +772,7 @@ bool InsetMathGrid::idxLeft(LCursor & cur) const
 }
 
 
-bool InsetMathGrid::idxRight(LCursor & cur) const
+bool InsetMathGrid::idxRight(Cursor & cur) const
 {
        // leave matrix if on the right hand edge
        if (cur.col() + 1 == ncols())
@@ -810,7 +783,7 @@ bool InsetMathGrid::idxRight(LCursor & cur) const
 }
 
 
-bool InsetMathGrid::idxFirst(LCursor & cur) const
+bool InsetMathGrid::idxFirst(Cursor & cur) const
 {
        switch (v_align_) {
                case 't':
@@ -827,7 +800,7 @@ bool InsetMathGrid::idxFirst(LCursor & cur) const
 }
 
 
-bool InsetMathGrid::idxLast(LCursor & cur) const
+bool InsetMathGrid::idxLast(Cursor & cur) const
 {
        switch (v_align_) {
                case 't':
@@ -1012,11 +985,11 @@ int InsetMathGrid::border() const
 }
 
 
-void InsetMathGrid::splitCell(LCursor & cur)
+void InsetMathGrid::splitCell(Cursor & cur)
 {
        if (cur.idx() == cur.lastidx())
                return;
-       MathArray ar = cur.cell();
+       MathData ar = cur.cell();
        ar.erase(0, cur.pos());
        cur.cell().erase(cur.pos(), cur.lastpos());
        ++cur.idx();
@@ -1025,23 +998,11 @@ void InsetMathGrid::splitCell(LCursor & cur)
 }
 
 
-void InsetMathGrid::doDispatch(LCursor & cur, FuncRequest & cmd)
+void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        //lyxerr << "*** InsetMathGrid: request: " << cmd << endl;
        switch (cmd.action) {
 
-       case LFUN_MOUSE_RELEASE:
-               //if (cmd.button() == mouse_button::button3) {
-               //      GridInsetMailer(*this).showDialog();
-               //      return DispatchResult(true, true);
-               //}
-               InsetMathNest::doDispatch(cur, cmd);
-               break;
-
-       case LFUN_INSET_DIALOG_UPDATE:
-               GridInsetMailer(*this).updateDialog(&cur.bv());
-               break;
-
        // insert file functions
        case LFUN_LINE_DELETE:
                // FIXME: We use recordUndoInset when a change reflects more
@@ -1247,7 +1208,6 @@ void InsetMathGrid::doDispatch(LCursor & cur, FuncRequest & cmd)
                                        cell(i).append(grid.cell(grid.index(r, c)));
                }
                cur.clearSelection(); // bug 393
-               cur.bv().switchKeyMap();
                finishUndo();
                break;
        }
@@ -1301,7 +1261,7 @@ void InsetMathGrid::doDispatch(LCursor & cur, FuncRequest & cmd)
 }
 
 
-bool InsetMathGrid::getStatus(LCursor & cur, FuncRequest const & cmd,
+bool InsetMathGrid::getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & status) const
 {
        switch (cmd.action) {