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()) {
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();
}
+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:
+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.
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) {
}
-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();
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());
}
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()))
y += row->height();
row = row->next();
}
- force_clear_ = false;
// maybe we have to clear the screen at the bottom
if ((y < y2) && text->isTopLevel()) {
if (rp.paint(y, xo, y + text->top_y()))
text->markChangeInDraw(bv, row, prev);
}
- force_clear_ = false;
}
/**
* 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,
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;
/// grey out (no buffer)
void greyOut();
- /// FIXME ?
- bool force_clear_;
-
/// is the screen displaying text or the splash screen?
bool greyed_out_;
};
+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
///
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)
{}
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
void InsetButton::draw(BufferView * bv, LyXFont const &,
- int baseline, float & x, bool) const
+ int baseline, float & x) const
{
lyx::Assert(bv);
cache(bv);
///
int width(BufferView *, LyXFont const &) const;
///
- void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+ void draw(BufferView *, LyXFont const &, int, float &) const;
protected:
///
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.
pain.text(int(x), baseline, label, f);
x += w;
- InsetText::draw(bv, f, baseline, x, cleared);
+ InsetText::draw(bv, f, baseline, x);
}
///
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,
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;
}
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;
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;
}
}
-bool InsetCollapsable::doClearArea() const
-{
- return inset.doClearArea();
-}
-
-
LyXText * InsetCollapsable::getLyXText(BufferView const * bv,
bool const recursive) const
{
///
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);
///
///
bool isTextInset() const { return true; }
///
- bool doClearArea() const;
- ///
void insetUnlock(BufferView *);
///
bool needFullRow() const { return isOpen(); }
void InsetError::draw(BufferView * bv, LyXFont const & font,
- int baseline, float & x, bool) const
+ int baseline, float & x) const
{
lyx::Assert(bv);
cache(bv);
///
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 {}
///
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);
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;
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;
}
///
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;
///
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.
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
}
///
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);
///
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;
}
///
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;
void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
- int baseline, float & x, bool) const
+ int baseline, float & x) const
{
Painter & pain = bv->painter();
///
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;
///
void InsetNewline::draw(BufferView * bv, LyXFont const & font,
- int baseline, float & x, bool) const
+ int baseline, float & x) const
{
Painter & pain(bv->painter());
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;
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());
///
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;
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);
///
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
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;
- 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;
+ return;
}
-#endif
Painter & pain = bv->painter();
int i;
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) {
}
-bool InsetTabular::doClearArea() const
-{
- return !locked || (need_update & (FULL|INIT));
-}
-
-
void InsetTabular::getSelection(int & srow, int & erow,
int & scol, int & ecol) const
{
///
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);
///
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;
locked = false;
old_par = 0;
last_drawn_width = -1;
- frame_is_visible = false;
cached_bview = 0;
sstate.lpar = 0;
in_insetAllowed = false;
void InsetText::draw(BufferView * bv, LyXFont const & f,
- int baseline, float & x, bool cleared) const
+ int baseline, float & x) const
{
if (nodraw())
return;
// 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;
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;
}
}
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;
}
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;
}
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);
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();
- }
- } 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;
+ break;
}
- 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;
}
-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);
}
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;
}
-bool InsetText::doClearArea() const
-{
- return !locked || (need_update & (FULL|INIT));
-}
-
-
void InsetText::selectAll(BufferView * bv)
{
getLyXText(bv)->cursorTop(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;
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;
}
///
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 {
///
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);
///
///
bool isTextInset() const { return true; }
///
- bool doClearArea() const;
- ///
void insetUnlock(BufferView *);
///
bool lockInsetInInset(BufferView *, UpdatableInset *);
///
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;
///
///
mutable int last_drawn_width;
///
- mutable bool frame_is_visible;
- ///
mutable BufferView * cached_bview;
///
mutable boost::shared_ptr<LyXText> cached_text;
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!!!
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; }
///
///
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();
///
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
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
///
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;
///
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
void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
- int y, float & xx, bool /*cleared*/) const
+ int y, float & xx) const
{
// label
LyXFont font(f);
///
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);
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
}
-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());
}
}
-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();
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()) {
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();
int yo_;
float x_;
int y_;
- bool cleared_;
int width_;
float separator_;
float hfill_;
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)
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();
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());
}
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());
}
}
}
- // 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();
} 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())
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);
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());
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) {
// 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();
}
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
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);
}
}
}
-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;
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;
// 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)
freezeUndo();
bv->unlockInset(bv->theLockingInset());
finishUndo();
- bv->text->status(bv, LyXText::NEED_MORE_REFRESH);
+ bv->text->postPaint(*bv, 0);
unFreezeUndo();
}
}
finishUndo();
- bv->text->status(bv, LyXText::NEED_MORE_REFRESH);
+ bv->text->postPaint(*bv, 0);
return true;
}