on_off ? Painter::line_onoffdash : Painter::line_solid);
}
on_off = !tabular->BottomLine(cell);
- pain.line(x,baseline + tabular->GetDescentOfRow(row),
- x2, baseline + tabular->GetDescentOfRow(row),
+ pain.line(x, baseline + tabular->GetDescentOfRow(row),
+ x2, baseline + tabular->GetDescentOfRow(row),
on_off ? LColor::tabularonoffline : LColor::tabularline,
on_off ? Painter::line_onoffdash : Painter::line_solid);
if (!tabular->LeftAlreadyDrawed(cell)) {
if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
int w = tabular->GetWidthOfColumn(cell);
- int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row);
- pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row),
+ int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row)-1;
+ pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row) + 1,
w, h, LColor::selection);
}
}
case INIT:
case FULL:
case CELL:
- if (calculate_dimensions_of_cells(bv, font, false))
+ if (calculate_dimensions_of_cells(bv, font, false)) {
need_update = INIT;
+ resetPos(bv);
+ }
break;
case SELECTION:
need_update = FULL;
lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
return;
}
+ finishUndo();
locked = true;
the_locking_inset = 0;
inset_x = 0;
actcell = tabular->GetNumberOfCells() - 1;
clearSelection();
resetPos(bv);
- finishUndo();
+ bv->fitCursor();
}
{
if (the_locking_inset) {
the_locking_inset->insetUnlock(bv);
+ updateLocal(bv, CELL, false);
the_locking_inset = 0;
}
hideInsetCursor(bv);
return false;
if (the_locking_inset == inset) {
the_locking_inset->insetUnlock(bv);
- the_locking_inset = 0;
#ifdef WITH_WARNINGS
#warning fix scrolling when cellinset has requested a scroll (Jug)!!!
#endif
scroll(bv, 0.0F);
#endif
updateLocal(bv, CELL, false);
+ // this has to be here otherwise we don't redraw the cell!
+ the_locking_inset = 0;
// showInsetCursor(bv, false);
return true;
}
}
-unsigned int InsetTabular::insetInInsetY()
+int InsetTabular::insetInInsetY() const
{
if (!the_locking_inset)
return 0;
int const orow = actrow;
hideInsetCursor(bv);
+ if (!locked) {
+ locked = true;
+ the_locking_inset = 0;
+ inset_x = 0;
+ inset_y = 0;
+ }
setPos(bv, x, y);
if (actrow != orow)
updateLocal(bv, NONE, false);
if (button == 3) {
if ((ocell != actcell) && the_locking_inset) {
the_locking_inset->insetUnlock(bv);
+ updateLocal(bv, CELL, false);
the_locking_inset = 0;
}
showInsetCursor(bv);
return;
} else if (the_locking_inset) {
the_locking_inset->insetUnlock(bv);
+ updateLocal(bv, CELL, false);
+ the_locking_inset = 0;
}
- the_locking_inset = 0;
if (button == 2) {
localDispatch(bv, LFUN_PASTESELECTION, "paragraph");
return;
}
if (inset_hit && bv->theLockingInset()) {
- // only activate the Inset so that no internal inset is hit
- // by this call. It should be only hit by the insetButtonPress call.
- if (activateCellInsetAbs(bv, 0, 0, 0))
- the_locking_inset->insetButtonPress(bv,
- x - inset_x,
- y - inset_y,
- button);
+ if (!bv->lockInset(static_cast<UpdatableInset*>(tabular->GetCellInset(actcell)))) {
+ lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
+ return;
+ }
+ the_locking_inset->insetButtonPress(
+ bv, x - inset_x, y - inset_y, button);
return;
}
showInsetCursor(bv);
}
if (result < FINISHED) {
if (!the_locking_inset) {
-// showInsetCursor(bv);
+ if (bv->fitCursor())
+ updateLocal(bv, FULL, false);
+ if (locked)
+ showInsetCursor(bv);
}
} else
bv->unlockInset(this);
void InsetTabular::fitInsetCursor(BufferView * bv) const
{
if (the_locking_inset) {
+ int old_first_y = bv->text->first_y;
the_locking_inset->fitInsetCursor(bv);
+ if (old_first_y != bv->text->first_y)
+ need_update = FULL;
return;
}
LyXFont font;
int const asc = lyxfont::maxAscent(font);
int const desc = lyxfont::maxDescent(font);
- bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
+ resetPos(bv);
+ if (bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc))
+ need_update = FULL;
}
}
if (!frozen)
unFreezeUndo();
+ if (selectall)
+ clearSelection();
updateLocal(bv, INIT, true);
}
if (the_locking_inset)
{
if (the_locking_inset)
return the_locking_inset->insetAllowed(code);
- return false;
+ // we return true here because if the inset is not locked someone
+ // wants to insert something in one of our insettexts and we generally
+ // allow to do so.
+ return true;
}
bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
bool usePaste)
{
- if (buf.find('\t') == string::npos)
- return false;
+ if (buf.length() <= 0)
+ return true;
int cols = 1;
int rows = 1;
case '\t':
// we can only set this if we are not too far right
if (cols < columns) {
- loctab->GetCellInset(cell)->setText(buf.substr(op, p-op));
+ InsetText * ti = loctab->GetCellInset(cell);
+ LyXFont const font = ti->getLyXText(bv)->
+ getFont(bv->buffer(), ti->paragraph(), 0);
+ ti->setText(buf.substr(op, p-op), font);
++cols;
++cell;
}
break;
case '\n':
// we can only set this if we are not too far right
- if (cols < columns)
- loctab->GetCellInset(cell)->setText(buf.substr(op, p-op));
+ if (cols < columns) {
+ InsetText * ti = loctab->GetCellInset(cell);
+ LyXFont const font = ti->getLyXText(bv)->
+ getFont(bv->buffer(), ti->paragraph(), 0);
+ ti->setText(buf.substr(op, p-op), font);
+ }
cols = ocol;
++row;
if (row < rows)
op = p;
}
// check for the last cell if there is no trailing '\n'
- if ((cell < cells) && (op < len))
- loctab->GetCellInset(cell)->setText(buf.substr(op, len-op));
+ if ((cell < cells) && (op < len)) {
+ InsetText * ti = loctab->GetCellInset(cell);
+ LyXFont const font = ti->getLyXText(bv)->
+ getFont(bv->buffer(), ti->paragraph(), 0);
+ ti->setText(buf.substr(op, len-op), font);
+ }
return true;
}