mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
postPaint() etc.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6514 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a1e4f55eb6
commit
af2f39cc94
@ -1,3 +1,7 @@
|
||||
2003-03-16 John Levon <levon@movementarian.org>
|
||||
|
||||
* insettext.C: remove unused s.refresh
|
||||
|
||||
2003-03-13 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* insettext.C (edit): replace Dialogs::updateParagraph with
|
||||
|
@ -100,7 +100,6 @@ void InsetText::saveLyXTextState(LyXText * t) const
|
||||
sstate.selendboundary = t->selection.end.boundary();
|
||||
sstate.selection = t->selection.set();
|
||||
sstate.mark_set = t->selection.mark();
|
||||
sstate.refresh = t->refresh_row != 0;
|
||||
} else {
|
||||
sstate.lpar = 0;
|
||||
}
|
||||
@ -109,26 +108,24 @@ void InsetText::saveLyXTextState(LyXText * t) const
|
||||
|
||||
void InsetText::restoreLyXTextState(BufferView * bv, LyXText * t) const
|
||||
{
|
||||
if (sstate.lpar) {
|
||||
t->selection.set(true);
|
||||
/* at this point just to avoid the Delete-Empty-Paragraph
|
||||
* Mechanism when setting the cursor */
|
||||
t->selection.mark(sstate.mark_set);
|
||||
if (sstate.selection) {
|
||||
t->setCursor(bv, sstate.selstartpar, sstate.selstartpos,
|
||||
true, sstate.selstartboundary);
|
||||
t->selection.cursor = t->cursor;
|
||||
t->setCursor(bv, sstate.selendpar, sstate.selendpos,
|
||||
true, sstate.selendboundary);
|
||||
t->setSelection(bv);
|
||||
t->setCursor(bv, sstate.lpar, sstate.pos);
|
||||
} else {
|
||||
t->setCursor(bv, sstate.lpar, sstate.pos, true, sstate.boundary);
|
||||
t->selection.cursor = t->cursor;
|
||||
t->selection.set(false);
|
||||
}
|
||||
if (sstate.refresh) {
|
||||
}
|
||||
if (!sstate.lpar)
|
||||
return;
|
||||
|
||||
t->selection.set(true);
|
||||
/* at this point just to avoid the DEPM when setting the cursor */
|
||||
t->selection.mark(sstate.mark_set);
|
||||
if (sstate.selection) {
|
||||
t->setCursor(bv, sstate.selstartpar, sstate.selstartpos,
|
||||
true, sstate.selstartboundary);
|
||||
t->selection.cursor = t->cursor;
|
||||
t->setCursor(bv, sstate.selendpar, sstate.selendpos,
|
||||
true, sstate.selendboundary);
|
||||
t->setSelection(bv);
|
||||
t->setCursor(bv, sstate.lpar, sstate.pos);
|
||||
} else {
|
||||
t->setCursor(bv, sstate.lpar, sstate.pos, true, sstate.boundary);
|
||||
t->selection.cursor = t->cursor;
|
||||
t->selection.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,6 +211,22 @@ public:
|
||||
/// Set the status to make a paint pending.
|
||||
void status(BufferView *, text_status) const;
|
||||
|
||||
/// clear any pending paints
|
||||
void clearPaint();
|
||||
|
||||
/// post notice that we changed during a draw
|
||||
void postChangedInDraw();
|
||||
|
||||
/**
|
||||
* Mark position y as the starting point for a repaint
|
||||
*/
|
||||
void postPaint(BufferView & bv, int start_y);
|
||||
|
||||
/**
|
||||
* Mark the given row at position y as needing a repaint.
|
||||
*/
|
||||
void postRowPaint(BufferView & bv, Row * row, int start_y);
|
||||
|
||||
///
|
||||
Inset::RESULT dispatch(FuncRequest const & cmd);
|
||||
|
||||
|
76
src/text.C
76
src/text.C
@ -1453,19 +1453,19 @@ void LyXText::breakParagraph(BufferView * bview,
|
||||
cursorLeft(bview);
|
||||
}
|
||||
|
||||
status(bview, LyXText::NEED_MORE_REFRESH);
|
||||
refresh_row = cursor.row();
|
||||
refresh_y = cursor.y() - cursor.row()->baseline();
|
||||
int y = cursor.y() - cursor.row()->baseline();
|
||||
|
||||
// Do not forget the special right address boxes
|
||||
if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
|
||||
while (refresh_row->previous() &&
|
||||
refresh_row->previous()->par() == refresh_row->par())
|
||||
{
|
||||
refresh_row = refresh_row->previous();
|
||||
refresh_y -= refresh_row->height();
|
||||
Row * r = cursor.row();
|
||||
while (r->previous() && r->previous()->par() == r->par()) {
|
||||
r = r->previous();
|
||||
y -= r->height();
|
||||
}
|
||||
}
|
||||
|
||||
postPaint(*bview, y);
|
||||
|
||||
removeParagraph(cursor.row());
|
||||
|
||||
// set the dimensions of the cursor row
|
||||
@ -1660,9 +1660,8 @@ void LyXText::insertChar(BufferView * bview, char c)
|
||||
setHeightOfRow(bview, row->previous());
|
||||
|
||||
y -= row->previous()->height();
|
||||
refresh_y = y;
|
||||
refresh_row = row->previous();
|
||||
status(bview, LyXText::NEED_MORE_REFRESH);
|
||||
|
||||
postPaint(*bview, y);
|
||||
|
||||
breakAgainOneRow(bview, row);
|
||||
|
||||
@ -1695,9 +1694,7 @@ void LyXText::insertChar(BufferView * bview, char c)
|
||||
}
|
||||
|
||||
if (c == Paragraph::META_INSET || row->fill() < 0) {
|
||||
refresh_y = y;
|
||||
refresh_row = row;
|
||||
status(bview, LyXText::NEED_MORE_REFRESH);
|
||||
postPaint(*bview, y);
|
||||
breakAgainOneRow(bview, row);
|
||||
// will the cursor be in another row now?
|
||||
if (row->lastPos() <= cursor.pos() + 1 && row->next()) {
|
||||
@ -1720,15 +1717,16 @@ void LyXText::insertChar(BufferView * bview, char c)
|
||||
else
|
||||
need_break_row = 0;
|
||||
} else {
|
||||
refresh_y = y;
|
||||
refresh_row = row;
|
||||
|
||||
// FIXME: similar code is duplicated all over - make resetHeightOfRow
|
||||
int const tmpheight = row->height();
|
||||
|
||||
setHeightOfRow(bview, row);
|
||||
if (tmpheight == row->height())
|
||||
status(bview, LyXText::NEED_VERY_LITTLE_REFRESH);
|
||||
else
|
||||
status(bview, LyXText::NEED_MORE_REFRESH);
|
||||
|
||||
if (tmpheight == row->height()) {
|
||||
postRowPaint(*bview, row, y);
|
||||
} else {
|
||||
postPaint(*bview, y);
|
||||
}
|
||||
|
||||
current_font = rawtmpfont;
|
||||
real_current_font = realtmpfont;
|
||||
@ -2344,11 +2342,9 @@ void LyXText::changeCase(BufferView & bview, LyXText::TextCase action)
|
||||
|
||||
++pos;
|
||||
}
|
||||
if (to.row() != from.row()) {
|
||||
refresh_y = from.y() - from.row()->baseline();
|
||||
refresh_row = from.row();
|
||||
status(&bview, LyXText::NEED_MORE_REFRESH);
|
||||
}
|
||||
|
||||
if (to.row() != from.row())
|
||||
postPaint(bview, from.y() - from.row()->baseline());
|
||||
}
|
||||
|
||||
|
||||
@ -2468,9 +2464,7 @@ void LyXText::backspace(BufferView * bview)
|
||||
int const tmpheight = cursor.row()->height();
|
||||
setHeightOfRow(bview, cursor.row());
|
||||
if (cursor.row()->height() != tmpheight) {
|
||||
refresh_y = cursor.y() - cursor.row()->baseline();
|
||||
refresh_row = cursor.row();
|
||||
status(bview, LyXText::NEED_MORE_REFRESH);
|
||||
postPaint(*bview, cursor.y() - cursor.row()->baseline());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -2524,9 +2518,7 @@ void LyXText::backspace(BufferView * bview)
|
||||
if (cursor.pos())
|
||||
cursor.pos(cursor.pos() - 1);
|
||||
|
||||
status(bview, LyXText::NEED_MORE_REFRESH);
|
||||
refresh_row = cursor.row();
|
||||
refresh_y = cursor.y() - cursor.row()->baseline();
|
||||
postPaint(*bview, cursor.y() - cursor.row()->baseline());
|
||||
|
||||
// remove the lost paragraph
|
||||
// This one is not safe, since the paragraph that the tmprow and the
|
||||
@ -2655,9 +2647,8 @@ void LyXText::backspace(BufferView * bview)
|
||||
tmprow->fill(fill(*bview, *tmprow, workWidth(*bview)));
|
||||
setHeightOfRow(bview, tmprow);
|
||||
|
||||
refresh_y = y;
|
||||
refresh_row = tmprow;
|
||||
status(bview, LyXText::NEED_MORE_REFRESH);
|
||||
postPaint(*bview, y);
|
||||
|
||||
setCursor(bview, cursor.par(), cursor.pos(),
|
||||
false, cursor.boundary());
|
||||
//current_font = rawtmpfont;
|
||||
@ -2683,9 +2674,7 @@ void LyXText::backspace(BufferView * bview)
|
||||
if (row->lastPos() == row->par()->size() - 1)
|
||||
removeRow(row->next());
|
||||
|
||||
refresh_y = y;
|
||||
refresh_row = row;
|
||||
status(bview, LyXText::NEED_MORE_REFRESH);
|
||||
postPaint(*bview, y);
|
||||
|
||||
breakAgainOneRow(bview, row);
|
||||
// will the cursor be in another row now?
|
||||
@ -2706,12 +2695,11 @@ void LyXText::backspace(BufferView * bview)
|
||||
row->fill(fill(*bview, *row, workWidth(*bview)));
|
||||
int const tmpheight = row->height();
|
||||
setHeightOfRow(bview, row);
|
||||
if (tmpheight == row->height())
|
||||
status(bview, LyXText::NEED_VERY_LITTLE_REFRESH);
|
||||
else
|
||||
status(bview, LyXText::NEED_MORE_REFRESH);
|
||||
refresh_y = y;
|
||||
refresh_row = row;
|
||||
if (tmpheight == row->height()) {
|
||||
postRowPaint(*bview, row, y);
|
||||
} else {
|
||||
postPaint(*bview, y);
|
||||
}
|
||||
setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary());
|
||||
}
|
||||
}
|
||||
|
71
src/text2.C
71
src/text2.C
@ -79,12 +79,11 @@ void LyXText::init(BufferView * bview, bool reinit)
|
||||
}
|
||||
|
||||
lastrow = 0;
|
||||
refresh_row = 0;
|
||||
need_break_row = 0;
|
||||
width = height = 0;
|
||||
copylayouttype.erase();
|
||||
top_y(refresh_y = 0);
|
||||
status_ = LyXText::UNCHANGED;
|
||||
top_y(0);
|
||||
clearPaint();
|
||||
} else if (firstrow)
|
||||
return;
|
||||
|
||||
@ -2494,6 +2493,72 @@ void LyXText::status(BufferView * bview, LyXText::text_status new_status) const
|
||||
}
|
||||
|
||||
|
||||
void LyXText::clearPaint()
|
||||
{
|
||||
status_ = UNCHANGED;
|
||||
refresh_row = 0;
|
||||
refresh_y = 0;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::postChangedInDraw()
|
||||
{
|
||||
status_ = CHANGED_IN_DRAW;
|
||||
}
|
||||
|
||||
|
||||
void LyXText::postPaint(BufferView & bv, int start_y)
|
||||
{
|
||||
status_ = NEED_MORE_REFRESH;
|
||||
refresh_y = start_y;
|
||||
refresh_row = 0;
|
||||
|
||||
if (!inset_owner)
|
||||
return;
|
||||
|
||||
// We are an inset's lyxtext. Tell the top-level lyxtext
|
||||
// it needs to update the row we're in.
|
||||
|
||||
LyXText * t = bv.text;
|
||||
|
||||
// FIXME: but what if this row is below ?
|
||||
if (!t->refresh_row) {
|
||||
t->refresh_row = t->cursor.row();
|
||||
t->refresh_y = t->cursor.y() - t->cursor.row()->baseline();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FIXME: we should probably remove this y parameter,
|
||||
// make refresh_y be 0, and use row->y etc.
|
||||
void LyXText::postRowPaint(BufferView & bv, Row * row, int start_y)
|
||||
{
|
||||
// FIXME: shouldn't this check that we're not updating
|
||||
// above the existing refresh_y ??
|
||||
if (status_ == NEED_MORE_REFRESH)
|
||||
return;
|
||||
|
||||
status_ = NEED_VERY_LITTLE_REFRESH;
|
||||
refresh_y = start_y;
|
||||
refresh_row = row;
|
||||
|
||||
if (!inset_owner)
|
||||
return;
|
||||
|
||||
// We are an inset's lyxtext. Tell the top-level lyxtext
|
||||
// it needs to update the row we're in.
|
||||
|
||||
LyXText * t = bv.text;
|
||||
|
||||
// FIXME: but what if this new row is above ?
|
||||
// Why the !t->refresh_row at all ?
|
||||
if (!t->refresh_row) {
|
||||
t->refresh_row = t->cursor.row();
|
||||
t->refresh_y = t->cursor.y() - t->cursor.row()->baseline();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool LyXText::isTopLevel() const
|
||||
{
|
||||
/// only the top-level lyxtext has a non-null bv owner
|
||||
|
@ -429,11 +429,9 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
||||
par->params().startOfAppendix(start);
|
||||
|
||||
// we can set the refreshing parameters now
|
||||
status(cmd.view(), LyXText::NEED_MORE_REFRESH);
|
||||
updateCounters(cmd.view());
|
||||
redoHeightOfParagraph(bv);
|
||||
refresh_y = 0;
|
||||
refresh_row = 0;
|
||||
postPaint(*cmd.view(), 0);
|
||||
setCursor(cmd.view(), cursor.par(), cursor.pos());
|
||||
update(bv);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user