UpdatableInset::draw(pain,font,baseline,x);
if (init_inset || (top_x != int(x)) || (top_baseline != baseline)) {
- int ox = top_x;
+// int ox = top_x;
init_inset = false;
top_x = int(x);
top_baseline = baseline;
- if (ox != top_x)
- recomputeTextInsets(pain, font);
+// if (ox != top_x)
+// recomputeTextInsets(pain, font);
calculate_width_of_cells(pain, font);
resetPos(pain);
reinit = true;
}
+void InsetTabular::update(BufferView * bv, LyXFont const & font) const
+{
+ if (init_inset)
+ recomputeTextInsets(bv, font);
+}
+
+
void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline,
int row, int cell) const
{
if (InsetHit(bv, x, y)) {
ActivateCellInset(bv, x, y, button);
}
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, false);
// bv->getOwner()->getPopups().updateFormTabular();
}
if (hasSelection()) {
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
}
no_selection = false;
oldcell = -1;
locked = false;
}
-void InsetTabular::UpdateLocal(BufferView * bv, bool flag)
+void InsetTabular::UpdateLocal(BufferView * bv, bool what, bool mark_dirty)
{
- if (flag)
+ if (what)
calculate_width_of_cells(bv->painter(), LyXFont(LyXFont::ALL_SANE));
- bv->updateInset(this, flag);
- if (flag)
+ bv->updateInset(this, mark_dirty);
+ if (what)
resetPos(bv->painter());
}
return false;
if (the_locking_inset != inset)
return the_locking_inset->UpdateInsetInInset(bv, inset);
- UpdateLocal(bv);
+ UpdateLocal(bv, true, false);
return true;
}
{
if (hasSelection()) {
sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
}
no_selection = false;
sel_pos_end = cursor.pos();
sel_cell_end = actcell;
if (old != sel_pos_end)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
#if 0
if (ocell != actcell)
bview->getOwner()->getPopups().updateFormTabular();
else if (result == DISPATCHED) {
bool upd = SetCellDimensions(bv->painter(), actcell, actrow);
the_locking_inset->ToggleInsetCursor(bv);
- UpdateLocal(bv, upd);
+ UpdateLocal(bv, upd, false);
the_locking_inset->ToggleInsetCursor(bv);
return result;
} else if (result == FINISHED) {
else
sel_cell_end = actcell;
}
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_RIGHT:
result = moveRight(bv);
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_LEFTSEL:
if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos()))
else
sel_cell_end = actcell-1;
}
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_LEFT:
result = moveLeft(bv);
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_DOWNSEL:
{
sel_cell_end = tabular->GetCellBelow(sel_cell_end);
else
sel_cell_end = tabular->GetLastCellBelow(sel_cell_end);
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
}
break;
case LFUN_DOWN:
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_UPSEL:
{
sel_cell_end = tabular->GetCellAbove(sel_cell_end);
else
sel_cell_end = tabular->GetLastCellAbove(sel_cell_end);
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
}
break;
case LFUN_UP:
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_BACKSPACE:
break;
sel_pos_start = sel_pos_end = cursor.pos();
sel_cell_start = sel_cell_end = actcell;
if (hs)
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, false);
break;
case LFUN_LAYOUT_TABLE:
{
bool update = (tabular->GetPWidth(actcell) != val);
tabular->SetPWidth(actcell,val);
if (update)
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
}
break;
case LyXTabular::SET_SPECIAL_COLUMN:
// append the row into the tabular
UnlockInsetInInset(bv, the_locking_inset);
tabular->AppendRow(actcell);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::APPEND_COLUMN:
// append the column into the tabular
tabular->AppendColumn(actcell);
actcell = tabular->GetCellNumber(row, column);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::DELETE_ROW:
tabular->DeleteRow(tabular->row_of_cell(actcell));
if ((row+1) > tabular->rows())
--row;
actcell = tabular->GetCellNumber(row, column);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::DELETE_COLUMN:
tabular->DeleteColumn(tabular->column_of_cell(actcell));
if ((column+1) > tabular->columns())
--column;
actcell = tabular->GetCellNumber(row, column);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::TOGGLE_LINE_TOP:
lineSet = !tabular->TopLine(actcell);
for(i=sel_row_start; i<=sel_row_end; ++i)
for(j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetTopLine(tabular->GetCellNumber(i,j),lineSet);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::TOGGLE_LINE_BOTTOM:
for(i=sel_row_start; i<=sel_row_end; ++i)
for(j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetBottomLine(tabular->GetCellNumber(i,j),lineSet);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::TOGGLE_LINE_LEFT:
for(i=sel_row_start; i<=sel_row_end; ++i)
for(j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetLeftLine(tabular->GetCellNumber(i,j),lineSet);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::TOGGLE_LINE_RIGHT:
for(i=sel_row_start; i<=sel_row_end; ++i)
for(j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetRightLine(tabular->GetCellNumber(i,j),lineSet);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::ALIGN_LEFT:
case LyXTabular::ALIGN_RIGHT:
for(i=sel_row_start; i<=sel_row_end; ++i)
for(j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetAlignment(tabular->GetCellNumber(i,j),setAlign);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::MULTICOLUMN:
{
// check wether we are completly in a multicol
if (tabular->IsMultiColumn(actcell)) {
tabular->UnsetMultiColumn(actcell);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
} else {
tabular->SetMultiColumn(actcell, 1);
- UpdateLocal(bv, false);
+ UpdateLocal(bv, false, true);
}
return;
}
cursor.pos(0);
sel_cell_end = sel_cell_start;
sel_pos_end = sel_pos_start;
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
}
case LyXTabular::SET_ALL_LINES:
for(i=sel_row_start; i<=sel_row_end; ++i)
for(j=sel_col_start; j<=sel_col_end; ++j)
tabular->SetAllLines(tabular->GetCellNumber(i,j), setLines);
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, true);
break;
case LyXTabular::SET_LONGTABULAR:
tabular->SetLongTabular(true);
- UpdateLocal(bv, true); // because this toggles displayed
+ UpdateLocal(bv, true, true); // because this toggles displayed
break;
case LyXTabular::UNSET_LONGTABULAR:
tabular->SetLongTabular(false);
- UpdateLocal(bv, true); // because this toggles displayed
+ UpdateLocal(bv, true, true); // because this toggles displayed
break;
case LyXTabular::SET_ROTATE_TABULAR:
tabular->SetRotateTabular(true);
inset->Edit(bv, x - inset_x, y - inset_y, button);
if (!the_locking_inset)
return false;
- UpdateLocal(bv, true);
+ UpdateLocal(bv, true, false);
return true;
}
return w;
}
-void InsetTabular::recomputeTextInsets(Painter & pain, const LyXFont & font) const
+void InsetTabular::recomputeTextInsets(BufferView * bv, const LyXFont & font) const
{
InsetText * inset;
- int cx, cell;
+ int cell;
- cx = top_x;
+// cx = top_x;
for(int j= 0; j < tabular->columns(); ++j) {
for(int i = 0; i < tabular->rows(); ++i) {
if (tabular->IsPartOfMultiColumn(i,j))
continue;
cell = tabular->GetCellNumber(i,j);
inset = tabular->GetCellInset(cell);
- inset->computeTextRows(pain);
- tabular->SetWidthOfCell(cell, inset->width(pain, font));
+ inset->update(bv, font);
+ inset->computeTextRows(bv->painter());
+ tabular->SetWidthOfCell(cell, inset->width(bv->painter(), font));
}
- cell = tabular->GetCellNumber(0, j);
- cx += tabular->GetWidthOfColumn(cell);
+// cell = tabular->GetCellNumber(0, j);
+// cx += tabular->GetWidthOfColumn(cell);
}
}