paint cleanups as sent to list

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6517 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-03-17 01:34:36 +00:00
parent 1a66f02a3a
commit 3b9620ae6d
45 changed files with 252 additions and 616 deletions

View File

@ -500,12 +500,10 @@ void BufferView::Pimpl::workAreaResize()
void BufferView::Pimpl::update()
{
if (!bv_->theLockingInset() || !bv_->theLockingInset()->nodraw()) {
LyXText::text_status st = bv_->text->status();
screen().update(bv_->text, bv_);
screen().update(*bv_);
bool fitc = false;
while (bv_->text->status() == LyXText::CHANGED_IN_DRAW) {
bv_->text->fullRebreak(bv_);
st = LyXText::NEED_MORE_REFRESH;
bv_->text->setCursor(bv_, bv_->text->cursor.par(),
bv_->text->cursor.pos());
if (bv_->text->selection.set()) {
@ -517,12 +515,14 @@ void BufferView::Pimpl::update()
bv_->text->selection.end.pos());
}
fitc = true;
bv_->text->status(bv_, st);
screen().update(bv_->text, bv_);
bv_->text->postPaint(*bv_, 0);
screen().update(*bv_);
}
// do this here instead of in the screen::update because of
// the above loop!
bv_->text->status(bv_, LyXText::UNCHANGED);
bv_->text->clearPaint();
if (fitc)
fitCursor();
}

View File

@ -1,3 +1,14 @@
2003-03-17 John Levon <levon@movementarian.org>
* lyxtext.h:
* undo_funcs.C:
* text2.C: more paint cleanups
* BufferView_pimpl.C: screen prototype changed, use postPaint etc.
* rowpainter.h:
* rowpainter.C: remove "smart" background painting code
2003-03-16 John Levon <levon@movementarian.org>
* lyxtext.h:

View File

@ -1,3 +1,9 @@
2003-03-17 John Levon <levon@movementarian.org>
* screen.h:
* screen.C: remove cleared/background painting code,
update() was taking a pointless LyXText parameter
2003-03-13 Angus Leeming <leeming@lyx.org>
* Dialogs.h: remove showParagraph and updateParagraph.

View File

@ -111,7 +111,7 @@ SplashScreen::SplashScreen()
LyXScreen::LyXScreen()
: cursor_visible_(false), force_clear_(true), greyed_out_(true)
: cursor_visible_(false), greyed_out_(true)
{
// Start loading the pixmap as soon as possible
if (lyxrc.show_banner) {
@ -244,11 +244,11 @@ bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
}
void LyXScreen::update(LyXText * text, BufferView * bv,
int yo, int xo)
void LyXScreen::update(BufferView & bv, int yo, int xo)
{
int const vwidth = workarea().workWidth();
int const vheight = workarea().workHeight();
LyXText * text = bv.text;
workarea().getPainter().start();
@ -256,27 +256,18 @@ void LyXScreen::update(LyXText * text, BufferView * bv,
case LyXText::NEED_MORE_REFRESH:
{
int const y = max(int(text->refresh_y - text->top_y()), 0);
drawFromTo(text, bv, y, vheight, yo, xo);
text->refresh_y = 0;
// otherwise this is called ONLY from BufferView_pimpl(update)
// or we should see to set this flag accordingly
if (text != bv->text)
text->status(bv, LyXText::UNCHANGED);
drawFromTo(text, &bv, y, vheight, yo, xo);
expose(0, y, vwidth, vheight - y);
}
break;
case LyXText::NEED_VERY_LITTLE_REFRESH:
{
// ok I will update the current cursor row
drawOneRow(text, bv, text->refresh_row, text->refresh_y,
drawOneRow(text, &bv, text->refresh_row, text->refresh_y,
yo, xo);
// this because if we had a major update the refresh_row could
// have been set to 0!
if (text->refresh_row) {
// otherwise this is called ONLY from BufferView_pimpl(update)
// or we should see to set this flag accordingly
if (text != bv->text)
text->status(bv, LyXText::UNCHANGED);
expose(0, text->refresh_y - text->top_y() + yo,
vwidth, text->refresh_row->height());
}
@ -448,9 +439,8 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
internal = internal && (st != LyXText::CHANGED_IN_DRAW);
while (internal && text->status() == LyXText::CHANGED_IN_DRAW) {
text->fullRebreak(bv);
st = LyXText::NEED_MORE_REFRESH;
text->setCursor(bv, text->cursor.par(), text->cursor.pos());
text->status(bv, st);
text->postPaint(*bv, 0);
Row * prev = row->previous();
RowPainter rp(*bv, *text, *row);
if (rp.paint(y + yo, xo, y + text->top_y()))
@ -459,7 +449,6 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
y += row->height();
row = row->next();
}
force_clear_ = false;
// maybe we have to clear the screen at the bottom
if ((y < y2) && text->isTopLevel()) {
@ -482,5 +471,4 @@ void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
if (rp.paint(y, xo, y + text->top_y()))
text->markChangeInDraw(bv, row, prev);
}
force_clear_ = false;
}

View File

@ -118,18 +118,17 @@ public:
/**
* update - update part of the screen rendering
* @param text the containing text region
* @param bv the bufferview
* @param xo the x offset into the text
* @param yo the x offset into the text
*
* Updates part of the screen. If text->status is
* Updates part of the screen. If bv->text->status is
* LyXText::NEED_MORE_REFRESH, we update from the
* point of change and to the end of the screen.
* If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
* we only update the current row.
*/
virtual void update(LyXText * text, BufferView * bv, int yo = 0, int xo = 0);
virtual void update(BufferView & bv, int yo = 0, int xo = 0);
/// FIXME
virtual void toggleSelection(LyXText *, BufferView *, bool = true,
@ -139,9 +138,6 @@ public:
virtual void toggleToggle(LyXText *, BufferView *,
int y_offset = 0, int x_offset = 0);
/// FIXME
virtual bool forceClear() const { return force_clear_; }
protected:
/// cause the display of the given area of the work area
virtual void expose(int x, int y, int w, int h) = 0;
@ -164,9 +160,6 @@ private:
/// grey out (no buffer)
void greyOut();
/// FIXME ?
bool force_clear_;
/// is the screen displaying text or the splash screen?
bool greyed_out_;
};

View File

@ -1,3 +1,9 @@
2003-03-17 John Levon <levon@movementarian.org>
* most files: remove the "cleared" parameter
to draw in favour of always clearing. Associated
code removal.
2003-03-16 John Levon <levon@movementarian.org>
* insettext.C: remove unused s.refresh

View File

@ -162,8 +162,7 @@ public:
///
virtual int width(BufferView *, LyXFont const &) const = 0;
///
virtual void draw(BufferView *, LyXFont const &,
int baseline, float & x, bool cleared) const = 0;
virtual void draw(BufferView *, LyXFont const &, int baseline, float & x) const = 0;
/// update the inset representation
virtual void update(BufferView *, LyXFont const &, bool = false)
{}
@ -177,8 +176,6 @@ public:
virtual EDITABLE editable() const;
///
virtual bool isTextInset() const { return false; }
///
virtual bool doClearArea() const { return true; }
/// return true if the inset should be removed automatically
virtual bool autoDelete() const;
/// returns true the inset can hold an inset of given type

View File

@ -93,7 +93,7 @@ int InsetButton::width(BufferView * bv, LyXFont const &) const
void InsetButton::draw(BufferView * bv, LyXFont const &,
int baseline, float & x, bool) const
int baseline, float & x) const
{
lyx::Assert(bv);
cache(bv);

View File

@ -30,7 +30,7 @@ public:
///
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
void draw(BufferView *, LyXFont const &, int, float &) const;
protected:
///

View File

@ -66,7 +66,7 @@ string const InsetCaption::editMessage() const
void InsetCaption::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x, bool cleared) const
int baseline, float & x) const
{
// We must draw the label, we should get the label string
// from the enclosing float inset.
@ -101,7 +101,7 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
pain.text(int(x), baseline, label, f);
x += w;
InsetText::draw(bv, f, baseline, x, cleared);
InsetText::draw(bv, f, baseline, x);
}

View File

@ -40,7 +40,7 @@ public:
///
virtual
void draw(BufferView * bv, LyXFont const & f,
int baseline, float & x, bool cleared) const;
int baseline, float & x) const;
///
virtual
int latex(Buffer const * buf, std::ostream & os,

View File

@ -183,14 +183,14 @@ void InsetCollapsable::draw_collapsed(Painter & pain,
void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x, bool cleared) const
int baseline, float & x) const
{
lyx::Assert(bv);
cache(bv);
if (need_update != NONE) {
const_cast<InsetText *>(&inset)->update(bv, f, true);
bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
bv->text->postChangedInDraw();
need_update = NONE;
return;
}
@ -214,18 +214,6 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
if (!owner())
x += static_cast<float>(scroll());
if (!cleared && (inset.need_update == InsetText::FULL ||
inset.need_update == InsetText::INIT ||
top_x != int(x) ||
top_baseline != baseline))
{
// we don't need anymore to clear here we just have to tell
// the underlying LyXText that it should do the RowClear!
inset.setUpdateStatus(bv, InsetText::FULL);
bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
return;
}
top_x = int(x);
topx_set = true;
top_baseline = baseline;
@ -233,9 +221,7 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
int const bl = baseline - ascent(bv, f) + ascent_collapsed();
draw_collapsed(pain, bl, old_x);
inset.draw(bv, f,
bl + descent_collapsed() + inset.ascent(bv, f),
x, cleared);
inset.draw(bv, f, bl + descent_collapsed() + inset.ascent(bv, f), x);
if (x < (top_x + button_length + TEXT_TO_INSET_OFFSET))
x = top_x + button_length + TEXT_TO_INSET_OFFSET;
}
@ -563,12 +549,6 @@ void InsetCollapsable::setFont(BufferView * bv, LyXFont const & font,
}
bool InsetCollapsable::doClearArea() const
{
return inset.doClearArea();
}
LyXText * InsetCollapsable::getLyXText(BufferView const * bv,
bool const recursive) const
{

View File

@ -56,7 +56,7 @@ public:
///
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
void draw(BufferView *, const LyXFont &, int , float &) const;
///
void update(BufferView *, LyXFont const &, bool =false);
///
@ -74,8 +74,6 @@ public:
///
bool isTextInset() const { return true; }
///
bool doClearArea() const;
///
void insetUnlock(BufferView *);
///
bool needFullRow() const { return isOpen(); }

View File

@ -81,7 +81,7 @@ int InsetError::width(BufferView *, LyXFont const & font) const
void InsetError::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x, bool) const
int baseline, float & x) const
{
lyx::Assert(bv);
cache(bv);

View File

@ -37,7 +37,7 @@ public:
///
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
void draw(BufferView *, LyXFont const &, int, float &) const;
///
void write(Buffer const *, std::ostream &) const {}
///

View File

@ -567,7 +567,7 @@ int InsetERT::width(BufferView * bv, LyXFont const & font) const
void InsetERT::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x, bool cleared) const
int baseline, float & x) const
{
lyx::Assert(bv);
cache(bv);
@ -589,18 +589,6 @@ void InsetERT::draw(BufferView * bv, LyXFont const & f,
if (!owner())
x += static_cast<float>(scroll());
if (!cleared && (inset.need_update == InsetText::FULL ||
inset.need_update == InsetText::INIT ||
top_x != int(x) ||
top_baseline != baseline))
{
// we don't need anymore to clear here we just have to tell
// the underlying LyXText that it should do the RowClear!
inset.setUpdateStatus(bv, InsetText::FULL);
bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
return;
}
top_x = int(x);
topx_set = true;
top_baseline = baseline;
@ -608,12 +596,10 @@ void InsetERT::draw(BufferView * bv, LyXFont const & f,
int const bl = baseline - ascent(bv, f) + ascent_collapsed();
if (inlined()) {
inset.draw(bv, f, baseline, x, cleared);
inset.draw(bv, f, baseline, x);
} else {
draw_collapsed(pain, bl, old_x);
inset.draw(bv, f,
bl + descent_collapsed() + inset.ascent(bv, f),
x, cleared);
inset.draw(bv, f, bl + descent_collapsed() + inset.ascent(bv, f), x);
}
need_update = NONE;
}

View File

@ -109,7 +109,7 @@ public:
///
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
void draw(BufferView *, const LyXFont &, int , float &) const;
/// set the status of the inset
void status(BufferView *, ERTStatus const st) const;
///

View File

@ -344,7 +344,7 @@ BufferView * InsetGraphics::view() const
void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x, bool) const
int baseline, float & x) const
{
// MakeAbsPath returns params().filename unchanged if it absolute
// already.
@ -418,21 +418,6 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
paint.text(old_x + TEXT_TO_INSET_OFFSET + 6, baseline - 4, msg, msgFont);
}
}
// the status message may mean we changed size, so indicate
// we need a row redraw
#if 0
if (old_status_ != grfx::ErrorUnknown && old_status_ != cached_status_) {
bv->getLyXText()->status(bv, LyXText::CHANGED_IN_DRAW);
}
#endif
// Reset the cache, ready for the next draw request
#if 0
cached_status_ = grfx::ErrorUnknown;
cached_image_.reset();
cache_filled_ = false;
#endif
}

View File

@ -43,7 +43,7 @@ public:
///
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
void draw(BufferView *, LyXFont const &, int, float &) const;
///
void edit(BufferView *, int, int, mouse_button::state);
///

View File

@ -557,11 +557,11 @@ int InsetInclude::width(BufferView * bv, LyXFont const & font) const
void InsetInclude::draw(BufferView * bv, LyXFont const & font, int y,
float & xx, bool b) const
float & xx) const
{
cache(bv);
if (!preview_->previewReady()) {
InsetButton::draw(bv, font, y, xx, b);
InsetButton::draw(bv, font, y, xx);
return;
}

View File

@ -67,7 +67,7 @@ public:
///
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
void draw(BufferView *, LyXFont const &, int, float &) const;
/// get the parameters
Params const & params(void) const;

View File

@ -360,7 +360,7 @@ bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font,
void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
int baseline, float & x, bool) const
int baseline, float & x) const
{
Painter & pain = bv->painter();

View File

@ -40,7 +40,7 @@ public:
///
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
void draw(BufferView *, LyXFont const &, int, float &) const;
///
int lbearing(LyXFont const & font) const;
///

View File

@ -88,7 +88,7 @@ int InsetNewline::docbook(Buffer const *, std::ostream &, bool) const
void InsetNewline::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x, bool) const
int baseline, float & x) const
{
Painter & pain(bv->painter());

View File

@ -33,7 +33,7 @@ public:
virtual int width(BufferView *, LyXFont const &) const;
virtual void draw(BufferView *, LyXFont const &,
int baseline, float & x, bool cleared) const;
int baseline, float & x) const;
virtual int latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;

View File

@ -218,7 +218,7 @@ LyXFont const InsetQuotes::convertFont(LyXFont const & f) const
void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x, bool) const
int baseline, float & x) const
{
string const text = dispString(font.language());

View File

@ -76,7 +76,7 @@ public:
///
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
void draw(BufferView *, LyXFont const &, int, float &) const;
#if 0
///
LyXFont const convertFont(LyXFont const & font) const;

View File

@ -85,7 +85,7 @@ int InsetSpecialChar::width(BufferView *, LyXFont const & font) const
void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x, bool) const
int baseline, float & x) const
{
Painter & pain = bv->painter();
LyXFont font(f);

View File

@ -54,7 +54,7 @@ public:
///
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
void draw(BufferView *, LyXFont const &, int, float &) const;
///
void write(Buffer const *, std::ostream &) const;
/// Will not be used when lyxf3

View File

@ -261,20 +261,12 @@ int InsetTabular::width(BufferView *, LyXFont const &) const
void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
float & x, bool cleared) const
float & x) const
{
if (nodraw()) {
if (cleared)
need_update = FULL;
need_update = FULL;
return;
}
#if 0
if (need_update == INIT) {
if (calculate_dimensions_of_cells(bv, font, true))
bv->text->status = LyXText::CHANGED_IN_DRAW;
need_update = FULL;
}
#endif
Painter & pain = bv->painter();
int i;
@ -282,173 +274,53 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
int nx;
#if 0
UpdatableInset::draw(bv, font, baseline, x, cleared);
UpdatableInset::draw(bv, font, baseline, x);
#else
if (!owner())
x += static_cast<float>(scroll());
#endif
if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
(top_x != int(x)) || (top_baseline != baseline)))
{
int h = ascent(bv, font) + descent(bv, font);
int const tx = display() || !owner() ? 0 : top_x;
int w = tx ? width(bv, font) : pain.paperWidth();
int ty = baseline - ascent(bv, font);
if (ty < 0)
ty = 0;
if ((ty + h) > pain.paperHeight())
h = pain.paperHeight();
if ((top_x + w) > pain.paperWidth())
w = pain.paperWidth();
pain.fillRectangle(tx, ty, w, h, backgroundColor());
need_update = FULL;
cleared = true;
}
top_x = int(x);
topx_set = true;
top_baseline = baseline;
x += ADD_TO_TABULAR_WIDTH;
if (cleared) {
int cell = 0;
float cx;
first_visible_cell = -1;
for (i = 0; i < tabular->rows(); ++i) {
nx = int(x);
cell = tabular->GetCellNumber(i, 0);
if (!((baseline + tabular->GetDescentOfRow(i)) > 0) &&
(baseline - tabular->GetAscentOfRow(i))<pain.paperHeight())
{
baseline += tabular->GetDescentOfRow(i) +
tabular->GetAscentOfRow(i + 1) +
tabular->GetAdditionalHeight(i + 1);
continue;
}
for (j = 0; j < tabular->columns(); ++j) {
if (nx > bv->workWidth())
break;
if (tabular->IsPartOfMultiColumn(i, j))
continue;
cx = nx + tabular->GetBeginningOfTextInCell(cell);
if (first_visible_cell < 0)
first_visible_cell = cell;
if (hasSelection()) {
drawCellSelection(pain, nx, baseline, i, j, cell);
}
tabular->GetCellInset(cell)->draw(bv, font, baseline, cx, cleared);
drawCellLines(pain, nx, baseline, i, cell);
nx += tabular->GetWidthOfColumn(cell);
++cell;
}
baseline += tabular->GetDescentOfRow(i) +
int cell = 0;
float cx;
first_visible_cell = -1;
for (i = 0; i < tabular->rows(); ++i) {
nx = int(x);
cell = tabular->GetCellNumber(i, 0);
if (!((baseline + tabular->GetDescentOfRow(i)) > 0) &&
(baseline - tabular->GetAscentOfRow(i))<pain.paperHeight())
{
baseline += tabular->GetDescentOfRow(i) +
tabular->GetAscentOfRow(i + 1) +
tabular->GetAdditionalHeight(i + 1);
continue;
}
} else if (need_update == CELL) {
int cell = 0;
nx = int(x);
if (the_locking_inset &&
tabular->GetCellInset(actcell) != the_locking_inset)
{
Inset * inset = tabular->GetCellInset(cell);
for (i = 0;
inset != the_locking_inset && i < tabular->rows();
++i)
{
for (j = 0;
inset != the_locking_inset && j < tabular->columns();
++j)
{
if (tabular->IsPartOfMultiColumn(i, j))
continue;
nx += tabular->GetWidthOfColumn(cell);
++cell;
inset = tabular->GetCellInset(cell);
}
if (tabular->row_of_cell(cell) > i) {
nx = int(x);
baseline += tabular->GetDescentOfRow(i) +
tabular->GetAscentOfRow(i + 1) +
tabular->GetAdditionalHeight(i + 1);
}
}
} else {
// compute baseline for actual row
for (i = 0; i < actrow; ++i) {
baseline += tabular->GetDescentOfRow(i) +
tabular->GetAscentOfRow(i + 1) +
tabular->GetAdditionalHeight(i + 1);
}
// now compute the right x position
cell = tabular->GetCellNumber(actrow, 0);
for (j = 0; (cell < actcell) && (j < tabular->columns()); ++j) {
if (tabular->IsPartOfMultiColumn(actrow, j))
continue;
nx += tabular->GetWidthOfColumn(cell);
++cell;
for (j = 0; j < tabular->columns(); ++j) {
if (nx > bv->workWidth())
break;
if (tabular->IsPartOfMultiColumn(i, j))
continue;
cx = nx + tabular->GetBeginningOfTextInCell(cell);
if (first_visible_cell < 0)
first_visible_cell = cell;
if (hasSelection()) {
drawCellSelection(pain, nx, baseline, i, j, cell);
}
tabular->GetCellInset(cell)->draw(bv, font, baseline, cx);
drawCellLines(pain, nx, baseline, i, cell);
nx += tabular->GetWidthOfColumn(cell);
++cell;
}
i = tabular->row_of_cell(cell);
if (the_locking_inset != tabular->GetCellInset(cell)) {
lyxerr[Debug::INSETTEXT] << "ERROR this shouldn't happen\n";
return;
}
float dx = nx + tabular->GetBeginningOfTextInCell(cell);
float cx = dx;
tabular->GetCellInset(cell)->draw(bv, font, baseline, dx, false);
//
// Here we use rectangular backgroundColor patches to clean up
// within a cell around the cell's red inset box. As follows:
//
// +--------------------+
// | C | The rectangles are A, B and C
// | A |------------| B | below, origin top left (tx, ty),
// | | inset box | | dimensions w(idth), h(eight).
// +---+------------+---+ x grows rightward, y downward
// | D |
// +--------------------+
//
#if 0
// clear only if we didn't have a change
if (bv->text->status() != LyXText::CHANGED_IN_DRAW) {
#endif
// clear before the inset
int tx, ty, w, h;
tx = nx + 1;
ty = baseline - tabular->GetAscentOfRow(i) + 1;
w = int(cx - nx - 1);
h = tabular->GetAscentOfRow(i) +
tabular->GetDescentOfRow(i) - 1;
pain.fillRectangle(tx, ty, w, h, backgroundColor());
// clear behind the inset
tx = int(cx + the_locking_inset->width(bv,font) + 1);
ty = baseline - tabular->GetAscentOfRow(i) + 1;
w = tabular->GetWidthOfColumn(cell) -
tabular->GetBeginningOfTextInCell(cell) -
the_locking_inset->width(bv,font) -
tabular->GetAdditionalWidth(cell) - 1;
h = tabular->GetAscentOfRow(i) + tabular->GetDescentOfRow(i) - 1;
pain.fillRectangle(tx, ty, w, h, backgroundColor());
// clear below the inset
tx = nx + 1;
ty = baseline + the_locking_inset->descent(bv, font) + 1;
w = tabular->GetWidthOfColumn(cell) -
tabular->GetAdditionalWidth(cell) - 1;
h = tabular->GetDescentOfRow(i) -
the_locking_inset->descent(bv, font) - 1;
pain.fillRectangle(tx, ty, w, h, backgroundColor());
// clear above the inset
tx = nx + 1;
ty = baseline - tabular->GetAscentOfRow(i) + 1;
w = tabular->GetWidthOfColumn(cell) -
tabular->GetAdditionalWidth(cell) - 1;
h = tabular->GetAscentOfRow(i) - the_locking_inset->ascent(bv, font);
pain.fillRectangle(tx, ty, w, h, backgroundColor());
#if 0
}
#endif
baseline += tabular->GetDescentOfRow(i) +
tabular->GetAscentOfRow(i + 1) +
tabular->GetAdditionalHeight(i + 1);
}
x -= ADD_TO_TABULAR_WIDTH;
x += width(bv, font);
if (bv->text->status() == LyXText::CHANGED_IN_DRAW) {
@ -2674,12 +2546,6 @@ int InsetTabular::scroll(bool recursive) const
}
bool InsetTabular::doClearArea() const
{
return !locked || (need_update & (FULL|INIT));
}
void InsetTabular::getSelection(int & srow, int & erow,
int & scol, int & ecol) const
{

View File

@ -92,7 +92,7 @@ public:
///
int width(BufferView *, LyXFont const & f) const;
///
void draw(BufferView *, const LyXFont &, int , float &, bool) const;
void draw(BufferView *, const LyXFont &, int , float &) const;
///
void update(BufferView *, LyXFont const &, bool = false);
///
@ -101,9 +101,7 @@ public:
void edit(BufferView *, int x, int y, mouse_button::state);
///
void edit(BufferView * bv, bool front = true);
///
bool doClearArea() const;
///
//
void insetUnlock(BufferView *);
///
void updateLocal(BufferView *, UpdateCodes, bool mark_dirty) const;

View File

@ -194,7 +194,6 @@ void InsetText::init(InsetText const * ins, bool same_id)
locked = false;
old_par = 0;
last_drawn_width = -1;
frame_is_visible = false;
cached_bview = 0;
sstate.lpar = 0;
in_insetAllowed = false;
@ -346,7 +345,7 @@ int InsetText::textWidth(BufferView * bv, bool fordraw) const
void InsetText::draw(BufferView * bv, LyXFont const & f,
int baseline, float & x, bool cleared) const
int baseline, float & x) const
{
if (nodraw())
return;
@ -356,7 +355,6 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
// this is the first thing we have to ask because if the x pos
// changed we have to do a complete rebreak of the text as we
// may have few space to draw in. Well we should check on this too
int old_x = top_x;
if (top_x != int(x)) {
top_x = int(x);
topx_set = true;
@ -364,7 +362,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
if (nw > 0 && old_max_width != nw) {
need_update = INIT;
old_max_width = nw;
bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
bv->text->postChangedInDraw();
return;
}
}
@ -376,16 +374,13 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
descent(bv, f);
// repaint the background if needed
if (cleared && backgroundColor() != LColor::background) {
clearInset(bv, baseline, cleared);
}
if (backgroundColor() != LColor::background)
clearInset(bv, baseline);
// no draw is necessary !!!
if ((drawFrame_ == LOCKED) && !locked && paragraphs.begin()->empty()) {
top_baseline = baseline;
x += width(bv, f);
if (need_update & CLEAR_FRAME)
clearFrame(pain, cleared);
need_update = NONE;
return;
}
@ -393,31 +388,10 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
if (!owner())
x += static_cast<float>(scroll());
// if top_x differs we did it already
if (!cleared && (old_x == int(x))
&& ((need_update&(INIT|FULL)) || (top_baseline != baseline)
||(last_drawn_width != insetWidth)))
{
// Condition necessary to eliminate bug 59 attachment 37
if (baseline > 0)
clearInset(bv, baseline, cleared);
}
if (cleared)
frame_is_visible = false;
if (!cleared && (need_update == NONE)) {
if (locked)
drawFrame(pain, cleared);
return;
}
top_baseline = baseline;
top_y = baseline - insetAscent;
if (last_drawn_width != insetWidth) {
if (!cleared)
clearInset(bv, baseline, cleared);
need_update |= FULL;
last_drawn_width = insetWidth;
}
@ -427,13 +401,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
inset_x = cix(bv) - top_x + drawTextXOffset;
inset_y = ciy(bv) + drawTextYOffset;
}
if (!cleared && (need_update == CURSOR)
&& !getLyXText(bv)->selection.set()) {
drawFrame(pain, cleared);
x += insetWidth;
need_update = NONE;
return;
}
bool clear = false;
if (!lt) {
lt = getLyXText(bv);
@ -459,62 +427,38 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
lt->top_y(first);
first = 0;
}
if (cleared || (need_update&(INIT|FULL))) {
int yf = y_offset + first;
y = 0;
while ((row != 0) && (yf < ph)) {
Row * prev = row->previous();
RowPainter rp(*bv, *lt, *row);
if (rp.paint(y + y_offset + first, int(x), y + lt->top_y(), cleared))
lt->markChangeInDraw(bv, row, prev);
if (bv->text->status() == LyXText::CHANGED_IN_DRAW) {
lt->need_break_row = row;
lt->fullRebreak(bv);
lt->setCursor(bv, lt->cursor.par(),
lt->cursor.pos());
if (lt->selection.set()) {
lt->setCursor(bv, lt->selection.start,
lt->selection.start.par(),
lt->selection.start.pos());
lt->setCursor(bv, lt->selection.end,
lt->selection.end.par(),
lt->selection.end.pos());
}
break;
int yf = y_offset + first;
y = 0;
while ((row != 0) && (yf < ph)) {
Row * prev = row->previous();
RowPainter rp(*bv, *lt, *row);
if (rp.paint(y + y_offset + first, int(x), y + lt->top_y()))
lt->markChangeInDraw(bv, row, prev);
if (bv->text->status() == LyXText::CHANGED_IN_DRAW) {
lt->need_break_row = row;
lt->fullRebreak(bv);
lt->setCursor(bv, lt->cursor.par(),
lt->cursor.pos());
if (lt->selection.set()) {
lt->setCursor(bv, lt->selection.start,
lt->selection.start.par(),
lt->selection.start.pos());
lt->setCursor(bv, lt->selection.end,
lt->selection.end.par(),
lt->selection.end.pos());
}
y += row->height();
yf += row->height();
row = row->next();
break;
}
} else if (!locked) {
if (need_update & CURSOR) {
bv->screen().toggleSelection(lt, bv, true, y_offset,int(x));
lt->clearSelection();
lt->selection.cursor = lt->cursor;
}
bv->screen().update(lt, bv, y_offset, int(x));
} else {
locked = false;
if (need_update & SELECTION) {
bv->screen().toggleToggle(lt, bv, y_offset, int(x));
} else if (need_update & CURSOR) {
bv->screen().toggleSelection(lt, bv, true, y_offset,int(x));
lt->clearSelection();
lt->selection.cursor = lt->cursor;
}
bv->screen().update(lt, bv, y_offset, int(x));
locked = true;
y += row->height();
yf += row->height();
row = row->next();
}
lt->refresh_y = 0;
lt->status(bv, LyXText::UNCHANGED);
if ((drawFrame_ == ALWAYS) ||
((cleared || (need_update != CURSOR_PAR)) &&
(drawFrame_ == LOCKED) && locked))
{
drawFrame(pain, cleared);
} else if (need_update & CLEAR_FRAME) {
clearFrame(pain, cleared);
lt->clearPaint();
if ((drawFrame_ == ALWAYS) || (drawFrame_ == LOCKED && locked)) {
drawFrame(pain);
}
x += insetWidth - TEXT_TO_INSET_OFFSET;
@ -529,30 +473,15 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
}
void InsetText::drawFrame(Painter & pain, bool cleared) const
void InsetText::drawFrame(Painter & pain) const
{
static int const ttoD2 = TEXT_TO_INSET_OFFSET / 2;
if (!frame_is_visible || cleared) {
frame_x = top_x + ttoD2;
frame_y = top_baseline - insetAscent + ttoD2;
frame_w = insetWidth - TEXT_TO_INSET_OFFSET;
frame_h = insetAscent + insetDescent - TEXT_TO_INSET_OFFSET;
pain.rectangle(frame_x, frame_y, frame_w, frame_h,
frame_color);
frame_is_visible = true;
}
}
void InsetText::clearFrame(Painter & pain, bool cleared) const
{
if (frame_is_visible) {
if (!cleared) {
pain.rectangle(frame_x, frame_y, frame_w, frame_h,
backgroundColor());
}
frame_is_visible = false;
}
frame_x = top_x + ttoD2;
frame_y = top_baseline - insetAscent + ttoD2;
frame_w = insetWidth - TEXT_TO_INSET_OFFSET;
frame_h = insetAscent + insetDescent - TEXT_TO_INSET_OFFSET;
pain.rectangle(frame_x, frame_y, frame_w, frame_h,
frame_color);
}
@ -791,16 +720,8 @@ void InsetText::insetUnlock(BufferView * bv)
no_selection = true;
locked = false;
int code = NONE;
#if 0
if (drawFrame_ == LOCKED)
code = CURSOR|CLEAR_FRAME;
else
code = CURSOR;
#else
if (drawFrame_ == LOCKED)
code = CLEAR_FRAME;
#endif
bool clear = false;
if (!lt) {
lt = getLyXText(bv);
clear = true;
@ -2470,12 +2391,6 @@ int InsetText::scroll(bool recursive) const
}
bool InsetText::doClearArea() const
{
return !locked || (need_update & (FULL|INIT));
}
void InsetText::selectAll(BufferView * bv)
{
getLyXText(bv)->cursorTop(bv);
@ -2491,7 +2406,7 @@ void InsetText::clearSelection(BufferView * bv)
}
void InsetText::clearInset(BufferView * bv, int baseline, bool & cleared) const
void InsetText::clearInset(BufferView * bv, int baseline) const
{
Painter & pain = bv->painter();
int w = insetWidth;
@ -2508,9 +2423,7 @@ void InsetText::clearInset(BufferView * bv, int baseline, bool & cleared) const
w = pain.paperWidth();
// w -= TEXT_TO_INSET_OFFSET;
pain.fillRectangle(top_x + 1, ty + 1, w - 1, h - 1, backgroundColor());
cleared = true;
need_update = FULL;
frame_is_visible = false;
}

View File

@ -47,17 +47,15 @@ public:
///
CURSOR = 1,
///
CLEAR_FRAME = 2,
DRAW_FRAME = 2,
///
DRAW_FRAME = 4,
SELECTION = 4,
///
SELECTION = 8,
CURSOR_PAR = 8,
///
CURSOR_PAR = 16,
FULL = 16,
///
FULL = 32,
///
INIT = 64
INIT = 32
};
///
enum DrawFrame {
@ -94,7 +92,7 @@ public:
///
int textWidth(BufferView *, bool fordraw = false) const;
///
void draw(BufferView *, LyXFont const &, int , float &, bool) const;
void draw(BufferView *, LyXFont const &, int , float &) const;
///
void update(BufferView *, LyXFont const &, bool = false);
///
@ -108,8 +106,6 @@ public:
///
bool isTextInset() const { return true; }
///
bool doClearArea() const;
///
void insetUnlock(BufferView *);
///
bool lockInsetInInset(BufferView *, UpdatableInset *);
@ -346,11 +342,9 @@ private:
///
Row * crow(BufferView *) const;
///
void drawFrame(Painter &, bool cleared) const;
void drawFrame(Painter &) const;
///
void clearFrame(Painter &, bool cleared) const;
///
void clearInset(BufferView *, int baseline, bool & cleared) const;
void clearInset(BufferView *, int baseline) const;
///
void saveLyXTextState(LyXText *) const;
///
@ -394,8 +388,6 @@ private:
///
mutable int last_drawn_width;
///
mutable bool frame_is_visible;
///
mutable BufferView * cached_bview;
///
mutable boost::shared_ptr<LyXText> cached_text;

View File

@ -73,8 +73,7 @@ void UpdatableInset::edit(BufferView *, bool)
void UpdatableInset::draw(BufferView *, LyXFont const &,
int /* baseline */, float & x,
bool/*cleared*/) const
int /* baseline */, float & x) const
{
x += float(scx);
// ATTENTION: don't do the following here!!!

View File

@ -75,7 +75,7 @@ public:
virtual void edit(BufferView *, bool front = true);
///
virtual void draw(BufferView *, LyXFont const &,
int baseline, float & x, bool cleared) const;
int baseline, float & x) const;
///
virtual bool insertInset(BufferView *, Inset *) { return false; }
///

View File

@ -187,29 +187,6 @@ public:
///
mutable Row * need_break_row;
/**
* The pixel y position from which to repaint the screen.
* The position is absolute along the height of outermost
* lyxtext (I think). NEED_MORE_REFRESH and NEED_LITTLE_REFRESH
* repaints both use this as a starting point (if it's within
* the viewable portion of the lyxtext).
*/
mutable int refresh_y;
/**
* The row from which to repaint the screen, used by screen.c.
* This must be set if the pending update is NEED_LITTLE_REFRESH.
* It doesn't make any difference for NEED_MORE_REFRESH.
*/
mutable Row * refresh_row;
/**
* Return the status. This represents what repaints are
* pending after some operation (e.g. inserting a char).
*/
text_status status() const;
/// Set the status to make a paint pending.
void status(BufferView *, text_status) const;
/// clear any pending paints
void clearPaint();
@ -230,15 +207,36 @@ public:
///
Inset::RESULT dispatch(FuncRequest const & cmd);
friend class LyXScreen;
/**
* Return the status. This represents what repaints are
* pending after some operation (e.g. inserting a char).
*/
text_status status() const;
private:
/**
* The pixel y position from which to repaint the screen.
* The position is absolute along the height of outermost
* lyxtext (I think). NEED_MORE_REFRESH and NEED_LITTLE_REFRESH
* repaints both use this as a starting point (if it's within
* the viewable portion of the lyxtext).
*/
int refresh_y;
/**
* The row from which to repaint the screen, used by screen.c.
* This must be set if the pending update is NEED_LITTLE_REFRESH.
* It doesn't make any difference for NEED_MORE_REFRESH.
*/
mutable Row * refresh_row;
/// refresh status
text_status status_;
/// only the top-level LyXText has this non-zero
BufferView * bv_owner;
/** wether the screen needs a refresh,
starting with refresh_y
*/
mutable text_status status_;
public:
/** returns a pointer to the row near the specified y-coordinate
(relative to the whole text). y is set to the real beginning

View File

@ -194,7 +194,7 @@ void InsetFormula::read(Buffer const *, LyXLex & lex)
void InsetFormula::draw(BufferView * bv, LyXFont const & font,
int y, float & xx, bool) const
int y, float & xx) const
{
cache(bv);
// This initiates the loading of the preview, so should come

View File

@ -41,7 +41,7 @@ public:
///
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
void draw(BufferView *, LyXFont const &, int, float &) const;
///
void write(Buffer const *, std::ostream &) const;

View File

@ -37,7 +37,7 @@ public:
///
virtual int width(BufferView *, LyXFont const &) const = 0;
///
virtual void draw(BufferView *,LyXFont const &, int, float &, bool) const = 0;
virtual void draw(BufferView *,LyXFont const &, int, float &) const = 0;
/// lowest x coordinate
virtual int xlow() const;
/// highest x coordinate

View File

@ -171,7 +171,7 @@ Inset::Code InsetFormulaMacro::lyxCode() const
void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
int y, float & xx, bool /*cleared*/) const
int y, float & xx) const
{
// label
LyXFont font(f);

View File

@ -39,7 +39,7 @@ public:
///
int width(BufferView *, LyXFont const &) const;
///
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
void draw(BufferView *, LyXFont const &, int, float &) const;
///
void read(Buffer const *, LyXLex & lex);

View File

@ -114,7 +114,7 @@ bool RowPainter::paintInset(pos_type const pos)
LyXFont const & font = getFont(pos);
inset->update(perv(bv_), font, false);
inset->draw(perv(bv_), font, yo_ + row_.baseline(), x_, cleared_);
inset->draw(perv(bv_), font, yo_ + row_.baseline(), x_);
// return true if something changed when we drew an inset
@ -305,63 +305,12 @@ bool RowPainter::paintFromPos(pos_type & vpos)
}
bool RowPainter::paintBackground()
void RowPainter::paintBackground()
{
pos_type const last = row_.lastPrintablePos();
bool clear_area = true;
Inset const * inset = 0;
if (!bv_.screen().forceClear() && last == row_.pos()
&& row_.pos() < par_.size()
&& par_.isInset(row_.pos())) {
inset = par_.getInset(row_.pos());
clear_area = inset->doClearArea();
}
if (cleared_) {
return true;
}
if (clear_area) {
int const x = xo_;
int const y = yo_ < 0 ? 0 : yo_;
int const h = yo_ < 0 ? row_.height() + yo_ : row_.height();
pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
return true;
}
if (!inset)
return false;
LyXFont font(LyXFont::ALL_SANE);
// FIXME
BufferView * bv = perv(bv_);
int h = row_.baseline() - inset->ascent(bv, font);
// first clear the whole row above the inset!
if (h > 0) {
pain_.fillRectangle(xo_, yo_, width_, h, text_.backgroundColor());
}
// clear the space below the inset!
h += inset->ascent(bv, font) + inset->descent(bv, font);
if ((row_.height() - h) > 0) {
pain_.fillRectangle(xo_, yo_ + h,
width_, row_.height() - h, text_.backgroundColor());
}
// clear the space behind the inset, if needed
if (!inset->display() && !inset->needFullRow()) {
int const xp = int(x_) + inset->width(bv, font);
if (width_ - xp > 0) {
pain_.fillRectangle(xp, yo_, width_ - xp,
row_.height(), text_.backgroundColor());
}
}
return false;
int const x = xo_;
int const y = yo_ < 0 ? 0 : yo_;
int const h = yo_ < 0 ? row_.height() + yo_ : row_.height();
pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
}
@ -1021,12 +970,11 @@ bool RowPainter::paintText()
}
bool RowPainter::paint(int y_offset, int x_offset, int y, bool cleared)
bool RowPainter::paint(int y_offset, int x_offset, int y)
{
xo_ = x_offset;
yo_ = y_offset;
y_ = y;
cleared_ = cleared;
width_ = text_.isInInset()
? text_.inset_owner->textWidth(perv(bv_), true) : bv_.workWidth();
@ -1041,8 +989,10 @@ bool RowPainter::paint(int y_offset, int x_offset, int y, bool cleared)
x_ = 0;
x_ += xo_;
// clear to background if necessary
cleared_ = paintBackground();
// If we're *not* at the top-level of rows, then the
// background has already been cleared.
if (&text_ == bv_.text)
paintBackground();
// paint the selection background
if (text_.selection.set()) {

View File

@ -34,11 +34,11 @@ public:
RowPainter(BufferView const & bv, LyXText const & text, Row const & row);
/// paint the row. Returns true if CHANGED_IN_DRAW (e.g. image was loaded)
bool paint(int y_offset, int x_offset, int y, bool cleared = false);
bool paint(int y_offset, int x_offset, int y);
private:
// paint various parts
bool paintBackground();
void paintBackground();
void paintSelection();
void paintAppendix();
void paintDepthBar();
@ -94,7 +94,6 @@ private:
int yo_;
float x_;
int y_;
bool cleared_;
int width_;
float separator_;
float hfill_;

View File

@ -54,17 +54,19 @@ using lyx::pos_type;
LyXText::LyXText(BufferView * bv)
: height(0), width(0), top_row_(0), top_row_offset_(0),
inset_owner(0), the_locking_inset(0), need_break_row(0),
refresh_y(0), refresh_row(0), bv_owner(bv),
status_(LyXText::UNCHANGED), firstrow(0), lastrow(0)
{}
bv_owner(bv), firstrow(0), lastrow(0)
{
clearPaint();
}
LyXText::LyXText(InsetText * inset)
: height(0), width(0), top_row_(0), top_row_offset_(0),
inset_owner(inset), the_locking_inset(0), need_break_row(0),
refresh_y(0), refresh_row(0), bv_owner(0),
status_(LyXText::UNCHANGED), firstrow(0), lastrow(0)
{}
bv_owner(0), firstrow(0), lastrow(0)
{
clearPaint();
}
void LyXText::init(BufferView * bview, bool reinit)
@ -321,10 +323,14 @@ void LyXText::removeRow(Row * row) const
lyx::Assert(!row->next());
lastrow = row_prev;
}
/* FIXME: when we cache the bview, this should just
* become a postPaint(), I think */
if (refresh_row == row) {
refresh_row = row_prev ? row_prev : row->next();
// what about refresh_y, refresh_height
// what about refresh_y
}
if (top_row_ == row) {
if (row->next()) {
top_row_ = row->next();
@ -713,10 +719,8 @@ void LyXText::redoHeightOfParagraph(BufferView * bview)
setHeightOfRow(bview, tmprow);
}
// we can set the refreshing parameters now
status(bview, LyXText::NEED_MORE_REFRESH);
refresh_y = y;
refresh_row = tmprow;
postPaint(*bview, y);
setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary());
}
@ -734,12 +738,7 @@ void LyXText::redoDrawingOfParagraph(BufferView * bview, LyXCursor const & cur)
y -= tmprow->height();
}
// we can set the refreshing parameters now
if (status_ == LyXText::UNCHANGED || y < refresh_y) {
refresh_y = y;
refresh_row = tmprow;
}
status(bview, LyXText::NEED_MORE_REFRESH);
postPaint(*bview, y);
setCursor(bview, cur.par(), cur.pos());
}
@ -774,12 +773,8 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur,
}
}
// we can set the refreshing parameters now
status(bview, LyXText::NEED_MORE_REFRESH);
refresh_y = y;
refresh_row = tmprow->previous(); /* the real refresh row will
be deleted, so I store
the previous here */
Row * prevrow = tmprow->previous();
// remove it
if (tmprow->next())
tmppar = tmprow->next()->par();
@ -817,13 +812,12 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur,
} while (tmppar && tmppar != endpar);
// this is because of layout changes
if (refresh_row) {
refresh_y -= refresh_row->height();
setHeightOfRow(bview, refresh_row);
if (prevrow) {
setHeightOfRow(bview, prevrow);
const_cast<LyXText *>(this)->postPaint(*bview, y - prevrow->height());
} else {
refresh_row = firstrow;
refresh_y = 0;
setHeightOfRow(bview, refresh_row);
setHeightOfRow(bview, firstrow);
const_cast<LyXText *>(this)->postPaint(*bview, 0);
}
if (tmprow && tmprow->next())
@ -1105,9 +1099,7 @@ void LyXText::setParagraph(BufferView * bview,
while (tmppar != selection.start.par()->previous()) {
setCursor(bview, tmppar, 0);
status(bview, LyXText::NEED_MORE_REFRESH);
refresh_row = cursor.row();
refresh_y = cursor.y() - cursor.row()->baseline();
postPaint(*bview, cursor.y() - cursor.row()->baseline());
cursor.par()->params().lineTop(line_top);
cursor.par()->params().lineBottom(line_bottom);
cursor.par()->params().pagebreakTop(pagebreak_top);
@ -1646,9 +1638,7 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
if (z >= row->pos()) {
// set the dimensions of the row above
y -= row->previous()->height();
refresh_y = y;
refresh_row = row->previous();
status(bview, LyXText::NEED_MORE_REFRESH);
postPaint(*bview, y);
breakAgain(bview, row->previous());
@ -1663,14 +1653,13 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
int const tmpheight = row->height();
pos_type const tmplast = row->lastPos();
refresh_y = y;
refresh_row = row;
breakAgain(bview, row);
if (row->height() == tmpheight && row->lastPos() == tmplast)
status(bview, LyXText::NEED_VERY_LITTLE_REFRESH);
else
status(bview, LyXText::NEED_MORE_REFRESH);
if (row->height() == tmpheight && row->lastPos() == tmplast) {
postRowPaint(*bview, row, y);
} else {
postPaint(*bview, y);
}
// check the special right address boxes
if (par->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
@ -2337,13 +2326,11 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
// ok, we will delete anything
LyXCursor tmpcursor;
// make sure that you do not delete any environments
status(bview, LyXText::NEED_MORE_REFRESH);
deleted = true;
if (old_cursor.row()->previous()) {
refresh_row = old_cursor.row()->previous();
refresh_y = old_cursor.y() - old_cursor.row()->baseline() - refresh_row->height();
const_cast<LyXText *>(this)->postPaint(*bview, old_cursor.y() - old_cursor.row()->baseline()
- old_cursor.row()->previous()->height());
tmpcursor = cursor;
cursor = old_cursor; // that undo can restore the right cursor position
Paragraph * endpar = old_cursor.par()->next();
@ -2373,8 +2360,9 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
}
setHeightOfRow(bview, refresh_row);
} else {
refresh_row = old_cursor.row()->next();
refresh_y = old_cursor.y() - old_cursor.row()->baseline();
Row * nextrow = old_cursor.row()->next();
const_cast<LyXText *>(this)->postPaint(*bview,
old_cursor.y() - old_cursor.row()->baseline());
tmpcursor = cursor;
cursor = old_cursor; // that undo can restore the right cursor position
@ -2400,8 +2388,8 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
the parindent that can occur or dissappear.
The next row can change its height, if
there is another layout before */
if (refresh_row) {
breakAgain(bview, refresh_row);
if (nextrow) {
breakAgain(bview, nextrow);
updateCounters(bview);
}
}
@ -2464,35 +2452,6 @@ LyXText::text_status LyXText::status() const
}
void LyXText::status(BufferView * bview, LyXText::text_status new_status) const
{
// We should not lose information from previous status
// sets, or we'll forget to repaint the other bits
// covered by the NEED_MORE_REFRESH
if (new_status == NEED_VERY_LITTLE_REFRESH
&& status_ == NEED_MORE_REFRESH)
return;
status_ = new_status;
if (new_status == UNCHANGED)
return;
if (!inset_owner)
return;
LyXText * t = bview->text;
// We are an inset's lyxtext. Tell the top-level lyxtext
// it needs to update the row we're in.
t->status(bview, NEED_VERY_LITTLE_REFRESH);
if (!t->refresh_row) {
t->refresh_row = t->cursor.row();
t->refresh_y = t->cursor.y() - t->cursor.row()->baseline();
}
}
void LyXText::clearPaint()
{
status_ = UNCHANGED;
@ -2509,10 +2468,18 @@ void LyXText::postChangedInDraw()
void LyXText::postPaint(BufferView & bv, int start_y)
{
text_status old = status_;
status_ = NEED_MORE_REFRESH;
refresh_y = start_y;
refresh_row = 0;
if (old != UNCHANGED && refresh_y < start_y) {
lyxerr << "Paint already pending from above" << endl;
return;
}
refresh_y = start_y;
if (!inset_owner)
return;
@ -2533,13 +2500,17 @@ void LyXText::postPaint(BufferView & bv, int start_y)
// 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_ != UNCHANGED && refresh_y < start_y) {
lyxerr << "Paint already pending from above" << endl;
return;
} else {
refresh_y = start_y;
}
if (status_ == NEED_MORE_REFRESH)
return;
status_ = NEED_VERY_LITTLE_REFRESH;
refresh_y = start_y;
refresh_row = row;
if (!inset_owner)

View File

@ -66,7 +66,7 @@ void finishNoUndo(BufferView * bv)
freezeUndo();
bv->unlockInset(bv->theLockingInset());
finishUndo();
bv->text->status(bv, LyXText::NEED_MORE_REFRESH);
bv->text->postPaint(*bv, 0);
unFreezeUndo();
}
@ -266,7 +266,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
}
finishUndo();
bv->text->status(bv, LyXText::NEED_MORE_REFRESH);
bv->text->postPaint(*bv, 0);
return true;
}