]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_gridinset.C
Georg Baum's vspace change
[lyx.git] / src / mathed / math_gridinset.C
index bec0cf3b21fb2f36ac31650cdef467b9b3bedcaa..d16f82776cfd17ed3badbd83fc1ff4662a07013c 100644 (file)
 #include <config.h>
 
 #include "math_gridinset.h"
+#include "math_data.h"
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
+#include "dispatchresult.h"
+#include "debug.h"
 #include "funcrequest.h"
+#include "LColor.h"
 #include "frontends/Painter.h"
-#include "debug.h"
-#include "Lsstream.h"
-
+#include "support/std_sstream.h"
 
 #include "insets/mailinset.h"
 
-using std::swap;
+using std::endl;
 using std::max;
 using std::min;
-using std::vector;
-using std::istream;
+using std::swap;
+
+using std::string;
 using std::auto_ptr;
-using std::endl;
+using std::istream;
+using std::istringstream;
+using std::ostringstream;
+using std::vector;
 
 
 class GridInsetMailer : public MailInset {
@@ -47,7 +53,7 @@ public:
                data << name() << " active_cell " << 0 << '\n';
                WriteStream ws(data);
                inset_.write(ws);
-               return STRCONV(data.str());
+               return data.str();
        }
 
 protected:
@@ -466,14 +472,18 @@ void MathGridInset::draw(PainterInfo & pi, int x, int y) const
                for (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 + 1, yy,
+                                    x + dim_.width() - 1, yy,
+                                    LColor::foreground);
                }
 
        for (col_type col = 0; col <= ncols(); ++col)
                for (int i = 0; i < colinfo_[col].lines_; ++i) {
                        int xx = x + colinfo_[col].offset_
                                - i * vlinesep() - vlinesep()/2 - colsep()/2;
-                       pi.pain.line(xx, y - dim_.ascent() + 1, xx, y + dim_.descent() - 1);
+                       pi.pain.line(xx, y - dim_.ascent() + 1,
+                                    xx, y + dim_.descent() - 1,
+                                    LColor::foreground);
                }
 }
 
@@ -1032,21 +1042,21 @@ void MathGridInset::splitCell(idx_type & idx, pos_type & pos)
 }
 
 
-dispatch_result MathGridInset::dispatch
-       (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
+DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
+       idx_type & idx, pos_type & pos)
 {
        switch (cmd.action) {
 
                case LFUN_MOUSE_RELEASE:
                        //if (cmd.button() == mouse_button::button3) {
                        //      GridInsetMailer(*this).showDialog();
-                       //      return DISPATCHED;
+                       //      return DispatchResult(true, true);
                        //}
-                       return UNDISPATCHED;
+                       return DispatchResult(false);
 
                case LFUN_INSET_DIALOG_UPDATE:
                        GridInsetMailer(*this).updateDialog(cmd.view());
-                       return UNDISPATCHED;
+                       return DispatchResult(false);
 
                // insert file functions
                case LFUN_DELETE_LINE_FORWARD:
@@ -1062,12 +1072,12 @@ dispatch_result MathGridInset::dispatch
                                idx = nargs() - 1;
                        if (pos > cell(idx).size())
                                pos = cell(idx).size();
-                       return DISPATCHED_POP;
+                       return DispatchResult(true, FINISHED);
 
                case LFUN_CELL_SPLIT:
                        //recordUndo(bv, Undo::ATOMIC);
                        splitCell(idx, pos);
-                       return DISPATCHED_POP;
+                       return DispatchResult(true, FINISHED);
 
                case LFUN_BREAKLINE: {
                        //recordUndo(bv, Undo::INSERT);
@@ -1086,12 +1096,12 @@ dispatch_result MathGridInset::dispatch
                        pos = cell(idx).size();
 
                        //mathcursor->normalize();
-                       return DISPATCHED_POP;
+                       return DispatchResult(true, FINISHED);
                }
 
                case LFUN_TABULAR_FEATURE: {
                        //lyxerr << "handling tabular-feature " << cmd.argument << endl;
-                       istringstream is(STRCONV(cmd.argument));
+                       istringstream is(cmd.argument);
                        string s;
                        is >> s;
                        if (s == "valign-top")
@@ -1141,9 +1151,9 @@ dispatch_result MathGridInset::dispatch
                        else if (s == "swap-column")
                                swapCol(col(idx));
                        else
-                               return UNDISPATCHED;
-                       lyxerr << "returning DISPATCHED_POP" << endl;
-                       return DISPATCHED_POP;
+                               return DispatchResult(false);
+                       lyxerr << "returning DispatchResult(true, FINISHED)" << endl;
+                       return DispatchResult(true, FINISHED);
                }
 
                case LFUN_PASTE: {
@@ -1161,7 +1171,7 @@ dispatch_result MathGridInset::dispatch
                                for (row_type r = 0; r < numrows; ++r) {
                                        for (col_type c = 0; c < numcols; ++c) {
                                                idx_type i = index(r + row(idx), c + col(idx));
-                                               cell(i).append(grid.cell(grid.index(r, c)));
+                                               cell(i).insert(0, grid.cell(grid.index(r, c)));
                                        }
                                        // append the left over horizontal cells to the last column
                                        idx_type i = index(r + row(idx), ncols() - 1);
@@ -1174,10 +1184,10 @@ dispatch_result MathGridInset::dispatch
                                        for (col_type c = 0; c < grid.ncols(); ++c)
                                                cell(i).append(grid.cell(grid.index(r, c)));
                        }
-                       return DISPATCHED_POP;
+                       return DispatchResult(true, FINISHED);
                }
 
                default:
-                       return MathNestInset::dispatch(cmd, idx, pos);
+                       return MathNestInset::priv_dispatch(cmd, idx, pos);
        }
 }