* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
* \author Matthias Ettrich
- * \author José Matos
+ * \author José Matos
* \author Jean-Marc Lasgouttes
* \author Angus Leeming
* \author John Levon
- * \author André Pönitz
- * \author Jürgen Vigna
+ * \author André Pönitz
+ * \author Jürgen Vigna
*
* Full author contact details are available in file CREDITS.
*/
dim.wid = tabular.width() + 2 * ADD_TO_TABULAR_WIDTH;
}
+bool InsetTabular::isCellSelected(Cursor & cur, row_type row, col_type col)
+ const
+{
+ if (&cur.inset() == this && cur.selection()) {
+ if (cur.selIsMultiCell()) {
+ row_type rs, re;
+ col_type cs, ce;
+ getSelection(cur, rs, re, cs, ce);
+
+ if (col >= cs && col <= ce && row >= rs && row <= re)
+ return true;
+ } else
+ if (col == tabular.cellColumn(cur.idx())
+ && row == tabular.cellRow(cur.idx())) {
+ CursorSlice const & beg = cur.selBegin();
+ CursorSlice const & end = cur.selEnd();
+
+ if (end.lastpos() > 0 && end.pos() == end.lastpos()
+ && beg.pos() == 0)
+ return true;
+ }
+ }
+ return false;
+}
+
void InsetTabular::draw(PainterInfo & pi, int x, int y) const
{
//lyxerr << "InsetTabular::draw: " << x << " " << y << endl;
BufferView * bv = pi.base.bv;
+ Cursor & cur = pi.base.bv->cursor();
// FIXME: As the full backrgound is painted in drawSelection(),
// we have no choice but to do a full repaint for the Text cells.
x += ADD_TO_TABULAR_WIDTH;
bool const original_drawing_state = pi.pain.isDrawingEnabled();
+ bool const original_selection_state = pi.selected;
idx_type idx = 0;
first_visible_cell = Tabular::npos;
if (first_visible_cell == Tabular::npos)
first_visible_cell = idx;
+ pi.selected |= isCellSelected(cur, i, j);
int const cx = nx + tabular.getBeginningOfTextInCell(idx);
// Cache the Inset position.
bv->coordCache().insets().add(cell(idx).get(), cx, y);
}
nx += tabular.columnWidth(idx);
++idx;
+ pi.selected = original_selection_state;
}
if (i + 1 < tabular.row_info.size())
int const w = tabular.width();
int const h = tabular.height();
int yy = y - tabular.rowAscent(0);
- pi.pain.fillRectangle(x, yy, w, h, backgroundColor());
+ pi.pain.fillRectangle(x, yy, w, h, pi.backgroundColor(this));
if (!cur.selection())
return;
if (cur.selIsMultiCell()) {
- row_type rs, re;
- col_type cs, ce;
- getSelection(cur, rs, re, cs, ce);
y -= tabular.rowAscent(0);
for (row_type j = 0; j < tabular.row_info.size(); ++j) {
int const a = tabular.rowAscent(j);
idx_type const cell =
tabular.cellIndex(j, i);
int const w = tabular.columnWidth(cell);
- if (i >= cs && i <= ce && j >= rs && j <= re)
+ if (isCellSelected(cur, j, i))
pi.pain.fillRectangle(xx, y, w, h,
Color_selection);
xx += w;
void InsetTabular::updateLabels(ParIterator const & it)
{
// In a longtable, tell captions what the current float is
- Counters & cnts = buffer().params().documentClass().counters();
+ Counters & cnts = buffer().masterBuffer()->params().documentClass().counters();
string const saveflt = cnts.current_float();
if (tabular.is_long_tabular)
cnts.current_float("table");
it2.forwardPos();
size_t const end = it2.nargs();
for ( ; it2.idx() < end; it2.top().forwardIdx())
- lyx::updateLabels(buffer(), it2);
+ buffer().updateLabels(it2);
//reset afterwards
if (tabular.is_long_tabular)