tabular.setOwner(this);
actrow = 0;
actcell = 0;
- locked_cell = -1;
clearSelection();
in_reset_pos = 0;
}
actrow = 0;
actcell = 0;
clearSelection();
- locked_cell = -1;
in_reset_pos = 0;
}
void InsetTabular::drawCellSelection(Painter & pain, int x, int y,
int row, int column, int cell) const
{
- if (locked_cell != -1)
+ if (actcell != -1)
return;
BOOST_ASSERT(hasSelection());
lyxerr << "# InsetTabular::lfunMousePress cell: " << cell << endl;
if (cell == -1) {
bv->cursor() = theTempCursor;
- bv->cursor().data_.push_back(CursorItem(this));
+ bv->cursor().data_.push_back(CursorSlice(this));
bv->cursor().data_.back().idx_ = cell;
} else {
setPos(bv, cmd.x, cmd.y);
bv->cursor() = theTempCursor;
bv->cursor().data_.back().idx_ = cell;
}
- locked_cell = cell;
+ actcell = cell;
lyxerr << bv->cursor() << endl;
if (cmd.button() == mouse_button::button2)
bv->fitCursor();
bv->cursor().push(this);
bv->cursor().data_.back().idx_ = actcell;
- locked_cell = actcell;
lyxerr << bv->cursor() << endl;
}
int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
bv->cursor().push(this);
if (x > xx)
- activateCellInset(bv, x - xx, y - cursory_, false);
+ activateCellInset(bv, actcell, x - xx, y - cursory_);
}
break;
}
-
int cell = bv->cursor().data_.back().idx_;
if (cell != -1) {
+
+ if (cell != actcell) {
+ lyxerr << "## ERROR ## InsetTabular::priv_dispatch: actcell: "
+ << actcell << " and cell " << cell << " should be the same "
+ << "here" << endl;
+ }
+
lyxerr << "# InsetTabular::dispatch 1: " << cmd << endl;
result = tabular.getCellInset(cell).dispatch(cmd, idx, pos);
switch (result.val()) {
- case LFUN_FINISHED_LEFT:
- lyxerr << "handle LFUN_FINISHED_LEFT, act: " << actcell << endl;
+ case FINISHED:
+ lyxerr << "# handle FINISHED_LEFT, act: " << actcell << endl;
if (movePrevCell(bv, false))
result = DispatchResult(true, true);
else
result = DispatchResult(false, FINISHED);
break;
- case LFUN_FINISHED_RIGHT:
- lyxerr << "handle LFUN_FINISHED_RIGHT, act: " << actcell << endl;
+ case FINISHED_RIGHT:
+ lyxerr << "# handle FINISHED_RIGHT, act: " << actcell << endl;
if (moveNextCell(bv, false))
result = DispatchResult(true, true);
else
result = DispatchResult(false, FINISHED_RIGHT);
break;
- case LFUN_FINISHED_UP:
- lyxerr << "handle LFUN_FINISHED_UP, act: " << actcell << endl;
+ case FINISHED_UP:
+ lyxerr << "# handle FINISHED_UP, act: " << actcell << endl;
result = moveUp(bv, true);
break;
- case LFUN_FINISHED_DOWN:
- lyxerr << "handle LFUN_FINISHED_DOWN, act: " << actcell << endl;
+ case FINISHED_DOWN:
+ lyxerr << "# handle FINISHED_DOWN, act: " << actcell << endl;
result = moveDown(bv, true);
break;
default:
+ lyxerr << "# don't handle dispatch in act: " << actcell << endl;
break;
}
void InsetTabular::getCursorPos(int & x, int & y) const
{
- if (locked_cell == -1) {
+ if (actcell == -1) {
x = TEXT_TO_INSET_OFFSET + cursorx_ - xo_;
y = TEXT_TO_INSET_OFFSET + cursory_;
} else {
- tabular.getCellInset(locked_cell).getCursorPos(x, y);
- x = TEXT_TO_INSET_OFFSET;
+ InsetText const & inset = tabular.getCellInset(actcell);
+ inset.getCursorPos(x, y);
+ x += inset.x() - xo_;
+ y += inset.y() - yo_;
}
}
if (!moved)
return DispatchResult(false, FINISHED_RIGHT);
if (lock) {
- activateCellInset(bv, 0, 0, false);
+ activateCellInset(bv, actcell, false);
return DispatchResult(true, true);
}
resetPos(bv);
return DispatchResult(false, FINISHED);
// behind the inset
if (lock) {
- activateCellInset(bv, 0, 0, true);
+ activateCellInset(bv, actcell, true);
return DispatchResult(true, true);
}
resetPos(bv);
return DispatchResult(false, FINISHED_UP);
resetPos(bv);
if (lock)
- activateCellInset(bv, bv->x_target(), 0, false);
+ activateCellInset(bv, actcell, bv->x_target(), 0);
return DispatchResult(true, true);
}
return DispatchResult(false, FINISHED_DOWN);
resetPos(bv);
if (lock)
- activateCellInset(bv, bv->x_target(), 0, false);
+ activateCellInset(bv, actcell, bv->x_target());
return DispatchResult(true, true);
}
bool InsetTabular::moveNextCell(BufferView * bv, bool lock)
{
+ lyxerr << "InsetTabular::moveNextCell 1 actcell: " << actcell << endl;
if (isRightToLeft(bv)) {
if (tabular.isFirstCellInRow(actcell)) {
int row = tabular.row_of_cell(actcell);
actcell = tabular.getLastCellInRow(row);
actcell = tabular.getCellBelow(actcell);
} else {
- if (!actcell)
+ if (actcell == 0)
return false;
--actcell;
}
return false;
++actcell;
}
+ lyxerr << "InsetTabular::moveNextCell 2 actcell: " << actcell << endl;
if (lock) {
bool rtl = tabular.getCellInset(actcell).paragraphs().begin()->
isRightToLeftPar(bv->buffer()->params());
- activateCellInset(bv, 0, 0, !rtl);
+ activateCellInset(bv, actcell, !rtl);
}
resetPos(bv);
return true;
if (lock) {
bool rtl = tabular.getCellInset(actcell).paragraphs().begin()->
isRightToLeftPar(bv->buffer()->params());
- activateCellInset(bv, 0, 0, !rtl);
+ activateCellInset(bv, actcell, !rtl);
}
lyxerr << "move prevcell 3" << endl;
resetPos(bv);
}
-void InsetTabular::activateCellInset(BufferView * bv, int x, int y, bool behind)
+void InsetTabular::activateCellInset(BufferView * bv, int cell, int x, int y)
{
- UpdatableInset & inset = tabular.getCellInset(actcell);
- if (behind) {
-#warning metrics?
- x = inset.x() + inset.width();
- y = inset.descent();
- }
- inset.edit(bv, x, y);
+ actcell = cell;
+ tabular.getCellInset(actcell).edit(bv, x, y);
bv->cursor().data_.back().idx_ = actcell;
- locked_cell = actcell;
updateLocal(bv);
}
+void InsetTabular::activateCellInset(BufferView * bv, int cell, bool behind)
+{
+ actcell = cell;
+ tabular.getCellInset(actcell).edit(bv, behind);
+ bv->cursor().data_.back().idx_ = actcell;
+ updateLocal(bv);
+}
+
+
+
bool InsetTabular::showInsetDialog(BufferView * bv) const
{
InsetTabularMailer(*this).showDialog(bv);