+/**
+ * \file math_gridinset.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
#include "math_gridinset.h"
+#include "math_data.h"
#include "math_mathmlstream.h"
#include "math_streamstr.h"
-#include "lyxfont.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::istream;
+using std::istringstream;
+using std::ostringstream;
+using std::vector;
class GridInsetMailer : public MailInset {
data << name() << " active_cell " << 0 << '\n';
WriteStream ws(data);
inset_.write(ws);
- return STRCONV(data.str());
+ return data.str();
}
protected:
setDefaults();
valign(v);
halign(h);
- //lyxerr << "created grid with " << ncols() << " columns\n";
+ //lyxerr << "created grid with " << ncols() << " columns" << endl;
}
void MathGridInset::setDefaults()
{
if (ncols() <= 0)
- lyxerr << "positive number of columns expected\n";
+ lyxerr << "positive number of columns expected" << endl;
//if (nrows() <= 0)
- // lyxerr << "positive number of rows expected\n";
+ // lyxerr << "positive number of rows expected" << endl;
for (col_type col = 0; col < ncols(); ++col) {
colinfo_[col].align_ = defaultColAlign(col);
colinfo_[col].skip_ = defaultColSpace(col);
++col;
colinfo_[col].lines_ = 0;
} else {
- lyxerr << "unknown column separator: '" << c << "'\n";
+ lyxerr << "unknown column separator: '" << c << "'" << endl;
}
}
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);
}
}
}
-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:
idx = nargs() - 1;
if (pos > cell(idx).size())
pos = cell(idx).size();
- return DISPATCHED_POP;
+ return DispatchResult(true, FINISHED);
case LFUN_CELL_SPLIT:
- //bv->lockedInsetStoreUndo(Undo::EDIT);
+ //recordUndo(bv, Undo::ATOMIC);
splitCell(idx, pos);
- return DISPATCHED_POP;
+ return DispatchResult(true, FINISHED);
case LFUN_BREAKLINE: {
- //bv->lockedInsetStoreUndo(Undo::INSERT);
+ //recordUndo(bv, Undo::INSERT);
row_type const r = row(idx);
addRow(r);
pos = cell(idx).size();
//mathcursor->normalize();
- return DISPATCHED_POP;
+ return DispatchResult(true, FINISHED);
}
case LFUN_TABULAR_FEATURE: {
- //lyxerr << "handling tabular-feature " << cmd.argument << "\n";
- istringstream is(STRCONV(cmd.argument));
+ //lyxerr << "handling tabular-feature " << cmd.argument << endl;
+ istringstream is(cmd.argument);
string s;
is >> s;
if (s == "valign-top")
valign('t');
- else if (s == "valign-center")
+ else if (s == "valign-middle")
valign('c');
else if (s == "valign-bottom")
valign('b');
else if (s == "swap-column")
swapCol(col(idx));
else
- return UNDISPATCHED;
- lyxerr << "returning DISPATCHED_POP\n";
- return DISPATCHED_POP;
+ return DispatchResult(false);
+ lyxerr << "returning DispatchResult(true, FINISHED)" << endl;
+ return DispatchResult(true, FINISHED);
}
case LFUN_PASTE: {
- //lyxerr << "pasting '" << cmd.argument << "'\n";
+ //lyxerr << "pasting '" << cmd.argument << "'" << endl;
MathGridInset grid(1, 1);
mathed_parse_normal(grid, cmd.argument);
if (grid.nargs() == 1) {
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);
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);
}
}