From: John Levon Date: Sat, 22 Mar 2003 17:26:03 +0000 (+0000) Subject: Ding dong, the CID is dead... X-Git-Tag: 1.6.10~17188 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=fa15f1b24a754723b7dd5855fad68a18636b7777;p=lyx.git Ding dong, the CID is dead... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6558 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index ee46da6ff9..e34057b830 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -503,30 +503,7 @@ void BufferView::Pimpl::update() { if (!bv_->theLockingInset() || !bv_->theLockingInset()->nodraw()) { screen().update(*bv_); - bool fitc = false; - while (bv_->text->status() == LyXText::CHANGED_IN_DRAW) { - bv_->text->fullRebreak(); - bv_->text->setCursor(bv_->text->cursor.par(), - bv_->text->cursor.pos()); - if (bv_->text->selection.set()) { - bv_->text->setCursor(bv_->text->selection.start, - bv_->text->selection.start.par(), - bv_->text->selection.start.pos()); - bv_->text->setCursor(bv_->text->selection.end, - bv_->text->selection.end.par(), - bv_->text->selection.end.pos()); - } - fitc = true; - bv_->text->postPaint(0); - screen().update(*bv_); - } - - // do this here instead of in the screen::update because of - // the above loop! bv_->text->clearPaint(); - - if (fitc) - fitCursor(); } } diff --git a/src/ChangeLog b/src/ChangeLog index c10063c817..93671fa2f7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2003-03-22 John Levon + + * BufferView_pimpl.C: + * lyxtext.h: + * rowpainter.C: + * rowpainter.h: + * text.C: + * text2.C: remove CHANGED_IN_DRAW, it cannot happen now + 2003-03-21 Alfredo Braunstein * lyxtext.h: diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 89657fd61e..13733d3b26 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,7 @@ +2003-03-22 John Levon + + * screen.C: + * screen.h: 2003-03-17 Lars Gullik Bjønnes * adjust for BufferView* arg removal from lyxtext. diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index e50da6c863..174a884263 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,7 @@ +2003-03-22 John Levon + + * qscreen.C: remove "internal" parameter, unused + 2003-03-21 John Levon * QDocument.C: fix swapping of TOC and secnum depth diff --git a/src/frontends/qt2/qscreen.C b/src/frontends/qt2/qscreen.C index 0d9cab5259..185007700b 100644 --- a/src/frontends/qt2/qscreen.C +++ b/src/frontends/qt2/qscreen.C @@ -161,7 +161,6 @@ void QScreen::draw(LyXText * text, BufferView * bv, unsigned int y) if (cursor_visible_) hideCursor(); int const old_first = text->top_y(); - bool const internal = (text == bv->text); text->top_y(y); // If you want to fix the warning below, fix it so it @@ -172,18 +171,18 @@ void QScreen::draw(LyXText * text, BufferView * bv, unsigned int y) && old_first - y < owner_.workHeight()) { if (text->top_y() < old_first) { int const dest_y = old_first - text->top_y(); - drawFromTo(text, bv, 0, dest_y, 0, 0, internal); + drawFromTo(text, bv, 0, dest_y, 0, 0); copyInPixmap(p, dest_y, 0, owner_.workWidth(), owner_.height() - dest_y); expose(0, 0, owner_.workWidth(), dest_y); } else { int const src_y = text->top_y() - old_first; - drawFromTo(text, bv, owner_.height() - src_y, owner_.height(), 0, 0, internal); + drawFromTo(text, bv, owner_.height() - src_y, owner_.height(), 0, 0); copyInPixmap(p, 0, 0, owner_.workWidth(), owner_.height() - src_y); expose(0, owner_.height() - src_y, owner_.workWidth(), src_y); } } else { lyxerr[Debug::GUI] << "dumb full redraw" << endl; - drawFromTo(text, bv, 0, owner_.height(), 0, 0, internal); + drawFromTo(text, bv, 0, owner_.height(), 0, 0); repaint(); } diff --git a/src/frontends/screen.C b/src/frontends/screen.C index 65198c7f6f..58b7d17e6e 100644 --- a/src/frontends/screen.C +++ b/src/frontends/screen.C @@ -273,7 +273,6 @@ void LyXScreen::update(BufferView & bv, int yo, int xo) } } break; - case LyXText::CHANGED_IN_DRAW: // just to remove the warning case LyXText::UNCHANGED: // Nothing needs done break; @@ -338,9 +337,7 @@ void LyXScreen::toggleToggle(LyXText * text, BufferView * bv, workarea().getPainter().start(); - drawFromTo(text, bv, top - text->top_y(), - bottom - text->top_y(), yo, - xo); + drawFromTo(text, bv, top - text->top_y(), bottom - text->top_y(), yo, xo); expose(0, top - text->top_y(), workarea().workWidth(), bottom - text->top_y() - (top - text->top_y())); @@ -357,11 +354,9 @@ void LyXScreen::redraw(LyXText * text, BufferView * bv) return; } - - workarea().getPainter().start(); - drawFromTo(text, bv, 0, workarea().workHeight(), 0, 0, text == bv->text); + drawFromTo(text, bv, 0, workarea().workHeight(), 0, 0); expose(0, 0, workarea().workWidth(), workarea().workHeight()); workarea().getPainter().end(); @@ -411,8 +406,7 @@ void LyXScreen::greyOut() void LyXScreen::drawFromTo(LyXText * text, BufferView * bv, - int y1, int y2, int yo, int xo, - bool internal) + int y1, int y2, int yo, int xo) { lyxerr[Debug::GUI] << "screen: drawFromTo " << y1 << '-' << y2 << endl; @@ -427,26 +421,8 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv, while (row != 0 && y < y2) { - LyXText::text_status st = text->status(); - // we need this here as the row pointer may be illegal - // at a later time (Jug20020502) - Row * prev = row->previous(); RowPainter rp(*bv, *text, *row); - - if (rp.paint(y + yo, xo, y + text->top_y())) - text->markChangeInDraw(row, prev); - - internal = internal && (st != LyXText::CHANGED_IN_DRAW); - while (internal && text->status() == LyXText::CHANGED_IN_DRAW) { - text->fullRebreak(); - text->setCursor(text->cursor.par(), - text->cursor.pos()); - text->postPaint(0); - Row * prev = row->previous(); - RowPainter rp(*bv, *text, *row); - if (rp.paint(y + yo, xo, y + text->top_y())) - text->markChangeInDraw(row, prev); - } + rp.paint(y + yo, xo, y + text->top_y()); y += row->height(); row = row->next(); } @@ -465,11 +441,12 @@ void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row, { int const y = y_text - text->top_y() + yo; - if (((y + row->height()) > 0) && - ((y - row->height()) <= static_cast(workarea().workHeight()))) { - Row * prev = row->previous(); - RowPainter rp(*bv, *text, *row); - if (rp.paint(y, xo, y + text->top_y())) - text->markChangeInDraw(row, prev); - } + if (y + row->height() <= 0) + return; + + if (y - row->height() > workarea().workHeight()) + return; + + RowPainter rp(*bv, *text, *row); + rp.paint(y, xo, y + text->top_y()); } diff --git a/src/frontends/screen.h b/src/frontends/screen.h index ebb3ed13e0..4239c57569 100644 --- a/src/frontends/screen.h +++ b/src/frontends/screen.h @@ -146,12 +146,12 @@ protected: virtual WorkArea & workarea() const = 0; /// y1 and y2 are coordinates of the screen - virtual void drawFromTo(LyXText *, BufferView *, int y1, int y2, - int y_offset = 0, int x_offset = 0, bool internal = false); + void drawFromTo(LyXText *, BufferView *, int y1, int y2, + int y_offset = 0, int x_offset = 0); /// y is a coordinate of the text - virtual void drawOneRow(LyXText *, BufferView *, Row * row, - int y_text, int y_offset = 0, int x_offset = 0); + void drawOneRow(LyXText *, BufferView *, Row * row, + int y_text, int y_offset = 0, int x_offset = 0); /// is the blinking cursor currently drawn bool cursor_visible_; diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index b288ab6490..645c3a0bbf 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2003-03-22 John Levon + + * xscreen.C: remove "internal", unused + 2003-03-13 Rob Lahaye * FormChanges.C: "LyX: " in dialog's name is redundant; diff --git a/src/frontends/xforms/xscreen.C b/src/frontends/xforms/xscreen.C index 233122f2d9..2816f40faf 100644 --- a/src/frontends/xforms/xscreen.C +++ b/src/frontends/xforms/xscreen.C @@ -214,18 +214,17 @@ void XScreen::draw(LyXText * text, BufferView * bv, unsigned int y) && (old_first - y) < owner_.workHeight()) { if (text->top_y() < old_first) { - drawFromTo(text, bv, 0, - old_first - text->top_y(), 0, 0, internal); - XCopyArea (fl_get_display(), - owner_.getWin(), - owner_.getWin(), - gc_copy, - owner_.xpos(), - owner_.ypos(), - owner_.workWidth(), - owner_.workHeight() - old_first + text->top_y(), - owner_.xpos(), - owner_.ypos() + old_first - text->top_y() + drawFromTo(text, bv, 0, old_first - text->top_y(), 0, 0); + XCopyArea(fl_get_display(), + owner_.getWin(), + owner_.getWin(), + gc_copy, + owner_.xpos(), + owner_.ypos(), + owner_.workWidth(), + owner_.workHeight() - old_first + text->top_y(), + owner_.xpos(), + owner_.ypos() + old_first - text->top_y() ); // expose the area drawn expose(0, 0, @@ -234,24 +233,24 @@ void XScreen::draw(LyXText * text, BufferView * bv, unsigned int y) } else { drawFromTo(text, bv, owner_.workHeight() + old_first - text->top_y(), - owner_.workHeight(), 0, 0, internal); - XCopyArea (fl_get_display(), - owner_.getWin(), - owner_.getWin(), - gc_copy, - owner_.xpos(), - owner_.ypos() + text->top_y() - old_first, - owner_.workWidth(), - owner_.workHeight() + old_first - text->top_y(), - owner_.xpos(), - owner_.ypos()); + owner_.workHeight(), 0, 0); + XCopyArea(fl_get_display(), + owner_.getWin(), + owner_.getWin(), + gc_copy, + owner_.xpos(), + owner_.ypos() + text->top_y() - old_first, + owner_.workWidth(), + owner_.workHeight() + old_first - text->top_y(), + owner_.xpos(), + owner_.ypos()); // expose the area drawn expose(0, owner_.workHeight() + old_first - text->top_y(), owner_.workWidth(), text->top_y() - old_first); } } else { // make a dumb new-draw - drawFromTo(text, bv, 0, owner_.workHeight(), 0, 0, internal); + drawFromTo(text, bv, 0, owner_.workHeight(), 0, 0); expose(0, 0, owner_.workWidth(), owner_.workHeight()); } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 236b322ce8..10af63b12f 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,25 @@ +2003-03-22 John Levon + + * inset.h: + * inset.C: remove no-longer-needed topx_set + + * insetcollapsable.h: + * insetcollapsable.C: remove dead code + + * insetminipage.C: + * insetert.C: rebreak the rows when a possible + change in size is made, and reset the cursor + (bug 962, bug 965) + + * insettabular.C: remove topx_set, CHANGED_IN_DRAW + + * insettext.C: remove CHANGED_IN_DRAW noticing/handling, + topx_set. Fix drawing errors for clearInset(). Remove + some unnecessary uses of topx, which should die. + + * updatableinset.C: fix getMaxWidth() so CHANGED_IN_DRAW + is no longer needed. Replace it with an ugly hack. + 2003-03-20 John Levon * inset.h: diff --git a/src/insets/inset.C b/src/insets/inset.C index 1025cc7bf1..ff8d77a51f 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -35,17 +35,17 @@ using std::endl; unsigned int Inset::inset_id = 0; Inset::Inset() - : InsetBase(), - top_x(0), topx_set(false), top_baseline(0), scx(0), - id_(inset_id++), owner_(0), par_owner_(0), - background_color_(LColor::inherit) + : InsetBase(), + top_x(0), top_baseline(0), scx(0), + id_(inset_id++), owner_(0), par_owner_(0), + background_color_(LColor::inherit) {} Inset::Inset(Inset const & in, bool same_id) - : InsetBase(), - top_x(0), topx_set(false), top_baseline(0), scx(0), owner_(0), - name_(in.name_), background_color_(in.background_color_) + : InsetBase(), + top_x(0), top_baseline(0), scx(0), owner_(0), + name_(in.name_), background_color_(in.background_color_) { if (same_id) id_ = in.id(); diff --git a/src/insets/inset.h b/src/insets/inset.h index 56b339c50c..e5800314d5 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -344,8 +344,6 @@ protected: /// mutable int top_x; /// - mutable bool topx_set; /* have we already drawn ourself! */ - /// mutable int top_baseline; /// mutable int scx; diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 64f0c4db1f..fe7a15c767 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -210,7 +210,6 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, x += scroll(); top_x = int(x); - topx_set = true; top_baseline = baseline; int const bl = baseline - ascent(bv, f) + ascent_collapsed(); @@ -408,26 +407,6 @@ int InsetCollapsable::docbook(Buffer const * buf, ostream & os, bool mixcont) co return inset.docbook(buf, os, mixcont); } -#if 0 -int InsetCollapsable::getMaxWidth(BufferView * bv, - UpdatableInset const * in) const -{ -#if 0 - int const w = UpdatableInset::getMaxWidth(bv, in); - - if (w < 0) { - // What does a negative max width signify? (Lgb) - // Use the max width of the draw-area (Jug) - return w; - } - // should be at least 30 pixels !!! - return max(30, w - width_collapsed()); -#else - return UpdatableInset::getMaxWidth(bv, in); -#endif -} -#endif - void InsetCollapsable::update(BufferView * bv, bool reinit) { diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 4b89a1684e..c6932a0200 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -122,10 +122,6 @@ public: #if 0 /// void setAutoCollapse(bool f) { autocollapse = f; } -#endif -#if 0 - /// - int getMaxWidth(BufferView *, UpdatableInset const *) const; #endif /// LyXText * getLyXText(BufferView const *, bool const recursive) const; diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 586adac1a9..453f4e9423 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -445,9 +445,18 @@ Inset::RESULT InsetERT::localDispatch(FuncRequest const & cmd) InsetERTMailer::string2params(cmd.argument, status_); status(bv, status_); - // FIXME: how on holy earth do you actually get - // this thing to reinit the bloody insettext - // and change the size of this inset !!?! + + /* FIXME: I refuse to believe we have to live + * with ugliness like this ! Note that this + * rebreak *is* needed. Consider a change from + * Open (needfullrow) to Inlined (only the space + * taken by the text). + */ + LyXText * t = inset.getLyXText(cmd.view()); + t->need_break_row = t->firstRow(); + t->fullRebreak(); + t->setCursorIntern(t->cursor.par(), t->cursor.pos()); + inset.update(cmd.view(), true); bv->updateInset(this); result = DISPATCHED; } diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index c763d727a1..98ffdb2bcb 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -117,8 +117,13 @@ dispatch_result InsetMinipage::localDispatch(FuncRequest const & cmd) params_.pos = params.pos; params_.width = params.width; - // FIXME: what magical mysterious commands are actually - // needed here to update the bloody size of the inset !!! + /* FIXME: I refuse to believe we have to live + * with ugliness like this ... */ + LyXText * t = inset.getLyXText(cmd.view()); + t->need_break_row = t->firstRow(); + t->fullRebreak(); + inset.update(cmd.view(), true); + t->setCursorIntern(t->cursor.par(), t->cursor.pos()); cmd.view()->updateInset(this); result = DISPATCHED; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 1c86f1bd03..cd4d6d6204 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -281,7 +281,6 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, #endif top_x = int(x); - topx_set = true; top_baseline = baseline; x += ADD_TO_TABULAR_WIDTH; @@ -323,15 +322,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, x -= ADD_TO_TABULAR_WIDTH; x += width(bv, font); - if (bv->text->status() == LyXText::CHANGED_IN_DRAW) { - int i = 0; - for(Inset * inset = owner(); inset; ++i) - inset = inset->owner(); - if (calculate_dimensions_of_cells(bv, false)) - need_update = INIT; - } else { - need_update = NONE; - } + need_update = NONE; } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 9e441eca08..bec717d54e 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -350,22 +350,14 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, if (nodraw()) return; - Painter & pain = bv->painter(); - - // 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 - if (top_x != int(x)) { + // update our idea of where we are. Clearly, we should + // not have to know this information. + if (top_x != int(x)) top_x = int(x); - topx_set = true; - int nw = getMaxWidth(bv, this); - if (nw > 0 && old_max_width != nw) { - need_update = INIT; - old_max_width = nw; - bv->text->postChangedInDraw(); - return; - } - } + + int const start_x = int(x); + + Painter & pain = bv->painter(); // call these methods so that insetWidth, insetAscent and // insetDescent have the right values. @@ -375,7 +367,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, // repaint the background if needed if (backgroundColor() != LColor::background) - clearInset(bv, baseline); + clearInset(bv, start_x + TEXT_TO_INSET_OFFSET, baseline); // no draw is necessary !!! if ((drawFrame_ == LOCKED) && !locked && paragraphs.begin()->empty()) { @@ -398,7 +390,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, if (the_locking_inset && (cpar(bv) == inset_par) && (cpos(bv) == inset_pos)) { - inset_x = cix(bv) - top_x + drawTextXOffset; + inset_x = cix(bv) - int(x) + drawTextXOffset; inset_y = ciy(bv) + drawTextYOffset; } @@ -431,25 +423,8 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, 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(row, prev); - if (bv->text->status() == LyXText::CHANGED_IN_DRAW) { - lt->need_break_row = row; - lt->fullRebreak(); - lt->setCursor(lt->cursor.par(), - lt->cursor.pos()); - if (lt->selection.set()) { - lt->setCursor(lt->selection.start, - lt->selection.start.par(), - lt->selection.start.pos()); - lt->setCursor(lt->selection.end, - lt->selection.end.par(), - lt->selection.end.pos()); - } - break; - } + rp.paint(y + y_offset + first, int(x), y + lt->top_y()); y += row->height(); yf += row->height(); row = row->next(); @@ -458,14 +433,12 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, lt->clearPaint(); if ((drawFrame_ == ALWAYS) || (drawFrame_ == LOCKED && locked)) { - drawFrame(pain); + drawFrame(pain, int(start_x)); } x += insetWidth - TEXT_TO_INSET_OFFSET; - if (bv->text->status() == LyXText::CHANGED_IN_DRAW) { - need_update |= FULL; - } else if (need_update != INIT) { + if (need_update != INIT) { need_update = NONE; } if (clear) @@ -473,10 +446,10 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, } -void InsetText::drawFrame(Painter & pain) const +void InsetText::drawFrame(Painter & pain, int x) const { static int const ttoD2 = TEXT_TO_INSET_OFFSET / 2; - frame_x = top_x + ttoD2; + frame_x = x + ttoD2; frame_y = top_baseline - insetAscent + ttoD2; frame_w = insetWidth - TEXT_TO_INSET_OFFSET; frame_h = insetAscent + insetDescent - TEXT_TO_INSET_OFFSET; @@ -495,6 +468,7 @@ void InsetText::update(BufferView * bv, bool reinit) return; } in_update = true; + if (reinit || need_update == INIT) { need_update = FULL; // we should put this call where we set need_update to INIT! @@ -502,6 +476,12 @@ void InsetText::update(BufferView * bv, bool reinit) if (owner()) owner()->update(bv, true); in_update = false; + + int nw = getMaxWidth(bv, this); + if (nw > 0 && old_max_width != nw) { + need_update |= INIT; + old_max_width = nw; + } return; } @@ -520,15 +500,22 @@ void InsetText::update(BufferView * bv, bool reinit) clear = true; } if ((need_update & CURSOR_PAR) && (lt->status() == LyXText::UNCHANGED) && - the_locking_inset) - { + the_locking_inset) { lt->updateInset(the_locking_inset); } + if (lt->status() == LyXText::NEED_MORE_REFRESH) need_update |= FULL; if (clear) lt = 0; + in_update = false; + + int nw = getMaxWidth(bv, this); + if (nw > 0 && old_max_width != nw) { + need_update |= INIT; + old_max_width = nw; + } } @@ -2404,7 +2391,7 @@ void InsetText::clearSelection(BufferView * bv) } -void InsetText::clearInset(BufferView * bv, int baseline) const +void InsetText::clearInset(BufferView * bv, int start_x, int baseline) const { Painter & pain = bv->painter(); int w = insetWidth; @@ -2419,8 +2406,7 @@ void InsetText::clearInset(BufferView * bv, int baseline) const h = pain.paperHeight(); if ((top_x + drawTextXOffset + w) > pain.paperWidth()) w = pain.paperWidth(); -// w -= TEXT_TO_INSET_OFFSET; - pain.fillRectangle(top_x + 1, ty + 1, w - 1, h - 1, backgroundColor()); + pain.fillRectangle(start_x + 1, ty + 1, w - 3, h - 1, backgroundColor()); need_update = FULL; } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 7a97e17789..68150a5cda 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -342,9 +342,9 @@ private: /// Row * crow(BufferView *) const; /// - void drawFrame(Painter &) const; + void drawFrame(Painter &, int x) const; /// - void clearInset(BufferView *, int baseline) const; + void clearInset(BufferView *, int start_x, int baseline) const; /// void saveLyXTextState(LyXText *) const; /// diff --git a/src/insets/updatableinset.C b/src/insets/updatableinset.C index 9ba5820d56..d3027c911e 100644 --- a/src/insets/updatableinset.C +++ b/src/insets/updatableinset.C @@ -160,9 +160,9 @@ Inset::RESULT UpdatableInset::localDispatch(FuncRequest const & ev) int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const { int w; + if (owner()) { - w = static_cast - (owner())->getMaxWidth(bv, this); + w = static_cast (owner())->getMaxWidth(bv, this); } else { w = bv->text->workWidth(const_cast(this)); } @@ -172,15 +172,14 @@ int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const // check for margins left/right and extra right margin "const 5" if ((w - ((2 * TEXT_TO_INSET_OFFSET) + 5)) >= 0) w -= (2 * TEXT_TO_INSET_OFFSET) + 5; - if (topx_set && owner()) { - w -= top_x; - w += owner()->x(); - } else if (owner()) { - // this is needed as otherwise we might have a too large inset if - // its top_x afterwards changes to LeftMargin so we try to put at - // least the default margin as top_x + + // Deep magic. I don't understand this either. + if (owner() && owner()->owner()) { + // add the right paper margin w -= 20; } + + // FIXME: why ? if (w < 10) { w = 10; } diff --git a/src/lyxtext.h b/src/lyxtext.h index c5d54c2355..eba0ec42a6 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -40,15 +40,10 @@ public: enum text_status { /// no repaint is needed UNCHANGED = 0, - /** - * A paint has caused a change in some rows - * and rebreaking is needed. - */ - CHANGED_IN_DRAW = 1, /// the refresh_row needs repainting - NEED_VERY_LITTLE_REFRESH = 2, + NEED_VERY_LITTLE_REFRESH = 1, /// everything from refresh_y downwards needs repainting - NEED_MORE_REFRESH = 3 + NEED_MORE_REFRESH = 2 }; /// @@ -118,8 +113,6 @@ public: void setCharFont(Paragraph * par, lyx::pos_type pos, LyXFont const & font, bool toggleall); - /// return true if the row changed - void markChangeInDraw(Row * row, Row * next); /// void breakAgainOneRow(Row * row); /// what you expect when pressing at cursor position @@ -191,9 +184,6 @@ public: /// 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 */ diff --git a/src/rowpainter.C b/src/rowpainter.C index d13584617e..faf9eb1d16 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -102,7 +102,7 @@ int RowPainter::leftMargin() const } -bool RowPainter::paintInset(pos_type const pos) +void RowPainter::paintInset(pos_type const pos) { Inset * inset = const_cast(par_.getInset(pos)); @@ -114,11 +114,6 @@ bool RowPainter::paintInset(pos_type const pos) inset->update(perv(bv_), false); inset->draw(perv(bv_), font, yo_ + row_.baseline(), x_); - - // return true if something changed when we drew an inset - - return (!text_.need_break_row && !text_.isInInset() - && bv_.text->status() == LyXText::CHANGED_IN_DRAW); } @@ -260,7 +255,7 @@ void RowPainter::paintForeignMark(float const orig_x, LyXFont const & orig_font) } -bool RowPainter::paintFromPos(pos_type & vpos) +void RowPainter::paintFromPos(pos_type & vpos) { pos_type const pos = text_.vis2log(vpos); @@ -271,11 +266,10 @@ bool RowPainter::paintFromPos(pos_type & vpos) char const c = par_.getChar(pos); if (IsInsetChar(c)) { - if (paintInset(pos)) - return true; + paintInset(pos); ++vpos; paintForeignMark(orig_x, orig_font); - return false; + return; } // usual characters, no insets @@ -300,7 +294,7 @@ bool RowPainter::paintFromPos(pos_type & vpos) paintForeignMark(orig_x, orig_font); - return false; + return; } @@ -854,7 +848,7 @@ void RowPainter::paintLast() } -bool RowPainter::paintText() +void RowPainter::paintText() { pos_type const last = row_.lastPrintablePos(); pos_type body_pos = par_.beginningOfBody(); @@ -952,8 +946,7 @@ bool RowPainter::paintText() x_ += separator_; ++vpos; } else { - if (paintFromPos(vpos)) - return true; + paintFromPos(vpos); } } @@ -965,11 +958,11 @@ bool RowPainter::paintText() LColor::strikeout, Painter::line_solid, Painter::line_thin); running_strikeout = false; } - return false; + return; } -bool RowPainter::paint(int y_offset, int x_offset, int y) +void RowPainter::paint(int y_offset, int x_offset, int y) { xo_ = x_offset; yo_ = y_offset; @@ -1015,5 +1008,5 @@ bool RowPainter::paint(int y_offset, int x_offset, int y) } // paint text - return paintText(); + paintText(); } diff --git a/src/rowpainter.h b/src/rowpainter.h index ad79fd2ac5..6711d57c6e 100644 --- a/src/rowpainter.h +++ b/src/rowpainter.h @@ -33,8 +33,8 @@ public: /// initialise painter 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); + /// paint the row. + void paint(int y_offset, int x_offset, int y); private: // paint various parts @@ -52,12 +52,9 @@ private: int paintPageBreak(string const & label, int y); int paintAppendixStart(int y); int paintLengthMarker(string const & prefix, VSpace const & vsp, int start); - /// returns true when CHANGED_IN_DRAW - bool paintText(); - /// returns true when CHANGED_IN_DRAW - bool paintFromPos(lyx::pos_type & vpos); - /// returns true when CHANGED_IN_DRAW - bool paintInset(lyx::pos_type const pos); + void paintText(); + void paintFromPos(lyx::pos_type & vpos); + void paintInset(lyx::pos_type const pos); /// return left margin int leftMargin() const; diff --git a/src/text.C b/src/text.C index 27737df237..018ff3c9b1 100644 --- a/src/text.C +++ b/src/text.C @@ -1341,29 +1341,6 @@ void LyXText::appendParagraph(Row * row) } -// Do we even need this at all ? Code that uses RowPainter *already* -// sets need_break_row when it sees a CHANGED_IN_DRAW, though not -// quite like this -void LyXText::markChangeInDraw(Row * row, Row * prev) -{ - if (prev && prev->par() == row->par()) { - breakAgainOneRow(prev); - if (prev->next() != row) { - // breakAgainOneRow() has removed row_ - need_break_row = prev; - } else { - need_break_row = row; - } - } else if (!prev) { - need_break_row = firstrow; - } else { - need_break_row = prev->next(); - } - setCursor(cursor.par(), cursor.pos()); - /* FIXME */ -} - - void LyXText::breakAgain(Row * row) { bool not_ready = true; diff --git a/src/text2.C b/src/text2.C index 4a9d0f1661..9410373ee2 100644 --- a/src/text2.C +++ b/src/text2.C @@ -2456,12 +2456,6 @@ void LyXText::clearPaint() } -void LyXText::postChangedInDraw() -{ - status_ = CHANGED_IN_DRAW; -} - - void LyXText::postPaint(int start_y) { text_status old = status_;