mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
Reuse some code and simplify InsetTabular::cursorPos()
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36487 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0fd75fefc4
commit
9fe6d655f3
@ -4720,21 +4720,13 @@ void InsetTabular::cursorPos(BufferView const & bv,
|
|||||||
{
|
{
|
||||||
cell(sl.idx())->cursorPos(bv, sl, boundary, x, y);
|
cell(sl.idx())->cursorPos(bv, sl, boundary, x, y);
|
||||||
|
|
||||||
int const row = tabular.cellRow(sl.idx());
|
|
||||||
int const col = tabular.cellColumn(sl.idx());
|
|
||||||
|
|
||||||
// y offset correction
|
// y offset correction
|
||||||
for (int r = 0; r < row; ++r)
|
y += cellYPos(sl.idx());
|
||||||
y += tabular.rowDescent(r) + tabular.rowAscent(r + 1)
|
|
||||||
+ tabular.interRowSpace(r + 1);
|
|
||||||
|
|
||||||
y += tabular.textVOffset(sl.idx());
|
y += tabular.textVOffset(sl.idx());
|
||||||
y += offset_valign_;
|
y += offset_valign_;
|
||||||
|
|
||||||
// x offset correction
|
// x offset correction
|
||||||
for (int c = 0; c < col; ++c)
|
x += cellXPos(sl.idx());
|
||||||
x += tabular.column_info[c].width;
|
|
||||||
|
|
||||||
x += tabular.textHOffset(sl.idx());
|
x += tabular.textHOffset(sl.idx());
|
||||||
x += ADD_TO_TABULAR_WIDTH;
|
x += ADD_TO_TABULAR_WIDTH;
|
||||||
x += scx_;
|
x += scx_;
|
||||||
@ -4807,13 +4799,23 @@ InsetTabular::idx_type InsetTabular::getNearestCell(BufferView & bv, int x, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int InsetTabular::cellYPos(idx_type const cell) const
|
||||||
|
{
|
||||||
|
row_type row = tabular.cellRow(cell);
|
||||||
|
int ly = 0;
|
||||||
|
for (row_type r = 0; r < row; ++r)
|
||||||
|
ly += tabular.rowDescent(r) + tabular.rowAscent(r + 1)
|
||||||
|
+ tabular.interRowSpace(r + 1);
|
||||||
|
return ly;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetTabular::cellXPos(idx_type const cell) const
|
int InsetTabular::cellXPos(idx_type const cell) const
|
||||||
{
|
{
|
||||||
col_type col = tabular.cellColumn(cell);
|
col_type col = tabular.cellColumn(cell);
|
||||||
int lx = 0;
|
int lx = 0;
|
||||||
for (col_type c = 0; c < col; ++c)
|
for (col_type c = 0; c < col; ++c)
|
||||||
lx += tabular.column_info[c].width;
|
lx += tabular.column_info[c].width;
|
||||||
|
|
||||||
return lx;
|
return lx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -928,6 +928,8 @@ private:
|
|||||||
///
|
///
|
||||||
int cellXPos(idx_type cell) const;
|
int cellXPos(idx_type cell) const;
|
||||||
///
|
///
|
||||||
|
int cellYPos(idx_type cell) const;
|
||||||
|
///
|
||||||
void resetPos(Cursor & cur) const;
|
void resetPos(Cursor & cur) const;
|
||||||
///
|
///
|
||||||
bool copySelection(Cursor & cur);
|
bool copySelection(Cursor & cur);
|
||||||
|
Loading…
Reference in New Issue
Block a user