From 1cadf458e39eed9570f13ebe0a1223a4fe7c282b Mon Sep 17 00:00:00 2001 From: John Levon Date: Fri, 21 Jun 2002 02:22:13 +0000 Subject: [PATCH] redraw() cleanup git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4450 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 4 +-- src/BufferView.h | 8 +++-- src/BufferView_pimpl.C | 39 ++++++---------------- src/BufferView_pimpl.h | 9 ++--- src/ChangeLog | 14 ++++++++ src/buffer.C | 6 ++-- src/converter.C | 6 ++-- src/exporter.C | 3 +- src/frontends/ChangeLog | 4 +++ src/frontends/WorkArea.h | 3 -- src/frontends/controllers/ChangeLog | 5 +++ src/frontends/controllers/ControlBibitem.C | 4 ++- src/frontends/controllers/ControlBibtex.C | 3 +- src/frontends/screen.C | 2 ++ src/frontends/screen.h | 4 +-- src/frontends/xforms/XWorkArea.h | 4 +-- src/frontends/xforms/xscreen.C | 12 +++---- src/frontends/xforms/xscreen.h | 2 +- src/lyxfunc.C | 5 +-- src/mathed/ChangeLog | 4 +++ src/mathed/formula.C | 4 ++- 21 files changed, 84 insertions(+), 61 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index 170a348c65..d9d6e37774 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -71,9 +71,9 @@ void BufferView::resize() } -void BufferView::redraw() +void BufferView::repaint() { - pimpl_->redraw(); + pimpl_->repaint(); } diff --git a/src/BufferView.h b/src/BufferView.h index 9168849a68..0c91f1c380 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -59,8 +59,12 @@ public: void buffer(Buffer * b); /// void resize(); - /// - void redraw(); + /** + * Repaint the pixmap. Used for when we don't want + * to go through the full update() logic, just a simple + * repaint of the whole screen. + */ + void repaint(); /// bool fitCursor(); /// diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index cd2b197a73..c159a7266c 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -207,28 +207,22 @@ void BufferView::Pimpl::buffer(Buffer * b) if (buffer_) { lyxerr[Debug::INFO] << "Buffer addr: " << buffer_ << endl; buffer_->addUser(bv_); + // If we don't have a text object for this, we make one if (bv_->text == 0) { resizeCurrentBuffer(); - } else { - updateScreen(); - updateScrollbar(); } + + // FIXME: needed when ? bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y); - owner_->updateMenubar(); - owner_->updateToolbar(); + // Similarly, buffer-dependent dialogs should be updated or // hidden. This should go here because some dialogs (eg ToC) // require bv_->text. owner_->getDialogs()->updateBufferDependent(true); - redraw(); } else { lyxerr[Debug::INFO] << " No Buffer!" << endl; - owner_->updateMenubar(); - owner_->updateToolbar(); owner_->getDialogs()->hideBufferDependent(); - updateScrollbar(); - workarea().redraw(); // Also remove all remaining text's from the testcache. // (there should not be any!) (if there is any it is a @@ -237,20 +231,16 @@ void BufferView::Pimpl::buffer(Buffer * b) textcache.show(lyxerr, "buffer delete all"); textcache.clear(); } - // should update layoutchoice even if we don't have a buffer. + + repaint(); + updateScrollbar(); + owner_->updateMenubar(); + owner_->updateToolbar(); owner_->updateLayoutChoice(); - owner_->updateWindowTitle(); } -void BufferView::Pimpl::redraw() -{ - lyxerr[Debug::INFO] << "BufferView::redraw()" << endl; - workarea().redraw(); -} - - bool BufferView::Pimpl::fitCursor() { bool ret; @@ -356,10 +346,6 @@ int BufferView::Pimpl::resizeCurrentBuffer() bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y); - // this will scroll the screen such that the cursor becomes visible - updateScrollbar(); - redraw(); - setState(); owner_->allowInput(); @@ -370,7 +356,7 @@ int BufferView::Pimpl::resizeCurrentBuffer() } -void BufferView::Pimpl::updateScreen() +void BufferView::Pimpl::repaint() { // Regenerate the screen. screen().redraw(bv_->text, bv_); @@ -910,6 +896,7 @@ void BufferView::Pimpl::workAreaResize() // update from work area work_area_width = workarea().workWidth(); work_area_height = workarea().workHeight(); + if (buffer_ != 0) { if (widthChange) { // The visible LyXView need a resize @@ -931,9 +918,6 @@ void BufferView::Pimpl::workAreaResize() // to the start of the document on vertical // resize fitCursor(); - - // The main window size has changed, repaint most stuff - redraw(); } else { screen().redraw(bv_->text, bv_); } @@ -1312,7 +1296,6 @@ void BufferView::Pimpl::center() screen().draw(bv_->text, bv_, 0); } update(bv_->text, BufferView::SELECT|BufferView::FITCUR); - redraw(); } diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 79af7c390f..05a390b28f 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -44,8 +44,6 @@ struct BufferView::Pimpl : public boost::signals::trackable { LyXScreen & screen() const; /// void buffer(Buffer *); - /// - void redraw(); /// Return true if the cursor was fitted. bool fitCursor(); /// @@ -56,8 +54,11 @@ struct BufferView::Pimpl : public boost::signals::trackable { void update(); // void update(LyXText *, BufferView::UpdateCodes); - /// Update pixmap of screen - void updateScreen(); + /** + * Repaint pixmap. Used for when we've made a visible + * change but don't need the full update() logic + */ + void repaint(); /// void workAreaResize(); /// diff --git a/src/ChangeLog b/src/ChangeLog index f31fddc817..761540b018 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2002-06-21 John Levon + + * buffer.C: + * converter.C: + * exporter.C: + * lyxfunc.C: + * BufferView.h: + * BufferView.C: use repaint() + + * BufferView_pimpl.h: + * BufferView_pimpl.C: s/updateScreen()/repaint()/ + as it's a clearer description. Remove superfluous + redraws. + 2002-06-21 John Levon * text.C: fix bug 488. Not ideal, but getting diff --git a/src/buffer.C b/src/buffer.C index ef5cf08538..2c9812fae4 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -3634,7 +3634,8 @@ int Buffer::runChktex() // if we removed error insets before we ran chktex or if we inserted // error insets after we ran chktex, this must be run: if (removedErrorInsets || res) { - users->redraw(); +#warning repaint needed here, or do you mean update() ? + users->repaint(); users->fitCursor(); } users->owner()->allowInput(); @@ -3921,7 +3922,8 @@ void Buffer::resizeInsets(BufferView * bv) void Buffer::redraw() { - users->redraw(); +#warning repaint needed here, or do you mean update() ? + users->repaint(); users->fitCursor(); } diff --git a/src/converter.C b/src/converter.C index 0881b06d21..f91c85f607 100644 --- a/src/converter.C +++ b/src/converter.C @@ -796,7 +796,8 @@ bool Converters::scanLog(Buffer const * buffer, string const & command, if ((result & LaTeX::ERRORS)) { // Insert all errors as errors boxes bv->insertErrors(terr); - bv->redraw(); +#warning repaint() or update() or nothing ? + bv->repaint(); bv->fitCursor(); } bv->owner()->allowInput(); @@ -853,7 +854,8 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command) if ((result & LaTeX::ERRORS)) { // Insert all errors as errors boxes bv->insertErrors(terr); - bv->redraw(); +#warning repaint() or update() or nothing ? + bv->repaint(); bv->fitCursor(); } } diff --git a/src/exporter.C b/src/exporter.C index 7d9c2b3f09..898d6301a9 100644 --- a/src/exporter.C +++ b/src/exporter.C @@ -39,7 +39,8 @@ bool Exporter::Export(Buffer * buffer, string const & format, if (bv) { // Remove all error insets if (bv->removeAutoInsets()) { - bv->redraw(); +#warning repaint() or update() or nothing ? + bv->repaint(); bv->fitCursor(); } } diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 5ca86d3dd7..0e79b700f0 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,7 @@ +2002-06-21 John Levon + + * WorkArea.h: remove redraw() + 2002-06-20 John Levon * guiapi.h: diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h index 0c7a78b9d0..28f3d35ad4 100644 --- a/src/frontends/WorkArea.h +++ b/src/frontends/WorkArea.h @@ -46,9 +46,6 @@ public: /// return the height of the work area in pixels virtual int workHeight() const = 0; - /// FIXME: GUII - virtual void redraw() const = 0; - /** * Update the scrollbar. * @param height the total document height in pixels diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 3d6c71e35d..d6d2ff8e51 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,8 @@ +2002-06-21 John Levon + + * ControlBibtex.C: + * ControlBibitem.C: use repaint() + 2002-06-21 John Levon * ControlTexinfo.C: do the same for Texinfo diff --git a/src/frontends/controllers/ControlBibitem.C b/src/frontends/controllers/ControlBibitem.C index 288bfff455..6a21aa0abb 100644 --- a/src/frontends/controllers/ControlBibitem.C +++ b/src/frontends/controllers/ControlBibitem.C @@ -40,6 +40,8 @@ void ControlBibitem::applyParamsToInset() // We need to do a redraw because the maximum // InsetBibKey width could have changed - lv_.view()->redraw(); +#warning please check you mean repaint() not update(), +#warning and whether the repaint() is needed at all + lv_.view()->repaint(); lv_.view()->fitCursor(); } diff --git a/src/frontends/controllers/ControlBibtex.C b/src/frontends/controllers/ControlBibtex.C index d089ada704..9f8df298d6 100644 --- a/src/frontends/controllers/ControlBibtex.C +++ b/src/frontends/controllers/ControlBibtex.C @@ -49,7 +49,8 @@ void ControlBibtex::applyParamsToInset() // We need to do a redraw because the maximum // InsetBibKey width could have changed - lv_.view()->redraw(); +#warning are you sure you need this repaint() ? + lv_.view()->repaint(); lv_.view()->fitCursor(); } diff --git a/src/frontends/screen.C b/src/frontends/screen.C index 8c72d54018..3322d112f5 100644 --- a/src/frontends/screen.C +++ b/src/frontends/screen.C @@ -303,6 +303,8 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv, int y1, int y2, int yo, int xo, bool internal) { + lyxerr[Debug::GUI] << "screen: drawFromTo " << y1 << "-" << y2 << endl; + int y_text = text->first_y + y1; // get the first needed row diff --git a/src/frontends/screen.h b/src/frontends/screen.h index 47f092d8e5..bfa7e82e82 100644 --- a/src/frontends/screen.h +++ b/src/frontends/screen.h @@ -144,8 +144,8 @@ public: virtual bool forceClear() const { return force_clear_; } protected: - /// copies specified area of pixmap to screen - virtual void expose(int x, int y, int exp_width, int exp_height) = 0; + /// cause the display of the given area of the work area + virtual void expose(int x, int y, int w, int h) = 0; /// get the work area virtual WorkArea & workarea() const = 0; diff --git a/src/frontends/xforms/XWorkArea.h b/src/frontends/xforms/XWorkArea.h index ddbe34b6af..1c1835de9e 100644 --- a/src/frontends/xforms/XWorkArea.h +++ b/src/frontends/xforms/XWorkArea.h @@ -35,8 +35,8 @@ public: virtual int workHeight() const { return work_area->h; } /// virtual void redraw() const { - fl_redraw_object(work_area); - fl_redraw_object(scrollbar); + //fl_redraw_object(work_area); + //fl_redraw_object(scrollbar); } /// Window getWin() const { return work_area->form->window; } diff --git a/src/frontends/xforms/xscreen.C b/src/frontends/xforms/xscreen.C index 715b0f3d4a..2025de8d1c 100644 --- a/src/frontends/xforms/xscreen.C +++ b/src/frontends/xforms/xscreen.C @@ -29,6 +29,7 @@ #include "insets/insettext.h" #include "ColorHandler.h" #include "language.h" +#include "debug.h" using std::max; using std::min; @@ -185,18 +186,15 @@ void XScreen::hideCursor() } -void XScreen::expose(int x, int y, int exp_width, int exp_height) +void XScreen::expose(int x, int y, int w, int h) { - // FIXME: here we should definitely NOT do this. - // we need to generate an expose event for the workarea - // and then copy from the pixmap to the screen. This - // is the Sane Way (tm) + lyxerr[Debug::GUI] << "expose " << w << "x" << h + << "+" << x << "+" << y << endl; XCopyArea(fl_get_display(), owner_.getPixmap(), owner_.getWin(), gc_copy, - x, y, - exp_width, exp_height, + x, y, w, h, x + owner_.xpos(), y + owner_.ypos()); } diff --git a/src/frontends/xforms/xscreen.h b/src/frontends/xforms/xscreen.h index 2fad257118..1fc39adc26 100644 --- a/src/frontends/xforms/xscreen.h +++ b/src/frontends/xforms/xscreen.h @@ -52,7 +52,7 @@ protected: virtual WorkArea & workarea() const { return owner_; } /// Copies specified area of pixmap to screen - virtual void expose(int x, int y, int exp_width, int exp_height); + virtual void expose(int x, int y, int w, int h); private: /// our owning widget diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 832aa76e44..fe5c9056a3 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1197,7 +1197,8 @@ string const LyXFunc::dispatch(kb_action action, string argument) case LFUN_REMOVEERRORS: if (owner->view()->removeAutoInsets()) { - owner->view()->redraw(); +#warning repaint() or update() or nothing ? + owner->view()->repaint(); owner->view()->fitCursor(); } break; @@ -1634,7 +1635,7 @@ string const LyXFunc::dispatch(kb_action action, string argument) gc.changeDisplay(true); } - owner->view()->redraw(); + owner->view()->repaint(); break; } diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index d807a7c2dd..85c7ddd3eb 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,7 @@ +2002-06-21 John Levon + + * formula.C: use repaint() + 2002-06-16 André Pönitz * math_factory.C: diff --git a/src/mathed/formula.C b/src/mathed/formula.C index c87271376f..12dc32de3b 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -278,8 +278,10 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action, hull()->numbered(row, true); } +#warning FIXME: please check you really mean repaint() ... is it needed, +#warning and if so, should it be update() instead ? if (!new_label.empty() && bv->ChangeRefsIfUnique(old_label, new_label)) - bv->redraw(); + bv->repaint(); hull()->label(row, new_label);