From be865e22f25a96736a27bed7cbb6f853f7d51fc6 Mon Sep 17 00:00:00 2001 From: John Levon Date: Thu, 12 Sep 2002 16:02:28 +0000 Subject: [PATCH] add some extra smarts about when to paint immediately. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5291 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 5 +++++ src/frontends/qt2/qscreen.C | 25 +++++++++++++++---------- src/frontends/qt2/qscreen.h | 3 +++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 798c15a65d..4991e6f937 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2002-09-12 John Levon + + * qscreen.h: + * qscreen.C: be even smarter about repaint() vs. update() + 2002-09-12 John Levon * QPrint.C: don't reset unless different buffer diff --git a/src/frontends/qt2/qscreen.C b/src/frontends/qt2/qscreen.C index 25ca534ea1..78fe7d1143 100644 --- a/src/frontends/qt2/qscreen.C +++ b/src/frontends/qt2/qscreen.C @@ -146,17 +146,19 @@ void QScreen::hideCursor() } +void QScreen::repaint() +{ + QWidget * content(owner_.getContent()); + content->repaint(0, 0, content->width(), content->height()); +} + + void QScreen::expose(int x, int y, int w, int h) { lyxerr[Debug::GUI] << "expose " << w << "x" << h << "+" << x << "+" << y << endl; - // if we're scrolling, we want immediate paint, otherwise not. - QWidget * content(owner_.getContent()); - if (content->width() == w && content->height() == h) - content->repaint(x, y, w, h); - else - content->update(x, y, w, h); + owner_.getContent()->update(x, y, w, h); } @@ -172,9 +174,12 @@ void QScreen::draw(LyXText * text, BufferView * bv, unsigned int y) bool const internal = (text == bv->text); text->first_y = y; + // If you want to fix the warning below, fix it so it + // actually scrolls properly. Hint: a cast won't do. + // is any optimization possible? - if ((y - old_first) < owner_.workHeight() - && (old_first - y) < owner_.workHeight()) { + if (y - old_first < owner_.workHeight() + && old_first - y < owner_.workHeight()) { if (text->first_y < old_first) { int const dest_y = old_first - text->first_y; drawFromTo(text, bv, 0, dest_y, 0, 0, internal); @@ -187,9 +192,9 @@ void QScreen::draw(LyXText * text, BufferView * bv, unsigned int y) expose(0, owner_.height() - src_y, owner_.workWidth(), src_y); } } else { - // make a dumb redraw + lyxerr[Debug::GUI] << "dumb full redraw" << endl; drawFromTo(text, bv, 0, owner_.height(), 0, 0, internal); - expose(0, 0, owner_.workWidth(), owner_.height()); + repaint(); } owner_.getPainter().end(); diff --git a/src/frontends/qt2/qscreen.h b/src/frontends/qt2/qscreen.h index 7c2e317e98..6e3cc48453 100644 --- a/src/frontends/qt2/qscreen.h +++ b/src/frontends/qt2/qscreen.h @@ -58,6 +58,9 @@ protected: /// get the work area virtual WorkArea & workarea() const { return owner_; } + /// repaint the whole content immediately + void repaint(); + /// copies specified area of pixmap to screen virtual void expose(int x, int y, int exp_width, int exp_height);