InsetTabular::InsetTabular(Buffer * buf, row_type rows,
col_type columns)
- : Inset(buf), tabular(buf, max(rows, row_type(1)), max(columns, col_type(1))), scx_(0),
- rowselect_(false), colselect_(false)
+ : Inset(buf), tabular(buf, max(rows, row_type(1)), max(columns, col_type(1))),
+ rowselect_(false), colselect_(false)
{
}
InsetTabular::InsetTabular(InsetTabular const & tab)
- : Inset(tab), tabular(tab.tabular), scx_(0)
+ : Inset(tab), tabular(tab.tabular)
{
}
void InsetTabular::draw(PainterInfo & pi, int x, int y) const
{
- x += scx_ + ADD_TO_TABULAR_WIDTH;
+ x += ADD_TO_TABULAR_WIDTH;
BufferView * bv = pi.base.bv;
Cursor & cur = pi.base.bv->cursor();
- resetPos(cur);
// FIXME: As the full background is painted in drawBackground(),
// we have no choice but to do a full repaint for the Text cells.
void InsetTabular::drawBackground(PainterInfo & pi, int x, int y) const
{
- x += scx_ + ADD_TO_TABULAR_WIDTH;
+ x += ADD_TO_TABULAR_WIDTH;
y += offset_valign_ - tabular.rowAscent(0);
pi.pain.fillRectangle(x, y, tabular.width(), tabular.height(),
pi.backgroundColor(this));
void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const
{
Cursor & cur = pi.base.bv->cursor();
- resetPos(cur);
- x += scx_ + ADD_TO_TABULAR_WIDTH;
+ x += ADD_TO_TABULAR_WIDTH;
if (!cur.selection())
return;
}
cur.setCurrentFont();
// FIXME: this accesses the position cache before it is initialized
- //resetPos(cur);
//cur.bv().fitCursor();
}
x += cellXPos(sl.idx());
x += tabular.textHOffset(sl.idx());
x += ADD_TO_TABULAR_WIDTH;
- x += scx_;
}
cur.setSelection(false);
cur.push(*this);
cur.idx() = getNearestCell(cur.bv(), x, y);
- resetPos(cur);
return cur.bv().textMetrics(&cell(cur.idx())->text()).editXY(cur, x, y);
}
}
-void InsetTabular::resetPos(Cursor & cur) const
-{
- BufferView & bv = cur.bv();
- int const maxwidth = bv.workWidth();
-
- int const scx_old = scx_;
- int const i = cur.find(this);
- if (i == -1) {
- scx_ = 0;
- } else {
- int const X1 = 0;
- int const X2 = maxwidth;
- int const offset = ADD_TO_TABULAR_WIDTH + 2;
- int const x1 = xo(cur.bv()) + cellXPos(cur[i].idx()) + offset;
- int const x2 = x1 + tabular.cellWidth(cur[i].idx());
-
- if (x1 < X1)
- scx_ = X1 + 20 - x1;
- else if (x2 > X2)
- scx_ = X2 - 20 - x2;
- else
- scx_ = 0;
- }
-
- // only update if offset changed
- if (scx_ != scx_old)
- cur.screenUpdateFlags(Update::Force | Update::FitCursor);
-}
-
-
void InsetTabular::moveNextCell(Cursor & cur, EntryDirection entry_from)
{
row_type const row = tabular.cellRow(cur.idx());
if (cur.selIsMultiCell()) {
cur.pit() = cur.lastpit();
cur.pos() = cur.lastpos();
- resetPos(cur);
return;
}
}
cur.setCurrentFont();
- resetPos(cur);
}
if (cur.selIsMultiCell()) {
cur.pit() = cur.lastpit();
cur.pos() = cur.lastpos();
- resetPos(cur);
return;
}
}
cur.setCurrentFont();
- resetPos(cur);
}