From b716616322a1e75654c5b822dcae7d179372ac0e Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 14 Nov 2007 17:39:16 +0000 Subject: [PATCH] cleanups and cosmetics. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21612 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiWorkArea.cpp | 33 ++++++++----------------- src/frontends/qt4/GuiWorkArea.h | 40 ++++++++++++------------------- 2 files changed, 25 insertions(+), 48 deletions(-) diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index b44553e55a..19e7661952 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -328,7 +328,8 @@ void GuiWorkArea::redraw() int const ymin = std::max(vi.y1, 0); int const ymax = vi.p2 < vi.size - 1 ? vi.y2 : viewport()->height(); - expose(0, ymin, viewport()->width(), ymax - ymin); + updateScreen(); + update(0, ymin, viewport()->width(), ymax - ymin); //LYXERR(Debug::WORKAREA) //<< " ymin = " << ymin << " width() = " << width() @@ -412,15 +413,6 @@ void GuiWorkArea::resizeBufferView() } -void GuiWorkArea::updateScrollbar() -{ - buffer_view_->updateScrollbar(); - ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters(); - setScrollbarParams(scroll_.height, scroll_.position, - scroll_.lineScrollHeight); -} - - void GuiWorkArea::showCursor() { if (cursor_visible_) @@ -489,21 +481,23 @@ void GuiWorkArea::toggleCursor() } -void GuiWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step) +void GuiWorkArea::updateScrollbar() { if (verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOn) setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - verticalScrollBar()->setTracking(false); + buffer_view_->updateScrollbar(); + ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters(); + // do what cursor movement does (some grey) - h += viewport()->height() / 4; + int const h = scroll_.height + viewport()->height() / 4; int scroll_max_ = std::max(0, h - viewport()->height()); verticalScrollBar()->setRange(0, scroll_max_); - verticalScrollBar()->setSliderPosition(scroll_pos); - verticalScrollBar()->setSingleStep(scroll_line_step); - verticalScrollBar()->setValue(scroll_pos); + verticalScrollBar()->setSliderPosition(scroll_.position); + verticalScrollBar()->setSingleStep(scroll_.lineScrollHeight); + verticalScrollBar()->setValue(scroll_.position); verticalScrollBar()->setTracking(true); } @@ -754,13 +748,6 @@ void GuiWorkArea::paintEvent(QPaintEvent * ev) } -void GuiWorkArea::expose(int x, int y, int w, int h) -{ - updateScreen(); - update(x, y, w, h); -} - - void GuiWorkArea::updateScreen() { GuiPainter pain(&screen_); diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h index 3b6e560551..0da23ceff3 100644 --- a/src/frontends/qt4/GuiWorkArea.h +++ b/src/frontends/qt4/GuiWorkArea.h @@ -110,27 +110,8 @@ public: /// ~GuiWorkArea(); - /** - * Update the scrollbar. - * @param height the total document height in pixels - * @param pos the current position in the document, in pixels - * @param line_height the line-scroll amount, in pixels - */ - void setScrollbarParams(int height, int pos, int line_height); /// void scheduleRedraw() { schedule_redraw_ = true; } - - /// update the passed area. - void update(int x, int y, int w, int h); - - /// copies specified area of pixmap to screen - virtual void expose(int x, int y, int exp_width, int exp_height); - - /// paint the cursor and store the background - virtual void showCursor(int x, int y, int h, CursorShape shape); - - /// hide the cursor - virtual void removeCursor(); /// BufferView & bufferView(); /// @@ -145,7 +126,11 @@ public: /// This needs to be public because it is accessed externally by GuiView. void processKeySym(KeySymbol const & key, KeyModifier mod); -public Q_SLOTS: +Q_SIGNALS: + /// + void titleChanged(GuiWorkArea *); + +private Q_SLOTS: /// Adjust the LyX buffer view with the position of the scrollbar. /** * The action argument is not used in the the code, it is there @@ -160,11 +145,18 @@ public Q_SLOTS: /// Slot for Buffer::closing signal. void close(); -Q_SIGNALS: +private: + /// update the passed area. + void update(int x, int y, int w, int h); /// - void titleChanged(GuiWorkArea *); + void updateScreen(); + + /// paint the cursor and store the background + virtual void showCursor(int x, int y, int h, CursorShape shape); + + /// hide the cursor + virtual void removeCursor(); -private: /// This function is called when the buffer readonly status change. void setReadOnly(bool); @@ -227,8 +219,6 @@ private: /// CursorWidget * cursor_; /// - void updateScreen(); - /// QPixmap screen_; /// bool need_resize_; -- 2.39.2