]> git.lyx.org Git - lyx.git/commitdiff
Ding dong, the CID is dead...
authorJohn Levon <levon@movementarian.org>
Sat, 22 Mar 2003 17:26:03 +0000 (17:26 +0000)
committerJohn Levon <levon@movementarian.org>
Sat, 22 Mar 2003 17:26:03 +0000 (17:26 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6558 a592a061-630c-0410-9148-cb99ea01b6c8

25 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/frontends/ChangeLog
src/frontends/qt2/ChangeLog
src/frontends/qt2/qscreen.C
src/frontends/screen.C
src/frontends/screen.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/xscreen.C
src/insets/ChangeLog
src/insets/inset.C
src/insets/inset.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetert.C
src/insets/insetminipage.C
src/insets/insettabular.C
src/insets/insettext.C
src/insets/insettext.h
src/insets/updatableinset.C
src/lyxtext.h
src/rowpainter.C
src/rowpainter.h
src/text.C
src/text2.C

index ee46da6ff91c8b9f3de9995922d24217eaf0f4e9..e34057b8307002bf64e1948b5149e30a85d59d64 100644 (file)
@@ -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();
        }
 }
 
index c10063c81706e6becea36a48ca014243b1da6fb7..93671fa2f7f13c4758897b2eb2bf273e40542eb1 100644 (file)
@@ -1,3 +1,12 @@
+2003-03-22  John Levon  <levon@movementarian.org>
+
+       * 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  <abraunst@libero.it>
 
        * lyxtext.h:
index 89657fd61e59d9afcfb62f7650faa59f0ea98af4..13733d3b26606ca87d4bdfdb93b75abfe741db82 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-22  John Levon  <levon@movementarian.org>
+
+       * screen.C:
+       * screen.h:
 2003-03-17  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * adjust for BufferView* arg removal from lyxtext.
index e50da6c863e8344080efb6e6598b5ce144c7e4d9..174a884263607de620ff499c34e74a824783478f 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-22  John Levon  <levon@movementarian.org>
+
+       * qscreen.C: remove "internal" parameter, unused
+
 2003-03-21  John Levon  <levon@movementarian.org>
 
        * QDocument.C: fix swapping of TOC and secnum depth
index 0d9cab5259362e93587c8a84fe452b45b3bc6974..185007700b60f62759738ddee439aff8b3652aef 100644 (file)
@@ -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();
        }
 
index 65198c7f6f0a1325783015df022d77af3f40eaa5..58b7d17e6e969f43c10359691065f125049b4cfe 100644 (file)
@@ -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<int>(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());
 }
index ebb3ed13e075818ce2faad778a3cef3388c8983e..4239c575697d6ccf224ce9cd082c12d0ede1eabd 100644 (file)
@@ -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_;
index b288ab64906c72db1f3ef9915f623d054c6fee71..645c3a0bbfee396cac855a95a3f05411a1be243f 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-22  John Levon  <levon@movementarian.org>
+
+       * xscreen.C: remove "internal", unused
+
 2003-03-13  Rob Lahaye  <lahaye@snu.ac.kr>
 
         * FormChanges.C: "LyX: " in dialog's name is redundant;
index 233122f2d9b4d456a44b42989cf631b4dec117c3..2816f40faf52fa1b97a385c85aaff7fcc8030b3d 100644 (file)
@@ -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());
        }
 
index 236b322ce8c0ed07eb48816293021fa6b67807a7..10af63b12f4868472e478a54c559a1c38b0ceac9 100644 (file)
@@ -1,3 +1,25 @@
+2003-03-22  John Levon  <levon@movementarian.org>
+
+       * 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  <levon@movementarian.org>
 
        * inset.h:
index 1025cc7bf1a45d89eca0179b6b7e24ef3532ef48..ff8d77a51fc33b065ae64eaa6e1a98eb0344cc9a 100644 (file)
@@ -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();
index 56b339c50cbd161c5c444f147a10c0474574c93d..e5800314d53bfdc51048c5a412ca7125d806a55b 100644 (file)
@@ -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;
index 64f0c4db1ffe2236822e378b3bfce6e73250418a..fe7a15c767806b21a271c74a3c3683f06b4e3198 100644 (file)
@@ -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)
 {
index 4b89a1684ed646eca63a8d75e5751714437a947a..c6932a02004a57be37c70d1b26483def770352ef 100644 (file)
@@ -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;
index 586adac1a9293d1cef88b292a01524c03f8123cd..453f4e9423a81c84743a48219c1d0c061c0bf8c7 100644 (file)
@@ -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;
        }
index c763d727a161ec9c8ce4e2d10a9e623d1a4399de..98ffdb2bcb0976fa802fe572119e6f6cb17bdfb0 100644 (file)
@@ -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;
        }
index 1c86f1bd036aa6b8190cb713f856a8354ae0133e..cd4d6d6204f478147e20b2b04cd97a952797f42e 100644 (file)
@@ -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;
 }
 
 
index 9e441eca085e4d64cdbd39d4c6515620309bfa0a..bec717d54e996f30c1681fa8404d993a39572f60 100644 (file)
@@ -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;
 }
 
index 7a97e17789ff244354f2014c120ee1ece9d03bc1..68150a5cdaf8275fad68589d9dcbe48f7cb547fa 100644 (file)
@@ -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;
        ///
index 9ba5820d56e1badcabcb2d92f58469d99237b31a..d3027c911e8df88976e1b48590e7696a7789938d 100644 (file)
@@ -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<UpdatableInset*>
-                       (owner())->getMaxWidth(bv, this);
+               w = static_cast<UpdatableInset*> (owner())->getMaxWidth(bv, this);
        } else {
                w = bv->text->workWidth(const_cast<UpdatableInset *>(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;
        }
index c5d54c235566bea422359c4c31d98a7bae80ff78..eba0ec42a631c4769b0f6b4745393374e5ce8bd5 100644 (file)
@@ -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 <enter> 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
         */
index d13584617ea27e764185a4b3e3bf4e4ab2a70887..faf9eb1d1657879f1da35bac4b7b21dea91b9d09 100644 (file)
@@ -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<Inset*>(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();
 }
index ad79fd2ac5fb85e0d0d26deca428eeb9aa11497b..6711d57c6e0afe414dfddc6531afe42ee0aba819 100644 (file)
@@ -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;
index 27737df2376b9205928b2a315f46e955414c0f8d..018ff3c9b1cf8d6c63b37e54e49dba27e06eefb7 100644 (file)
@@ -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;
index 4a9d0f1661ae47f4dc8fc7255af3416b0935152a..9410373ee222a333fe2ab59b6c7a4896e8c6401c 100644 (file)
@@ -2456,12 +2456,6 @@ void LyXText::clearPaint()
 }
 
 
-void LyXText::postChangedInDraw()
-{
-       status_ = CHANGED_IN_DRAW;
-}
-
-
 void LyXText::postPaint(int start_y)
 {
        text_status old = status_;