]> git.lyx.org Git - features.git/commitdiff
paint cleanups as sent to list
authorJohn Levon <levon@movementarian.org>
Mon, 17 Mar 2003 01:34:36 +0000 (01:34 +0000)
committerJohn Levon <levon@movementarian.org>
Mon, 17 Mar 2003 01:34:36 +0000 (01:34 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6517 a592a061-630c-0410-9148-cb99ea01b6c8

45 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/frontends/ChangeLog
src/frontends/screen.C
src/frontends/screen.h
src/insets/ChangeLog
src/insets/inset.h
src/insets/insetbutton.C
src/insets/insetbutton.h
src/insets/insetcaption.C
src/insets/insetcaption.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetlatexaccent.C
src/insets/insetlatexaccent.h
src/insets/insetnewline.C
src/insets/insetnewline.h
src/insets/insetquotes.C
src/insets/insetquotes.h
src/insets/insetspecialchar.C
src/insets/insetspecialchar.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/updatableinset.C
src/insets/updatableinset.h
src/lyxtext.h
src/mathed/formula.C
src/mathed/formula.h
src/mathed/formulabase.h
src/mathed/formulamacro.C
src/mathed/formulamacro.h
src/rowpainter.C
src/rowpainter.h
src/text2.C
src/undo_funcs.C

index 18c656d92c6d784b2d961e0cf15ec97fc33da771..c9489f0395454eb3f442329b66cfbee617c425e9 100644 (file)
@@ -500,12 +500,10 @@ void BufferView::Pimpl::workAreaResize()
 void BufferView::Pimpl::update()
 {
        if (!bv_->theLockingInset() || !bv_->theLockingInset()->nodraw()) {
-               LyXText::text_status st = bv_->text->status();
-               screen().update(bv_->text, bv_);
+               screen().update(*bv_);
                bool fitc = false;
                while (bv_->text->status() == LyXText::CHANGED_IN_DRAW) {
                        bv_->text->fullRebreak(bv_);
-                       st = LyXText::NEED_MORE_REFRESH;
                        bv_->text->setCursor(bv_, bv_->text->cursor.par(),
                                             bv_->text->cursor.pos());
                        if (bv_->text->selection.set()) {
@@ -517,12 +515,14 @@ void BufferView::Pimpl::update()
                                                     bv_->text->selection.end.pos());
                        }
                        fitc = true;
-                       bv_->text->status(bv_, st);
-                       screen().update(bv_->text, bv_);
+                       bv_->text->postPaint(*bv_, 0);
+                       screen().update(*bv_);
                }
+
                // do this here instead of in the screen::update because of
                // the above loop!
-               bv_->text->status(bv_, LyXText::UNCHANGED);
+               bv_->text->clearPaint();
+
                if (fitc)
                        fitCursor();
        }
index ba4b1e8480ea8d0a43ba24944ca1081ab28c7270..133e85f568cb1edbdbb2098a55a6d11169d37c88 100644 (file)
@@ -1,3 +1,14 @@
+2003-03-17  John Levon  <levon@movementarian.org>
+
+       * lyxtext.h:
+       * undo_funcs.C:
+       * text2.C: more paint cleanups
+
+       * BufferView_pimpl.C: screen prototype changed, use postPaint etc.
+
+       * rowpainter.h:
+       * rowpainter.C: remove "smart" background painting code
+
 2003-03-16  John Levon  <levon@movementarian.org>
 
        * lyxtext.h:
index ba4c91c180cd3f55081bfb90c78815f5b502a419..ad046b787edb6ae4dbabea0373029ee24cf2280a 100644 (file)
@@ -1,3 +1,9 @@
+2003-03-17  John Levon  <levon@movementarian.org>
+
+       * screen.h:
+       * screen.C: remove cleared/background painting code,
+       update() was taking a pointless LyXText parameter
+
 2003-03-13  Angus Leeming  <leeming@lyx.org>
 
        * Dialogs.h: remove showParagraph and updateParagraph.
index 0abd95b123a6e7434155113cdad0d093c8537193..57be406c3d00d07b35fe265ddcfc4ab8600fa9f9 100644 (file)
@@ -111,7 +111,7 @@ SplashScreen::SplashScreen()
 
 
 LyXScreen::LyXScreen()
-       : cursor_visible_(false), force_clear_(true), greyed_out_(true)
+       : cursor_visible_(false), greyed_out_(true)
 {
        // Start loading the pixmap as soon as possible
        if (lyxrc.show_banner) {
@@ -244,11 +244,11 @@ bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
 }
 
 
-void LyXScreen::update(LyXText * text, BufferView * bv,
-       int yo, int xo)
+void LyXScreen::update(BufferView & bv, int yo, int xo)
 {
        int const vwidth = workarea().workWidth();
        int const vheight = workarea().workHeight();
+       LyXText * text = bv.text;
 
        workarea().getPainter().start();
 
@@ -256,27 +256,18 @@ void LyXScreen::update(LyXText * text, BufferView * bv,
        case LyXText::NEED_MORE_REFRESH:
        {
                int const y = max(int(text->refresh_y - text->top_y()), 0);
-               drawFromTo(text, bv, y, vheight, yo, xo);
-               text->refresh_y = 0;
-               // otherwise this is called ONLY from BufferView_pimpl(update)
-               // or we should see to set this flag accordingly
-               if (text != bv->text)
-                       text->status(bv, LyXText::UNCHANGED);
+               drawFromTo(text, &bv, y, vheight, yo, xo);
                expose(0, y, vwidth, vheight - y);
        }
        break;
        case LyXText::NEED_VERY_LITTLE_REFRESH:
        {
                // ok I will update the current cursor row
-               drawOneRow(text, bv, text->refresh_row, text->refresh_y,
+               drawOneRow(text, &bv, text->refresh_row, text->refresh_y,
                           yo, xo);
                // this because if we had a major update the refresh_row could
                // have been set to 0!
                if (text->refresh_row) {
-                       // otherwise this is called ONLY from BufferView_pimpl(update)
-                       // or we should see to set this flag accordingly
-                       if (text != bv->text)
-                               text->status(bv, LyXText::UNCHANGED);
                        expose(0, text->refresh_y - text->top_y() + yo,
                                   vwidth, text->refresh_row->height());
                }
@@ -448,9 +439,8 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
                internal = internal && (st != LyXText::CHANGED_IN_DRAW);
                while (internal && text->status() == LyXText::CHANGED_IN_DRAW) {
                        text->fullRebreak(bv);
-                       st = LyXText::NEED_MORE_REFRESH;
                        text->setCursor(bv, text->cursor.par(), text->cursor.pos());
-                       text->status(bv, st);
+                       text->postPaint(*bv, 0);
                        Row * prev = row->previous();
                        RowPainter rp(*bv, *text, *row);
                        if (rp.paint(y + yo, xo, y + text->top_y()))
@@ -459,7 +449,6 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
                y += row->height();
                row = row->next();
        }
-       force_clear_ = false;
 
        // maybe we have to clear the screen at the bottom
        if ((y < y2) && text->isTopLevel()) {
@@ -482,5 +471,4 @@ void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
                if (rp.paint(y, xo, y + text->top_y()))
                        text->markChangeInDraw(bv, row, prev);
        }
-       force_clear_ = false;
 }
index d802af94a3e65e519d6316f1f77ae2a50876a3df..ebb3ed13e075818ce2faad778a3cef3388c8983e 100644 (file)
@@ -118,18 +118,17 @@ public:
 
        /**
         * update - update part of the screen rendering
-        * @param text the containing text region
         * @param bv the bufferview
         * @param xo the x offset into the text
         * @param yo the x offset into the text
         *
-        * Updates part of the screen. If text->status is
+        * Updates part of the screen. If bv->text->status is
         * LyXText::NEED_MORE_REFRESH, we update from the
         * point of change and to the end of the screen.
         * If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
         * we only update the current row.
         */
-       virtual void update(LyXText * text, BufferView * bv, int yo = 0, int xo = 0);
+       virtual void update(BufferView & bv, int yo = 0, int xo = 0);
 
        /// FIXME
        virtual void toggleSelection(LyXText *, BufferView *, bool = true,
@@ -139,9 +138,6 @@ public:
        virtual void toggleToggle(LyXText *, BufferView *,
                          int y_offset = 0, int x_offset = 0);
 
-       /// FIXME
-       virtual bool forceClear() const { return force_clear_; }
-
 protected:
        /// cause the display of the given area of the work area
        virtual void expose(int x, int y, int w, int h) = 0;
@@ -164,9 +160,6 @@ private:
        /// grey out (no buffer)
        void greyOut();
 
-       /// FIXME ?
-       bool force_clear_;
-
        /// is the screen displaying text or the splash screen?
        bool greyed_out_;
 };
index 634f58458b1da8f063383e218cccf0e6f2ccf165..f37aaed00c14ff886b58efe6f91cfbf009fe1b4d 100644 (file)
@@ -1,3 +1,9 @@
+2003-03-17  John Levon  <levon@movementarian.org>
+
+       * most files: remove the "cleared" parameter 
+       to draw in favour of always clearing. Associated
+       code removal.
+
 2003-03-16  John Levon  <levon@movementarian.org>
 
        * insettext.C: remove unused s.refresh
index d75ac50cf64683a15122bed386f4ca44ee32bb2c..2ba03068fc3f0c370873868c6141ab694416c697 100644 (file)
@@ -162,8 +162,7 @@ public:
        ///
        virtual int width(BufferView *, LyXFont const &) const = 0;
        ///
-       virtual void draw(BufferView *, LyXFont const &,
-                         int baseline, float & x, bool cleared) const = 0;
+       virtual void draw(BufferView *, LyXFont const &, int baseline, float & x) const = 0;
        /// update the inset representation
        virtual void update(BufferView *, LyXFont const &, bool = false)
                {}
@@ -177,8 +176,6 @@ public:
        virtual EDITABLE editable() const;
        ///
        virtual bool isTextInset() const { return false; }
-       ///
-       virtual bool doClearArea() const { return true; }
        /// return true if the inset should be removed automatically
        virtual bool autoDelete() const;
        /// returns true the inset can hold an inset of given type
index aa1830d714d9353baf5bb6ccce49b0d3ad462ecd..53ea6738142499dbaf65642d0ecb4aa797712c6f 100644 (file)
@@ -93,7 +93,7 @@ int InsetButton::width(BufferView * bv, LyXFont const &) const
 
 
 void InsetButton::draw(BufferView * bv, LyXFont const &,
-                       int baseline, float & x, bool) const
+                       int baseline, float & x) const
 {
        lyx::Assert(bv);
        cache(bv);
index 6d5b872e393ae23dad6a1e98330827d54f439878..b0a6edbe0d0b06ef8542bd3f0b4d2228c252fd3f 100644 (file)
@@ -30,7 +30,7 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+       void draw(BufferView *, LyXFont const &, int, float &) const;
 
 protected:
        ///
index e27551c1b6cddaab34bbfdfe84d7a46c2cbb7775..af5e9d8d6ef7044d55f5d4146cf56faf47a121e1 100644 (file)
@@ -66,7 +66,7 @@ string const InsetCaption::editMessage() const
 
 
 void InsetCaption::draw(BufferView * bv, LyXFont const & f,
-                       int baseline, float & x, bool cleared) const
+                       int baseline, float & x) const
 {
        // We must draw the label, we should get the label string
        // from the enclosing float inset.
@@ -101,7 +101,7 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f,
        pain.text(int(x), baseline, label, f);
        x += w;
 
-       InsetText::draw(bv, f, baseline, x, cleared);
+       InsetText::draw(bv, f, baseline, x);
 }
 
 
index addf67cd8a51d223a561d48a375860c9639316af..1b4feaee446918d3f269e26c527207b931fbac53 100644 (file)
@@ -40,7 +40,7 @@ public:
        ///
        virtual
        void draw(BufferView * bv, LyXFont const & f,
-                         int baseline, float & x, bool cleared) const;
+                         int baseline, float & x) const;
        ///
        virtual
        int latex(Buffer const * buf, std::ostream & os,
index c87ad118d5154992326ff95d40395183e7d81774..f99bc2df9082a7edacb2d8dcf3e1dd2d85e5fbb5 100644 (file)
@@ -183,14 +183,14 @@ void InsetCollapsable::draw_collapsed(Painter & pain,
 
 
 void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
-                           int baseline, float & x, bool cleared) const
+                           int baseline, float & x) const
 {
        lyx::Assert(bv);
        cache(bv);
 
        if (need_update != NONE) {
                const_cast<InsetText *>(&inset)->update(bv, f, true);
-               bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
+               bv->text->postChangedInDraw();
                need_update = NONE;
                return;
        }
@@ -214,18 +214,6 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
        if (!owner())
                x += static_cast<float>(scroll());
 
-       if (!cleared && (inset.need_update == InsetText::FULL ||
-                        inset.need_update == InsetText::INIT ||
-                        top_x != int(x) ||
-                        top_baseline != baseline))
-       {
-               // we don't need anymore to clear here we just have to tell
-               // the underlying LyXText that it should do the RowClear!
-               inset.setUpdateStatus(bv, InsetText::FULL);
-               bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
-               return;
-       }
-
        top_x = int(x);
        topx_set = true;
        top_baseline = baseline;
@@ -233,9 +221,7 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
        int const bl = baseline - ascent(bv, f) + ascent_collapsed();
 
        draw_collapsed(pain, bl, old_x);
-       inset.draw(bv, f,
-                          bl + descent_collapsed() + inset.ascent(bv, f),
-                          x, cleared);
+       inset.draw(bv, f, bl + descent_collapsed() + inset.ascent(bv, f), x);
        if (x < (top_x + button_length + TEXT_TO_INSET_OFFSET))
                x = top_x + button_length + TEXT_TO_INSET_OFFSET;
 }
@@ -563,12 +549,6 @@ void InsetCollapsable::setFont(BufferView * bv, LyXFont const & font,
 }
 
 
-bool InsetCollapsable::doClearArea() const
-{
-       return inset.doClearArea();
-}
-
-
 LyXText * InsetCollapsable::getLyXText(BufferView const * bv,
                                       bool const recursive) const
 {
index 00bc07abff1bb1044da30eddf8af47d3f4c2e70a..7243844297e2464b09bf906b0e751962c19b2b96 100644 (file)
@@ -56,7 +56,7 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, const LyXFont &, int , float &, bool) const;
+       void draw(BufferView *, const LyXFont &, int , float &) const;
        ///
        void update(BufferView *, LyXFont const &, bool =false);
        ///
@@ -74,8 +74,6 @@ public:
        ///
        bool isTextInset() const { return true; }
        ///
-       bool doClearArea() const;
-       ///
        void insetUnlock(BufferView *);
        ///
        bool needFullRow() const { return isOpen(); }
index 14f81578d2e6e6dd5a910d7ebc52ae3f12372183..38135356cd1a57c4bf2463967c00f912efdb0567 100644 (file)
@@ -81,7 +81,7 @@ int InsetError::width(BufferView *, LyXFont const & font) const
 
 
 void InsetError::draw(BufferView * bv, LyXFont const & font,
-                     int baseline, float & x, bool) const
+                     int baseline, float & x) const
 {
        lyx::Assert(bv);
        cache(bv);
index e0d1ad36e37319e79c550cdeab8aa41d6e859db6..84581860955f03726e4d10a721f85c014e59e322 100644 (file)
@@ -37,7 +37,7 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+       void draw(BufferView *, LyXFont const &, int, float &) const;
        ///
        void write(Buffer const *, std::ostream &) const {}
        ///
index ab92203805e0036e746a1e652eb3ec46b362f9bc..b109121e6ccf98bf0c6a2a85dfee0a2e6c99b680 100644 (file)
@@ -567,7 +567,7 @@ int InsetERT::width(BufferView * bv, LyXFont const & font) const
 
 
 void InsetERT::draw(BufferView * bv, LyXFont const & f,
-                   int baseline, float & x, bool cleared) const
+                   int baseline, float & x) const
 {
        lyx::Assert(bv);
        cache(bv);
@@ -589,18 +589,6 @@ void InsetERT::draw(BufferView * bv, LyXFont const & f,
        if (!owner())
                x += static_cast<float>(scroll());
 
-       if (!cleared && (inset.need_update == InsetText::FULL ||
-                        inset.need_update == InsetText::INIT ||
-                        top_x != int(x) ||
-                        top_baseline != baseline))
-       {
-               // we don't need anymore to clear here we just have to tell
-               // the underlying LyXText that it should do the RowClear!
-               inset.setUpdateStatus(bv, InsetText::FULL);
-               bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
-               return;
-       }
-
        top_x = int(x);
        topx_set = true;
        top_baseline = baseline;
@@ -608,12 +596,10 @@ void InsetERT::draw(BufferView * bv, LyXFont const & f,
        int const bl = baseline - ascent(bv, f) + ascent_collapsed();
 
        if (inlined()) {
-               inset.draw(bv, f, baseline, x, cleared);
+               inset.draw(bv, f, baseline, x);
        } else {
                draw_collapsed(pain, bl, old_x);
-               inset.draw(bv, f,
-                                  bl + descent_collapsed() + inset.ascent(bv, f),
-                                  x, cleared);
+               inset.draw(bv, f, bl + descent_collapsed() + inset.ascent(bv, f), x);
        }
        need_update = NONE;
 }
index 8e67a373e3086c9586d33d3022717f79cf3632f0..57c138b3054089b144e0537604145ded4b795079 100644 (file)
@@ -109,7 +109,7 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, const LyXFont &, int , float &, bool) const;
+       void draw(BufferView *, const LyXFont &, int , float &) const;
        /// set the status of the inset
        void status(BufferView *, ERTStatus const st) const;
        ///
index ec49afb8c06eeb6c73f62ccc1f9cf82b3daea4c0..817c23b8bbc9c8d370ccfe0a5450c6338da929a8 100644 (file)
@@ -344,7 +344,7 @@ BufferView * InsetGraphics::view() const
 
 
 void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
-                        int baseline, float & x, bool) const
+                        int baseline, float & x) const
 {
        // MakeAbsPath returns params().filename unchanged if it absolute
        // already.
@@ -418,21 +418,6 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
                        paint.text(old_x + TEXT_TO_INSET_OFFSET + 6, baseline - 4, msg, msgFont);
                }
        }
-
-       // the status message may mean we changed size, so indicate
-       // we need a row redraw
-#if 0
-       if (old_status_ != grfx::ErrorUnknown && old_status_ != cached_status_) {
-               bv->getLyXText()->status(bv, LyXText::CHANGED_IN_DRAW);
-       }
-#endif
-
-       // Reset the cache, ready for the next draw request
-#if 0
-       cached_status_ = grfx::ErrorUnknown;
-       cached_image_.reset();
-       cache_filled_ = false;
-#endif
 }
 
 
index a0e1f2b89ab5fe77ce5e828d814197a70f10a420..03a1884bccec79bcca40f013cb34ef9a565a1c7f 100644 (file)
@@ -43,7 +43,7 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+       void draw(BufferView *, LyXFont const &, int, float &) const;
        ///
        void edit(BufferView *, int, int, mouse_button::state);
        ///
index ec0fb8f22658cf32768da9b7b055847f25906ca2..53a560105e040b644d5a49cb74f40dc24194c2ca 100644 (file)
@@ -557,11 +557,11 @@ int InsetInclude::width(BufferView * bv, LyXFont const & font) const
 
 
 void InsetInclude::draw(BufferView * bv, LyXFont const & font, int y,
-                       float & xx, bool b) const
+                       float & xx) const
 {
        cache(bv);
        if (!preview_->previewReady()) {
-               InsetButton::draw(bv, font, y, xx, b);
+               InsetButton::draw(bv, font, y, xx);
                return;
        }
 
index dcddeeb22fdef6a237769912451c0729006348ac..ef7d8e06eb739fa34bdc0d5ca09eea1a6a337657 100644 (file)
@@ -67,7 +67,7 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+       void draw(BufferView *, LyXFont const &, int, float &) const;
 
        /// get the parameters
        Params const & params(void) const;
index f05530fd6b6430327d4bc72fcf5cb1094d7c1d03..50df0dd6f367542edc8ba957d8528380f2e6f943 100644 (file)
@@ -360,7 +360,7 @@ bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font,
 
 
 void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
-                           int baseline, float & x, bool) const
+                           int baseline, float & x) const
 {
        Painter & pain = bv->painter();
 
index 712f768151efc0371bb570a6a439fa95ed7c7dcc..06345ef6e72554a3db8c8776692ebc838069a71b 100644 (file)
@@ -40,7 +40,7 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+       void draw(BufferView *, LyXFont const &, int, float &) const;
        ///
        int lbearing(LyXFont const & font) const;
        ///
index df8f82bd4779942a8e3dd3890f5480ca26425d15..cdea8f9d5b8249a3402be6aa584c60a45888aa6a 100644 (file)
@@ -88,7 +88,7 @@ int InsetNewline::docbook(Buffer const *, std::ostream &, bool) const
 
 
 void InsetNewline::draw(BufferView * bv, LyXFont const & font,
-                       int baseline, float & x, bool) const
+                       int baseline, float & x) const
 {
        Painter & pain(bv->painter());
 
index 3a912ab6834d358750f6a42197c790373b88dc59..3a60b125965f148e0f09e32fddaaf1b0ba782343 100644 (file)
@@ -33,7 +33,7 @@ public:
        virtual int width(BufferView *, LyXFont const &) const;
 
        virtual void draw(BufferView *, LyXFont const &,
-                         int baseline, float & x, bool cleared) const;
+                         int baseline, float & x) const;
 
        virtual int latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
 
index 69b01d0eab8cb6362dbcbf248c14927a71d9e5e4..a8616be0cdb050dcc01393f4ce1029c6c6d07b84 100644 (file)
@@ -218,7 +218,7 @@ LyXFont const InsetQuotes::convertFont(LyXFont const & f) const
 
 
 void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
-                      int baseline, float & x, bool) const
+                      int baseline, float & x) const
 {
        string const text = dispString(font.language());
 
index 3bfa6c095fb194f2168a187414082c41835aa72d..5d5a10463ad6a22098cf8c1149a4b25c194fc6c0 100644 (file)
@@ -76,7 +76,7 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+       void draw(BufferView *, LyXFont const &, int, float &) const;
 #if 0
        ///
        LyXFont const convertFont(LyXFont const & font) const;
index 510dee9f442fa4b82366fa213aa8865887aa92a5..23a30b53d4f0ec0f17a0b37b416884cb2ce0c172 100644 (file)
@@ -85,7 +85,7 @@ int InsetSpecialChar::width(BufferView *, LyXFont const & font) const
 
 
 void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
-                           int baseline, float & x, bool) const
+                           int baseline, float & x) const
 {
        Painter & pain = bv->painter();
        LyXFont font(f);
index 79ced1f07db94350b24386bddae82a17fd937a8e..09bc4d7d02c613a9056d99e58111e5d08670e7b4 100644 (file)
@@ -54,7 +54,7 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+       void draw(BufferView *, LyXFont const &, int, float &) const;
        ///
        void write(Buffer const *, std::ostream &) const;
        /// Will not be used when lyxf3
index 5900e6e07973fe00344f734d4447d5b27a3da911..ece2cab22c324ba49536caea142b0c03c4e4a804 100644 (file)
@@ -261,20 +261,12 @@ int InsetTabular::width(BufferView *, LyXFont const &) const
 
 
 void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
-                       float & x, bool cleared) const
+                       float & x) const
 {
        if (nodraw()) {
-               if (cleared)
-                       need_update = FULL;
-               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;
@@ -282,173 +274,53 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
        int nx;
 
 #if 0
-       UpdatableInset::draw(bv, font, baseline, x, cleared);
+       UpdatableInset::draw(bv, font, baseline, x);
 #else
        if (!owner())
                x += static_cast<float>(scroll());
 #endif
-       if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
-                        (top_x != int(x)) || (top_baseline != baseline)))
-       {
-               int h = ascent(bv, font) + descent(bv, font);
-               int const tx = display() || !owner() ? 0 : top_x;
-               int w =  tx ? width(bv, font) : pain.paperWidth();
-               int ty = baseline - ascent(bv, font);
-
-               if (ty < 0)
-                       ty = 0;
-               if ((ty + h) > pain.paperHeight())
-                       h = pain.paperHeight();
-               if ((top_x + w) > pain.paperWidth())
-                       w = pain.paperWidth();
-               pain.fillRectangle(tx, ty, w, h, backgroundColor());
-               need_update = FULL;
-               cleared = true;
-       }
+
        top_x = int(x);
        topx_set = true;
        top_baseline = baseline;
        x += ADD_TO_TABULAR_WIDTH;
-       if (cleared) {
-               int cell = 0;
-               float cx;
-               first_visible_cell = -1;
-               for (i = 0; i < tabular->rows(); ++i) {
-                       nx = int(x);
-                       cell = tabular->GetCellNumber(i, 0);
-                       if (!((baseline + tabular->GetDescentOfRow(i)) > 0) &&
-                               (baseline - tabular->GetAscentOfRow(i))<pain.paperHeight())
-                       {
-                               baseline += tabular->GetDescentOfRow(i) +
-                                       tabular->GetAscentOfRow(i + 1) +
-                                       tabular->GetAdditionalHeight(i + 1);
-                               continue;
-                       }
-                       for (j = 0; j < tabular->columns(); ++j) {
-                               if (nx > bv->workWidth())
-                                       break;
-                               if (tabular->IsPartOfMultiColumn(i, j))
-                                       continue;
-                               cx = nx + tabular->GetBeginningOfTextInCell(cell);
-                               if (first_visible_cell < 0)
-                                       first_visible_cell = cell;
-                               if (hasSelection()) {
-                                       drawCellSelection(pain, nx, baseline, i, j, cell);
-                               }
 
-                               tabular->GetCellInset(cell)->draw(bv, font, baseline, cx, cleared);
-                               drawCellLines(pain, nx, baseline, i, cell);
-                               nx += tabular->GetWidthOfColumn(cell);
-                               ++cell;
-                       }
-                       baseline += tabular->GetDescentOfRow(i) +
+       int cell = 0;
+       float cx;
+       first_visible_cell = -1;
+       for (i = 0; i < tabular->rows(); ++i) {
+               nx = int(x);
+               cell = tabular->GetCellNumber(i, 0);
+               if (!((baseline + tabular->GetDescentOfRow(i)) > 0) &&
+                       (baseline - tabular->GetAscentOfRow(i))<pain.paperHeight())
+               {
+               baseline += tabular->GetDescentOfRow(i) +
                                tabular->GetAscentOfRow(i + 1) +
                                tabular->GetAdditionalHeight(i + 1);
+                       continue;
                }
-       } else if (need_update == CELL) {
-               int cell = 0;
-               nx = int(x);
-               if (the_locking_inset &&
-                       tabular->GetCellInset(actcell) != the_locking_inset)
-               {
-                       Inset * inset = tabular->GetCellInset(cell);
-                       for (i = 0;
-                            inset != the_locking_inset && i < tabular->rows();
-                            ++i)
-                       {
-                               for (j = 0;
-                                    inset != the_locking_inset && j < tabular->columns();
-                                    ++j)
-                               {
-                                       if (tabular->IsPartOfMultiColumn(i, j))
-                                               continue;
-                                       nx += tabular->GetWidthOfColumn(cell);
-                                       ++cell;
-                                       inset = tabular->GetCellInset(cell);
-                               }
-                               if (tabular->row_of_cell(cell) > i) {
-                                       nx = int(x);
-                                       baseline += tabular->GetDescentOfRow(i) +
-                                               tabular->GetAscentOfRow(i + 1) +
-                                               tabular->GetAdditionalHeight(i + 1);
-                               }
-                       }
-               } else {
-                       // compute baseline for actual row
-                       for (i = 0; i < actrow; ++i) {
-                               baseline += tabular->GetDescentOfRow(i) +
-                                       tabular->GetAscentOfRow(i + 1) +
-                                       tabular->GetAdditionalHeight(i + 1);
-                       }
-                       // now compute the right x position
-                       cell = tabular->GetCellNumber(actrow, 0);
-                       for (j = 0; (cell < actcell) && (j < tabular->columns()); ++j) {
-                                       if (tabular->IsPartOfMultiColumn(actrow, j))
-                                               continue;
-                                       nx += tabular->GetWidthOfColumn(cell);
-                                       ++cell;
+               for (j = 0; j < tabular->columns(); ++j) {
+                       if (nx > bv->workWidth())
+                               break;
+                       if (tabular->IsPartOfMultiColumn(i, j))
+                               continue;
+                       cx = nx + tabular->GetBeginningOfTextInCell(cell);
+                       if (first_visible_cell < 0)
+                               first_visible_cell = cell;
+                       if (hasSelection()) {
+                               drawCellSelection(pain, nx, baseline, i, j, cell);
                        }
+
+                       tabular->GetCellInset(cell)->draw(bv, font, baseline, cx);
+                       drawCellLines(pain, nx, baseline, i, cell);
+                       nx += tabular->GetWidthOfColumn(cell);
+                       ++cell;
                }
-               i = tabular->row_of_cell(cell);
-               if (the_locking_inset != tabular->GetCellInset(cell)) {
-                       lyxerr[Debug::INSETTEXT] << "ERROR this shouldn't happen\n";
-                       return;
-               }
-               float dx = nx + tabular->GetBeginningOfTextInCell(cell);
-               float cx = dx;
-               tabular->GetCellInset(cell)->draw(bv, font, baseline, dx, false);
-               //
-               // Here we use rectangular backgroundColor patches to clean up
-               // within a cell around the cell's red inset box. As follows:
-               //
-               //  +--------------------+
-               //  |         C          |   The rectangles are A, B and C
-               //  | A |------------| B |   below, origin top left (tx, ty),
-               //  |   |  inset box |   |   dimensions w(idth), h(eight).
-               //  +---+------------+---+   x grows rightward, y downward
-               //  |         D          |
-               //  +--------------------+
-               //
-#if 0
-               // clear only if we didn't have a change
-               if (bv->text->status() != LyXText::CHANGED_IN_DRAW) {
-#endif
-                       // clear before the inset
-                       int tx, ty, w, h;
-                       tx = nx + 1;
-                       ty = baseline - tabular->GetAscentOfRow(i) + 1;
-                       w = int(cx - nx - 1);
-                       h = tabular->GetAscentOfRow(i) +
-                               tabular->GetDescentOfRow(i) - 1;
-                       pain.fillRectangle(tx, ty, w, h, backgroundColor());
-                       // clear behind the inset
-                       tx = int(cx + the_locking_inset->width(bv,font) + 1);
-                       ty = baseline - tabular->GetAscentOfRow(i) + 1;
-                       w = tabular->GetWidthOfColumn(cell) -
-                               tabular->GetBeginningOfTextInCell(cell) -
-                               the_locking_inset->width(bv,font) -
-                               tabular->GetAdditionalWidth(cell) - 1;
-                       h = tabular->GetAscentOfRow(i) + tabular->GetDescentOfRow(i) - 1;
-                       pain.fillRectangle(tx, ty, w, h, backgroundColor());
-                       // clear below the inset
-                       tx = nx + 1;
-                       ty = baseline + the_locking_inset->descent(bv, font) + 1;
-                       w = tabular->GetWidthOfColumn(cell) -
-                               tabular->GetAdditionalWidth(cell) - 1;
-                       h = tabular->GetDescentOfRow(i) -
-                               the_locking_inset->descent(bv, font) - 1;
-                       pain.fillRectangle(tx, ty, w, h, backgroundColor());
-                       // clear above the inset
-                       tx = nx + 1;
-                       ty = baseline - tabular->GetAscentOfRow(i) + 1;
-                       w = tabular->GetWidthOfColumn(cell) -
-                               tabular->GetAdditionalWidth(cell) - 1;
-                       h = tabular->GetAscentOfRow(i) - the_locking_inset->ascent(bv, font);
-                       pain.fillRectangle(tx, ty, w, h, backgroundColor());
-#if 0
-               }
-#endif
+               baseline += tabular->GetDescentOfRow(i) +
+                       tabular->GetAscentOfRow(i + 1) +
+                       tabular->GetAdditionalHeight(i + 1);
        }
+
        x -= ADD_TO_TABULAR_WIDTH;
        x += width(bv, font);
        if (bv->text->status() == LyXText::CHANGED_IN_DRAW) {
@@ -2674,12 +2546,6 @@ int InsetTabular::scroll(bool recursive) const
 }
 
 
-bool InsetTabular::doClearArea() const
-{
-       return !locked || (need_update & (FULL|INIT));
-}
-
-
 void InsetTabular::getSelection(int & srow, int & erow,
                                int & scol, int & ecol) const
 {
index 81cb7f3fb3042e301c5e9b39c557f07ad66e9b13..51314c0925ca6e4651d8e4e0beae716ef660606b 100644 (file)
@@ -92,7 +92,7 @@ public:
        ///
        int width(BufferView *, LyXFont const & f) const;
        ///
-       void draw(BufferView *, const LyXFont &, int , float &, bool) const;
+       void draw(BufferView *, const LyXFont &, int , float &) const;
        ///
        void update(BufferView *, LyXFont const &, bool = false);
        ///
@@ -101,9 +101,7 @@ public:
        void edit(BufferView *, int x, int y, mouse_button::state);
        ///
        void edit(BufferView * bv, bool front = true);
-       ///
-       bool doClearArea() const;
-       ///
+       //
        void insetUnlock(BufferView *);
        ///
        void updateLocal(BufferView *, UpdateCodes, bool mark_dirty) const;
index 0a5daf47f58efcdd6a186b8b2dbdef17c8a474e2..4b2d82fa9d6cc67d8426795d196a7a3f69991473 100644 (file)
@@ -194,7 +194,6 @@ void InsetText::init(InsetText const * ins, bool same_id)
        locked = false;
        old_par = 0;
        last_drawn_width = -1;
-       frame_is_visible = false;
        cached_bview = 0;
        sstate.lpar = 0;
        in_insetAllowed = false;
@@ -346,7 +345,7 @@ int InsetText::textWidth(BufferView * bv, bool fordraw) const
 
 
 void InsetText::draw(BufferView * bv, LyXFont const & f,
-                    int baseline, float & x, bool cleared) const
+                    int baseline, float & x) const
 {
        if (nodraw())
                return;
@@ -356,7 +355,6 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
        // this is the first thing we have to ask because if the x pos
        // changed we have to do a complete rebreak of the text as we
        // may have few space to draw in. Well we should check on this too
-       int old_x = top_x;
        if (top_x != int(x)) {
                top_x = int(x);
                topx_set = true;
@@ -364,7 +362,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
                if (nw > 0 && old_max_width != nw) {
                        need_update = INIT;
                        old_max_width = nw;
-                       bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
+                       bv->text->postChangedInDraw();
                        return;
                }
        }
@@ -376,16 +374,13 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
        descent(bv, f);
 
        // repaint the background if needed
-       if (cleared && backgroundColor() != LColor::background) {
-               clearInset(bv, baseline, cleared);
-       }
+       if (backgroundColor() != LColor::background)
+               clearInset(bv, baseline);
 
        // no draw is necessary !!!
        if ((drawFrame_ == LOCKED) && !locked && paragraphs.begin()->empty()) {
                top_baseline = baseline;
                x += width(bv, f);
-               if (need_update & CLEAR_FRAME)
-                       clearFrame(pain, cleared);
                need_update = NONE;
                return;
        }
@@ -393,31 +388,10 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
        if (!owner())
                x += static_cast<float>(scroll());
 
-       // if top_x differs we did it already
-       if (!cleared && (old_x == int(x))
-           && ((need_update&(INIT|FULL)) || (top_baseline != baseline)
-               ||(last_drawn_width != insetWidth)))
-       {
-               // Condition necessary to eliminate bug 59 attachment 37
-               if (baseline > 0)
-                       clearInset(bv, baseline, cleared);
-       }
-
-       if (cleared)
-               frame_is_visible = false;
-
-       if (!cleared && (need_update == NONE)) {
-               if (locked)
-                       drawFrame(pain, cleared);
-               return;
-       }
-
        top_baseline = baseline;
        top_y = baseline - insetAscent;
 
        if (last_drawn_width != insetWidth) {
-               if (!cleared)
-                       clearInset(bv, baseline, cleared);
                need_update |= FULL;
                last_drawn_width = insetWidth;
        }
@@ -427,13 +401,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
                inset_x = cix(bv) - top_x + drawTextXOffset;
                inset_y = ciy(bv) + drawTextYOffset;
        }
-       if (!cleared && (need_update == CURSOR)
-           && !getLyXText(bv)->selection.set()) {
-               drawFrame(pain, cleared);
-               x += insetWidth;
-               need_update = NONE;
-               return;
-       }
+
        bool clear = false;
        if (!lt) {
                lt = getLyXText(bv);
@@ -459,62 +427,38 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
                lt->top_y(first);
                first = 0;
        }
-       if (cleared || (need_update&(INIT|FULL))) {
-               int yf = y_offset + first;
-               y = 0;
-               while ((row != 0) && (yf < ph)) {
-                       Row * prev = row->previous();
-                       RowPainter rp(*bv, *lt, *row);
-                       if (rp.paint(y + y_offset + first, int(x), y + lt->top_y(), cleared))
-                               lt->markChangeInDraw(bv, row, prev);
-                       if (bv->text->status() == LyXText::CHANGED_IN_DRAW) {
-                               lt->need_break_row = row;
-                               lt->fullRebreak(bv);
-                               lt->setCursor(bv, lt->cursor.par(),
-                                             lt->cursor.pos());
-                               if (lt->selection.set()) {
-                                       lt->setCursor(bv, lt->selection.start,
-                                                     lt->selection.start.par(),
-                                                     lt->selection.start.pos());
-                                       lt->setCursor(bv, lt->selection.end,
-                                                     lt->selection.end.par(),
-                                                     lt->selection.end.pos());
-                               }
-                               break;
+
+       int yf = y_offset + first;
+       y = 0;
+       while ((row != 0) && (yf < ph)) {
+               Row * prev = row->previous();
+               RowPainter rp(*bv, *lt, *row);
+               if (rp.paint(y + y_offset + first, int(x), y + lt->top_y()))
+                       lt->markChangeInDraw(bv, row, prev);
+               if (bv->text->status() == LyXText::CHANGED_IN_DRAW) {
+                       lt->need_break_row = row;
+                       lt->fullRebreak(bv);
+                       lt->setCursor(bv, lt->cursor.par(),
+                                     lt->cursor.pos());
+                       if (lt->selection.set()) {
+                               lt->setCursor(bv, lt->selection.start,
+                                             lt->selection.start.par(),
+                                             lt->selection.start.pos());
+                               lt->setCursor(bv, lt->selection.end,
+                                             lt->selection.end.par(),
+                                             lt->selection.end.pos());
                        }
-                       y += row->height();
-                       yf += row->height();
-                       row = row->next();
-               }
-       } 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;
@@ -529,30 +473,15 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
 }
 
 
-void InsetText::drawFrame(Painter & pain, bool cleared) const
+void InsetText::drawFrame(Painter & pain) const
 {
        static int const ttoD2 = TEXT_TO_INSET_OFFSET / 2;
-       if (!frame_is_visible || cleared) {
-               frame_x = top_x + ttoD2;
-               frame_y = top_baseline - insetAscent + ttoD2;
-               frame_w = insetWidth - TEXT_TO_INSET_OFFSET;
-               frame_h = insetAscent + insetDescent - TEXT_TO_INSET_OFFSET;
-               pain.rectangle(frame_x, frame_y, frame_w, frame_h,
-                              frame_color);
-               frame_is_visible = true;
-       }
-}
-
-
-void InsetText::clearFrame(Painter & pain, bool cleared) const
-{
-       if (frame_is_visible) {
-               if (!cleared) {
-                       pain.rectangle(frame_x, frame_y, frame_w, frame_h,
-                                      backgroundColor());
-               }
-               frame_is_visible = false;
-       }
+       frame_x = top_x + ttoD2;
+       frame_y = top_baseline - insetAscent + ttoD2;
+       frame_w = insetWidth - TEXT_TO_INSET_OFFSET;
+       frame_h = insetAscent + insetDescent - TEXT_TO_INSET_OFFSET;
+       pain.rectangle(frame_x, frame_y, frame_w, frame_h,
+                      frame_color);
 }
 
 
@@ -791,16 +720,8 @@ void InsetText::insetUnlock(BufferView * bv)
        no_selection = true;
        locked = false;
        int code = NONE;
-#if 0
-       if (drawFrame_ == LOCKED)
-               code = CURSOR|CLEAR_FRAME;
-       else
-               code = CURSOR;
-#else
-       if (drawFrame_ == LOCKED)
-               code = CLEAR_FRAME;
-#endif
        bool clear = false;
+
        if (!lt) {
                lt = getLyXText(bv);
                clear = true;
@@ -2470,12 +2391,6 @@ int InsetText::scroll(bool recursive) const
 }
 
 
-bool InsetText::doClearArea() const
-{
-       return !locked || (need_update & (FULL|INIT));
-}
-
-
 void InsetText::selectAll(BufferView * bv)
 {
        getLyXText(bv)->cursorTop(bv);
@@ -2491,7 +2406,7 @@ void InsetText::clearSelection(BufferView * bv)
 }
 
 
-void InsetText::clearInset(BufferView * bv, int baseline, bool & cleared) const
+void InsetText::clearInset(BufferView * bv, int baseline) const
 {
        Painter & pain = bv->painter();
        int w = insetWidth;
@@ -2508,9 +2423,7 @@ void InsetText::clearInset(BufferView * bv, int baseline, bool & cleared) const
                w = pain.paperWidth();
 //     w -= TEXT_TO_INSET_OFFSET;
        pain.fillRectangle(top_x + 1, ty + 1, w - 1, h - 1, backgroundColor());
-       cleared = true;
        need_update = FULL;
-       frame_is_visible = false;
 }
 
 
index 487e9a0e4a2a6e2968df4cab4d5e441214154d37..ee332ec2d5ad1f99f7a950c504c1d42454aa4fc3 100644 (file)
@@ -47,17 +47,15 @@ public:
                ///
                CURSOR = 1,
                ///
-               CLEAR_FRAME = 2,
+               DRAW_FRAME = 2,
                ///
-               DRAW_FRAME = 4,
+               SELECTION = 4,
                ///
-               SELECTION = 8,
+               CURSOR_PAR = 8,
                ///
-               CURSOR_PAR = 16,
+               FULL = 16,
                ///
-               FULL = 32,
-               ///
-               INIT = 64
+               INIT = 32
        };
        ///
        enum DrawFrame {
@@ -94,7 +92,7 @@ public:
        ///
        int textWidth(BufferView *, bool fordraw = false) const;
        ///
-       void draw(BufferView *, LyXFont const &, int , float &, bool) const;
+       void draw(BufferView *, LyXFont const &, int , float &) const;
        ///
        void update(BufferView *, LyXFont const &, bool = false);
        ///
@@ -108,8 +106,6 @@ public:
        ///
        bool isTextInset() const { return true; }
        ///
-       bool doClearArea() const;
-       ///
        void insetUnlock(BufferView *);
        ///
        bool lockInsetInInset(BufferView *, UpdatableInset *);
@@ -346,11 +342,9 @@ private:
        ///
        Row * crow(BufferView *) const;
        ///
-       void drawFrame(Painter &, bool cleared) const;
+       void drawFrame(Painter &) const;
        ///
-       void clearFrame(Painter &, bool cleared) const;
-       ///
-       void clearInset(BufferView *, int baseline, bool & cleared) const;
+       void clearInset(BufferView *, int baseline) const;
        ///
        void saveLyXTextState(LyXText *) const;
        ///
@@ -394,8 +388,6 @@ private:
        ///
        mutable int last_drawn_width;
        ///
-       mutable bool frame_is_visible;
-       ///
        mutable BufferView * cached_bview;
        ///
        mutable boost::shared_ptr<LyXText> cached_text;
index 9ed4b5cb7f73d34248933b4e9e132c9e626d613c..b7c7eafee8936b0ad4427e5d8e52df4f2716df04 100644 (file)
@@ -73,8 +73,7 @@ void UpdatableInset::edit(BufferView *, bool)
 
 
 void UpdatableInset::draw(BufferView *, LyXFont const &,
-                         int /* baseline */, float & x,
-                         bool/*cleared*/) const
+                         int /* baseline */, float & x) const
 {
        x += float(scx);
        // ATTENTION: don't do the following here!!!
index 192ced8ed83b69f7c27d9e95caa629a8ce83cb4a..a7ce6032327abe16930f43ac7f78e5f412bbc9fe 100644 (file)
@@ -75,7 +75,7 @@ public:
        virtual void edit(BufferView *, bool front = true);
        ///
        virtual void draw(BufferView *, LyXFont const &,
-                         int baseline, float & x, bool cleared) const;
+                         int baseline, float & x) const;
        ///
        virtual bool insertInset(BufferView *, Inset *) { return false; }
        ///
index 540b47455fd9373be9dcaf80aca60f7c7db66a6a..8efa06d90b42e94486531f24ebca146f4f1eb4b8 100644 (file)
@@ -187,29 +187,6 @@ public:
 
        ///
        mutable Row * need_break_row;
-       /**
-        * The pixel y position from which to repaint the screen.
-        * The position is absolute along the height of outermost
-        * lyxtext (I think). NEED_MORE_REFRESH and NEED_LITTLE_REFRESH
-        * repaints both use this as a starting point (if it's within
-        * the viewable portion of the lyxtext).
-        */
-       mutable int refresh_y;
-       /**
-        * The row from which to repaint the screen, used by screen.c.
-        * This must be set if the pending update is NEED_LITTLE_REFRESH.
-        * It doesn't make any difference for NEED_MORE_REFRESH.
-        */
-       mutable Row * refresh_row;
-
-       /**
-        * Return the status. This represents what repaints are
-        * pending after some operation (e.g. inserting a char).
-        */
-       text_status status() const;
-
-       /// Set the status to make a paint pending.
-       void status(BufferView *, text_status) const;
 
        /// clear any pending paints
        void clearPaint();
@@ -230,15 +207,36 @@ public:
        ///
        Inset::RESULT dispatch(FuncRequest const & cmd);
 
+       friend class LyXScreen;
+
+       /**
+        * Return the status. This represents what repaints are
+        * pending after some operation (e.g. inserting a char).
+        */
+       text_status status() const;
+
 private:
+       /**
+        * The pixel y position from which to repaint the screen.
+        * The position is absolute along the height of outermost
+        * lyxtext (I think). NEED_MORE_REFRESH and NEED_LITTLE_REFRESH
+        * repaints both use this as a starting point (if it's within
+        * the viewable portion of the lyxtext).
+        */
+       int refresh_y;
+       /**
+        * The row from which to repaint the screen, used by screen.c.
+        * This must be set if the pending update is NEED_LITTLE_REFRESH.
+        * It doesn't make any difference for NEED_MORE_REFRESH.
+        */
+       mutable Row * refresh_row;
+
+       /// refresh status
+       text_status status_;
+
        /// only the top-level LyXText has this non-zero
        BufferView * bv_owner;
 
-       /** wether the screen needs a refresh,
-          starting with refresh_y
-          */
-       mutable text_status status_;
-
 public:
        /** returns a pointer to the row near the specified y-coordinate
          (relative to the whole text). y is set to the real beginning
index d8a90be29361a05900b07499dc4c03f97cfe387e..15d10238f51d9c0bd9e7a831979806ac2bc973e9 100644 (file)
@@ -194,7 +194,7 @@ void InsetFormula::read(Buffer const *, LyXLex & lex)
 
 
 void InsetFormula::draw(BufferView * bv, LyXFont const & font,
-                       int y, float & xx, bool) const
+                       int y, float & xx) const
 {
        cache(bv);
        // This initiates the loading of the preview, so should come
index fd9c7550bef78ccc1e601f95ea8ba270d9cde67f..3c7381ee24a172e7fac38c634fcfe75a5b368da5 100644 (file)
@@ -41,7 +41,7 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+       void draw(BufferView *, LyXFont const &, int, float &) const;
 
        ///
        void write(Buffer const *, std::ostream &) const;
index f7f355532cce02b1fa9ce5bfb6dce62d7992dd05..8a99e1089d12e0eb31321f77364973a829dae601 100644 (file)
@@ -37,7 +37,7 @@ public:
        ///
        virtual int width(BufferView *, LyXFont const &) const = 0;
        ///
-       virtual void draw(BufferView *,LyXFont const &, int, float &, bool) const = 0;
+       virtual void draw(BufferView *,LyXFont const &, int, float &) const = 0;
        /// lowest x coordinate
        virtual int xlow() const;
        /// highest x coordinate
index 35f2ed3d0038ee1b8b0166dee1158f67090af6e6..dbdfaf0294a89ecf799238689195aedbc3b5c91b 100644 (file)
@@ -171,7 +171,7 @@ Inset::Code InsetFormulaMacro::lyxCode() const
 
 
 void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
-                            int y, float & xx, bool /*cleared*/) const
+                            int y, float & xx) const
 {
        // label
        LyXFont font(f);
index 01815f10977c50bc14d8f8f7db270d940d95edf0..8ad88e40019b5141f0133eea8c9f8071b5e60dba 100644 (file)
@@ -39,7 +39,7 @@ public:
        ///
        int width(BufferView *, LyXFont const &) const;
        ///
-       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
+       void draw(BufferView *, LyXFont const &, int, float &) const;
 
        ///
        void read(Buffer const *, LyXLex & lex);
index 5e5302e9b53ce02b8437e6aa2ef9a39d2c185372..db2cc8135a203ae786e1a13691c4c0055c27ca50 100644 (file)
@@ -114,7 +114,7 @@ bool RowPainter::paintInset(pos_type const pos)
        LyXFont const & font = getFont(pos);
 
        inset->update(perv(bv_), font, false);
-       inset->draw(perv(bv_), font, yo_ + row_.baseline(), x_, cleared_);
+       inset->draw(perv(bv_), font, yo_ + row_.baseline(), x_);
 
        // return true if something changed when we drew an inset
 
@@ -305,63 +305,12 @@ bool RowPainter::paintFromPos(pos_type & vpos)
 }
 
 
-bool RowPainter::paintBackground()
+void RowPainter::paintBackground()
 {
-       pos_type const last = row_.lastPrintablePos();
-       bool clear_area = true;
-       Inset const * inset = 0;
-
-       if (!bv_.screen().forceClear() && last == row_.pos()
-           && row_.pos() < par_.size()
-           && par_.isInset(row_.pos())) {
-               inset = par_.getInset(row_.pos());
-               clear_area = inset->doClearArea();
-       }
-
-       if (cleared_) {
-               return true;
-       }
-
-       if (clear_area) {
-               int const x = xo_;
-               int const y = yo_ < 0 ? 0 : yo_;
-               int const h = yo_ < 0 ? row_.height() + yo_ : row_.height();
-               pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
-               return true;
-       }
-
-       if (!inset)
-               return false;
-
-       LyXFont font(LyXFont::ALL_SANE);
-
-       // FIXME
-       BufferView * bv = perv(bv_);
-
-       int h = row_.baseline() - inset->ascent(bv, font);
-
-       // first clear the whole row above the inset!
-       if (h > 0) {
-               pain_.fillRectangle(xo_, yo_, width_, h, text_.backgroundColor());
-       }
-
-       // clear the space below the inset!
-       h += inset->ascent(bv, font) + inset->descent(bv, font);
-       if ((row_.height() - h) > 0) {
-               pain_.fillRectangle(xo_, yo_ + h,
-                       width_, row_.height() - h, text_.backgroundColor());
-       }
-
-       // clear the space behind the inset, if needed
-       if (!inset->display() && !inset->needFullRow()) {
-               int const xp = int(x_) + inset->width(bv, font);
-               if (width_ - xp > 0) {
-                       pain_.fillRectangle(xp, yo_, width_ - xp,
-                               row_.height(), text_.backgroundColor());
-               }
-       }
-
-       return false;
+       int const x = xo_;
+       int const y = yo_ < 0 ? 0 : yo_;
+       int const h = yo_ < 0 ? row_.height() + yo_ : row_.height();
+       pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
 }
 
 
@@ -1021,12 +970,11 @@ bool RowPainter::paintText()
 }
 
 
-bool RowPainter::paint(int y_offset, int x_offset, int y, bool cleared)
+bool RowPainter::paint(int y_offset, int x_offset, int y)
 {
        xo_ = x_offset;
        yo_ = y_offset;
        y_ = y;
-       cleared_ = cleared;
        width_ = text_.isInInset()
                ? text_.inset_owner->textWidth(perv(bv_), true) : bv_.workWidth();
 
@@ -1041,8 +989,10 @@ bool RowPainter::paint(int y_offset, int x_offset, int y, bool cleared)
                x_ = 0;
        x_ += xo_;
 
-       // clear to background if necessary
-       cleared_ = paintBackground();
+       // If we're *not* at the top-level of rows, then the
+       // background has already been cleared.
+       if (&text_ == bv_.text)
+               paintBackground();
 
        // paint the selection background
        if (text_.selection.set()) {
index 9c0c534733b9913c32b4ed6f5aaccfd43bdcdfdb..ad79fd2ac5fb85e0d0d26deca428eeb9aa11497b 100644 (file)
@@ -34,11 +34,11 @@ public:
        RowPainter(BufferView const & bv, LyXText const & text, Row const & row);
 
        /// paint the row. Returns true if CHANGED_IN_DRAW (e.g. image was loaded)
-       bool paint(int y_offset, int x_offset, int y, bool cleared = false);
+       bool paint(int y_offset, int x_offset, int y);
 
 private:
        // paint various parts
-       bool paintBackground();
+       void paintBackground();
        void paintSelection();
        void paintAppendix();
        void paintDepthBar();
@@ -94,7 +94,6 @@ private:
        int yo_;
        float x_;
        int y_;
-       bool cleared_;
        int width_;
        float separator_;
        float hfill_;
index 1040c8a11395507d013df094c596e24cf300fc32..da9940a808be069f260b39cf13995c1447f87f93 100644 (file)
@@ -54,17 +54,19 @@ using lyx::pos_type;
 LyXText::LyXText(BufferView * bv)
        : height(0), width(0), top_row_(0), top_row_offset_(0),
          inset_owner(0), the_locking_inset(0), need_break_row(0),
-         refresh_y(0), refresh_row(0), bv_owner(bv),
-         status_(LyXText::UNCHANGED), firstrow(0), lastrow(0)
-{}
+         bv_owner(bv), firstrow(0), lastrow(0)
+{
+       clearPaint();
+}
 
 
 LyXText::LyXText(InsetText * inset)
        : height(0), width(0), top_row_(0), top_row_offset_(0),
          inset_owner(inset), the_locking_inset(0), need_break_row(0),
-         refresh_y(0), refresh_row(0), bv_owner(0),
-         status_(LyXText::UNCHANGED), firstrow(0), lastrow(0)
-{}
+         bv_owner(0), firstrow(0), lastrow(0)
+{
+       clearPaint();
+}
 
 
 void LyXText::init(BufferView * bview, bool reinit)
@@ -321,10 +323,14 @@ void LyXText::removeRow(Row * row) const
                lyx::Assert(!row->next());
                lastrow = row_prev;
        }
+
+       /* FIXME: when we cache the bview, this should just
+        * become a postPaint(), I think */
        if (refresh_row == row) {
                refresh_row = row_prev ? row_prev : row->next();
-               // what about refresh_y, refresh_height
+               // what about refresh_y
        }
+
        if (top_row_ == row) {
                if (row->next()) {
                        top_row_ = row->next();
@@ -713,10 +719,8 @@ void LyXText::redoHeightOfParagraph(BufferView * bview)
                setHeightOfRow(bview, tmprow);
        }
 
-       // we can set the refreshing parameters now
-       status(bview, LyXText::NEED_MORE_REFRESH);
-       refresh_y = y;
-       refresh_row = tmprow;
+       postPaint(*bview, y);
+
        setCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary());
 }
 
@@ -734,12 +738,7 @@ void LyXText::redoDrawingOfParagraph(BufferView * bview, LyXCursor const & cur)
                y -= tmprow->height();
        }
 
-       // we can set the refreshing parameters now
-       if (status_ == LyXText::UNCHANGED || y < refresh_y) {
-               refresh_y = y;
-               refresh_row = tmprow;
-       }
-       status(bview, LyXText::NEED_MORE_REFRESH);
+       postPaint(*bview, y);
        setCursor(bview, cur.par(), cur.pos());
 }
 
@@ -774,12 +773,8 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur,
                }
        }
 
-       // we can set the refreshing parameters now
-       status(bview, LyXText::NEED_MORE_REFRESH);
-       refresh_y = y;
-       refresh_row = tmprow->previous();        /* the real refresh row will
-                                               be deleted, so I store
-                                               the previous here */
+       Row * prevrow = tmprow->previous();
+
        // remove it
        if (tmprow->next())
                tmppar = tmprow->next()->par();
@@ -817,13 +812,12 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur,
        } while (tmppar && tmppar != endpar);
 
        // this is because of layout changes
-       if (refresh_row) {
-               refresh_y -= refresh_row->height();
-               setHeightOfRow(bview, refresh_row);
+       if (prevrow) {
+               setHeightOfRow(bview, prevrow);
+               const_cast<LyXText *>(this)->postPaint(*bview, y - prevrow->height());
        } else {
-               refresh_row = firstrow;
-               refresh_y = 0;
-               setHeightOfRow(bview, refresh_row);
+               setHeightOfRow(bview, firstrow);
+               const_cast<LyXText *>(this)->postPaint(*bview, 0);
        }
 
        if (tmprow && tmprow->next())
@@ -1105,9 +1099,7 @@ void LyXText::setParagraph(BufferView * bview,
 
        while (tmppar != selection.start.par()->previous()) {
                setCursor(bview, tmppar, 0);
-               status(bview, LyXText::NEED_MORE_REFRESH);
-               refresh_row = cursor.row();
-               refresh_y = cursor.y() - cursor.row()->baseline();
+               postPaint(*bview, cursor.y() - cursor.row()->baseline());
                cursor.par()->params().lineTop(line_top);
                cursor.par()->params().lineBottom(line_bottom);
                cursor.par()->params().pagebreakTop(pagebreak_top);
@@ -1646,9 +1638,7 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
                if (z >= row->pos()) {
                        // set the dimensions of the row above
                        y -= row->previous()->height();
-                       refresh_y = y;
-                       refresh_row = row->previous();
-                       status(bview, LyXText::NEED_MORE_REFRESH);
+                       postPaint(*bview, y);
 
                        breakAgain(bview, row->previous());
 
@@ -1663,14 +1653,13 @@ void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
 
        int const tmpheight = row->height();
        pos_type const tmplast = row->lastPos();
-       refresh_y = y;
-       refresh_row = row;
 
        breakAgain(bview, row);
-       if (row->height() == tmpheight && row->lastPos() == tmplast)
-               status(bview, LyXText::NEED_VERY_LITTLE_REFRESH);
-       else
-               status(bview, LyXText::NEED_MORE_REFRESH);
+       if (row->height() == tmpheight && row->lastPos() == tmplast) {
+               postRowPaint(*bview, row, y);
+       } else {
+               postPaint(*bview, y);
+       }
 
        // check the special right address boxes
        if (par->layout()->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
@@ -2337,13 +2326,11 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
                // ok, we will delete anything
                LyXCursor tmpcursor;
 
-               // make sure that you do not delete any environments
-               status(bview, LyXText::NEED_MORE_REFRESH);
                deleted = true;
 
                if (old_cursor.row()->previous()) {
-                       refresh_row = old_cursor.row()->previous();
-                       refresh_y = old_cursor.y() - old_cursor.row()->baseline() - refresh_row->height();
+                       const_cast<LyXText *>(this)->postPaint(*bview, old_cursor.y() - old_cursor.row()->baseline()
+                                 - old_cursor.row()->previous()->height());
                        tmpcursor = cursor;
                        cursor = old_cursor; // that undo can restore the right cursor position
                        Paragraph * endpar = old_cursor.par()->next();
@@ -2373,8 +2360,9 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
                        }
                        setHeightOfRow(bview, refresh_row);
                } else {
-                       refresh_row = old_cursor.row()->next();
-                       refresh_y = old_cursor.y() - old_cursor.row()->baseline();
+                       Row * nextrow = old_cursor.row()->next();
+                       const_cast<LyXText *>(this)->postPaint(*bview,
+                               old_cursor.y() - old_cursor.row()->baseline());
 
                        tmpcursor = cursor;
                        cursor = old_cursor; // that undo can restore the right cursor position
@@ -2400,8 +2388,8 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
                           the parindent that can occur or dissappear.
                           The next row can change its height, if
                           there is another layout before */
-                       if (refresh_row) {
-                               breakAgain(bview, refresh_row);
+                       if (nextrow) {
+                               breakAgain(bview, nextrow);
                                updateCounters(bview);
                        }
                }
@@ -2464,35 +2452,6 @@ LyXText::text_status LyXText::status() const
 }
 
 
-void LyXText::status(BufferView * bview, LyXText::text_status new_status) const
-{
-       // We should not lose information from previous status
-       // sets, or we'll forget to repaint the other bits
-       // covered by the NEED_MORE_REFRESH
-       if (new_status == NEED_VERY_LITTLE_REFRESH
-           && status_ == NEED_MORE_REFRESH)
-               return;
-
-       status_ = new_status;
-
-       if (new_status == UNCHANGED)
-               return;
-
-       if (!inset_owner)
-              return;
-
-       LyXText * t = bview->text;
-
-       // We are an inset's lyxtext. Tell the top-level lyxtext
-       // it needs to update the row we're in.
-       t->status(bview, NEED_VERY_LITTLE_REFRESH);
-       if (!t->refresh_row) {
-               t->refresh_row = t->cursor.row();
-               t->refresh_y = t->cursor.y() - t->cursor.row()->baseline();
-       }
-}
-
-
 void LyXText::clearPaint()
 {
        status_ = UNCHANGED;
@@ -2509,10 +2468,18 @@ void LyXText::postChangedInDraw()
 
 void LyXText::postPaint(BufferView & bv, int start_y)
 {
+       text_status old = status_;
+
        status_ = NEED_MORE_REFRESH;
-       refresh_y = start_y;
        refresh_row = 0;
 
+       if (old != UNCHANGED && refresh_y < start_y) {
+               lyxerr << "Paint already pending from above" << endl;
+               return;
+       }
+
+       refresh_y = start_y;
+
        if (!inset_owner)
                return;
                
@@ -2533,13 +2500,17 @@ void LyXText::postPaint(BufferView & bv, int start_y)
 // make refresh_y be 0, and use row->y etc.
 void LyXText::postRowPaint(BufferView & bv, Row * row, int start_y)
 {
-       // FIXME: shouldn't this check that we're not updating
-       // above the existing refresh_y ??
+       if (status_ != UNCHANGED && refresh_y < start_y) {
+               lyxerr << "Paint already pending from above" << endl;
+               return;
+       } else {
+               refresh_y = start_y;
+       }
+
        if (status_ == NEED_MORE_REFRESH)
                return;
 
        status_ = NEED_VERY_LITTLE_REFRESH;
-       refresh_y = start_y;
        refresh_row = row;
 
        if (!inset_owner)
index 4501d53b116a3e91cb064c639f9b5642393d1859..1f4243789f5cbfdb84ef22f0002871f8f5ccbc72 100644 (file)
@@ -66,7 +66,7 @@ void finishNoUndo(BufferView * bv)
        freezeUndo();
        bv->unlockInset(bv->theLockingInset());
        finishUndo();
-       bv->text->status(bv, LyXText::NEED_MORE_REFRESH);
+       bv->text->postPaint(*bv, 0);
        unFreezeUndo();
 }
 
@@ -266,7 +266,7 @@ bool textHandleUndo(BufferView * bv, Undo & undo)
                }
 
        finishUndo();
-       bv->text->status(bv, LyXText::NEED_MORE_REFRESH);
+       bv->text->postPaint(*bv, 0);
        return true;
 }