mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
assorted tabular fixes (selection and scroll)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9345 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7d6b15683f
commit
597ef42648
@ -1,3 +1,14 @@
|
|||||||
|
|
||||||
|
2004-12-06 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
|
* insettabular.C (getCellXPos): make it return a relative x
|
||||||
|
position wrt. the begin of the tabular
|
||||||
|
(resetPos): a couple of fixes
|
||||||
|
(doDispatch): add a couple of resetPos calls
|
||||||
|
(drawSelection): fix drawing of selection in single-cell mode
|
||||||
|
(draw): replace 'do not draw' optimization by 'draw with
|
||||||
|
nullpainter' one
|
||||||
|
|
||||||
2004-12-03 Lars Gullik Bjonnes <larsbj@gullik.net>
|
2004-12-03 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||||
|
|
||||||
* insetbase.[Ch] (idxUpDown2): remove function
|
* insetbase.[Ch] (idxUpDown2): remove function
|
||||||
|
@ -263,6 +263,8 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
|
|
||||||
void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
|
setPosCache(pi, x, y);
|
||||||
|
|
||||||
//lyxerr << "InsetTabular::draw: " << x << " " << y << endl;
|
//lyxerr << "InsetTabular::draw: " << x << " " << y << endl;
|
||||||
BufferView * bv = pi.base.bv;
|
BufferView * bv = pi.base.bv;
|
||||||
|
|
||||||
@ -271,8 +273,6 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
|||||||
|
|
||||||
resetPos(bv->cursor());
|
resetPos(bv->cursor());
|
||||||
|
|
||||||
setPosCache(pi, x, y);
|
|
||||||
|
|
||||||
x += scroll();
|
x += scroll();
|
||||||
x += ADD_TO_TABULAR_WIDTH;
|
x += ADD_TO_TABULAR_WIDTH;
|
||||||
|
|
||||||
@ -283,11 +283,6 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
|||||||
int const a = tabular.getAscentOfRow(i);
|
int const a = tabular.getAscentOfRow(i);
|
||||||
int const d = tabular.getDescentOfRow(i);
|
int const d = tabular.getDescentOfRow(i);
|
||||||
idx = tabular.getCellNumber(i, 0);
|
idx = tabular.getCellNumber(i, 0);
|
||||||
if (y + d <= 0 && y - a < pi.pain.paperHeight()) {
|
|
||||||
y += d + tabular.getAscentOfRow(i + 1)
|
|
||||||
+ tabular.getAdditionalHeight(i + 1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (col_type j = 0; j < tabular.columns(); ++j) {
|
for (col_type j = 0; j < tabular.columns(); ++j) {
|
||||||
if (tabular.isPartOfMultiColumn(i, j))
|
if (tabular.isPartOfMultiColumn(i, j))
|
||||||
continue;
|
continue;
|
||||||
@ -297,6 +292,7 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
|||||||
int const cx = nx + tabular.getBeginningOfTextInCell(idx);
|
int const cx = nx + tabular.getBeginningOfTextInCell(idx);
|
||||||
if (nx + tabular.getWidthOfColumn(idx) < 0
|
if (nx + tabular.getWidthOfColumn(idx) < 0
|
||||||
|| nx > bv->workWidth()
|
|| nx > bv->workWidth()
|
||||||
|
|| y + d < 0
|
||||||
|| y - a > bv->workHeight()) {
|
|| y - a > bv->workHeight()) {
|
||||||
cell(idx)->draw(nullpi, cx, y);
|
cell(idx)->draw(nullpi, cx, y);
|
||||||
drawCellLines(nop, nx, y, i, idx);
|
drawCellLines(nop, nx, y, i, idx);
|
||||||
@ -317,12 +313,16 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
|||||||
|
|
||||||
void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const
|
void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
|
setPosCache(pi, x, y);
|
||||||
|
|
||||||
LCursor & cur = pi.base.bv->cursor();
|
LCursor & cur = pi.base.bv->cursor();
|
||||||
if (!cur.selection())
|
if (!cur.selection())
|
||||||
return;
|
return;
|
||||||
if (!ptr_cmp(&cur.inset(), this))
|
if (!ptr_cmp(&cur.inset(), this))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
resetPos(cur);
|
||||||
|
|
||||||
x += scroll();
|
x += scroll();
|
||||||
x += ADD_TO_TABULAR_WIDTH;
|
x += ADD_TO_TABULAR_WIDTH;
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
cur.text()->drawSelection(pi, x, y);
|
cur.text()->drawSelection(pi, x + getCellXPos(cur.idx()) + tabular.getBeginningOfTextInCell(cur.idx()), 0 /*this value is ignored */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,6 +509,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
if (sl == cur.top()) {
|
if (sl == cur.top()) {
|
||||||
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
|
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
|
resetPos(cur);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -521,6 +522,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
if (sl == cur.top()) {
|
if (sl == cur.top()) {
|
||||||
cmd = FuncRequest(LFUN_FINISHED_LEFT);
|
cmd = FuncRequest(LFUN_FINISHED_LEFT);
|
||||||
cur.undispatched();
|
cur.undispatched();
|
||||||
|
resetPos(cur);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -998,7 +1000,7 @@ void InsetTabular::getCursorPos(CursorSlice const & sl, int & x, int & y) const
|
|||||||
y += tabular.getDescentOfRow(i);
|
y += tabular.getDescentOfRow(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// x offset correction
|
// x offset correction
|
||||||
int const col = tabular.column_of_cell(sl.idx());
|
int const col = tabular.column_of_cell(sl.idx());
|
||||||
int idx = tabular.getCellNumber(row, 0);
|
int idx = tabular.getCellNumber(row, 0);
|
||||||
for (int j = 0; j < col; ++j) {
|
for (int j = 0; j < col; ++j) {
|
||||||
@ -1062,6 +1064,7 @@ InsetBase * InsetTabular::setPos(LCursor & cur, int x, int y) const
|
|||||||
}
|
}
|
||||||
cur.idx() = idx_min;
|
cur.idx() = idx_min;
|
||||||
//lyxerr << "# InsetTabular::setPos()\n" << cur << endl;
|
//lyxerr << "# InsetTabular::setPos()\n" << cur << endl;
|
||||||
|
resetPos(cur);
|
||||||
return cell(cur.idx())->text_.editXY(cur, x, y);
|
return cell(cur.idx())->text_.editXY(cur, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1076,14 +1079,12 @@ int InsetTabular::getCellXPos(idx_type const cell) const
|
|||||||
for (; c < cell; ++c)
|
for (; c < cell; ++c)
|
||||||
lx += tabular.getWidthOfColumn(c);
|
lx += tabular.getWidthOfColumn(c);
|
||||||
|
|
||||||
return lx - tabular.getWidthOfColumn(cell) + xo();
|
return lx - tabular.getWidthOfColumn(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetTabular::resetPos(LCursor & cur) const
|
void InsetTabular::resetPos(LCursor & cur) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
BufferView & bv = cur.bv();
|
BufferView & bv = cur.bv();
|
||||||
// col_type const actcol = tabular.column_of_cell(cur.idx());
|
// col_type const actcol = tabular.column_of_cell(cur.idx());
|
||||||
// int const offset = ADD_TO_TABULAR_WIDTH + 2;
|
// int const offset = ADD_TO_TABULAR_WIDTH + 2;
|
||||||
@ -1107,18 +1108,17 @@ void InsetTabular::resetPos(LCursor & cur) const
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if (&cur.inset() != this) {
|
if (&cur.inset() != this) {
|
||||||
scroll(bv, 0);
|
scroll(bv, 0.0F);
|
||||||
} else {
|
} else {
|
||||||
int const X1 = 0;
|
int const X1 = 0;
|
||||||
int const X2 = bv.workWidth();
|
int const X2 = bv.workWidth();
|
||||||
int const offset = ADD_TO_TABULAR_WIDTH + 2;
|
int const offset = ADD_TO_TABULAR_WIDTH + 2;
|
||||||
int const col_width = tabular.getWidthOfColumn(cur.idx());
|
int const x1 = xo() + scroll() + getCellXPos(cur.idx()) + offset;
|
||||||
int const x1 = getCellXPos(cur.idx()) + offset + scroll();
|
int const x2 = x1 + tabular.getWidthOfColumn(cur.idx());
|
||||||
int const x2 = x1 + col_width;
|
|
||||||
|
|
||||||
if (x1 < X1 + 20)
|
if (x1 < X1)
|
||||||
scroll(bv, X1 + 20 - x1);
|
scroll(bv, X1 + 20 - x1);
|
||||||
else if (x2 > X2 - 20)
|
else if (x2 > X2)
|
||||||
scroll(bv, X2 - 20 - x2);
|
scroll(bv, X2 - 20 - x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user