cleanups and cosmetics.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21612 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-11-14 17:39:16 +00:00
parent 240e59ae0d
commit b716616322
2 changed files with 26 additions and 49 deletions

View File

@ -328,7 +328,8 @@ void GuiWorkArea::redraw()
int const ymin = std::max(vi.y1, 0); int const ymin = std::max(vi.y1, 0);
int const ymax = vi.p2 < vi.size - 1 ? vi.y2 : viewport()->height(); 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) //LYXERR(Debug::WORKAREA)
//<< " ymin = " << ymin << " width() = " << width() //<< " 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() void GuiWorkArea::showCursor()
{ {
if (cursor_visible_) 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) if (verticalScrollBarPolicy() != Qt::ScrollBarAlwaysOn)
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
verticalScrollBar()->setTracking(false); verticalScrollBar()->setTracking(false);
buffer_view_->updateScrollbar();
ScrollbarParameters const & scroll_ = buffer_view_->scrollbarParameters();
// do what cursor movement does (some grey) // 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()); int scroll_max_ = std::max(0, h - viewport()->height());
verticalScrollBar()->setRange(0, scroll_max_); verticalScrollBar()->setRange(0, scroll_max_);
verticalScrollBar()->setSliderPosition(scroll_pos); verticalScrollBar()->setSliderPosition(scroll_.position);
verticalScrollBar()->setSingleStep(scroll_line_step); verticalScrollBar()->setSingleStep(scroll_.lineScrollHeight);
verticalScrollBar()->setValue(scroll_pos); verticalScrollBar()->setValue(scroll_.position);
verticalScrollBar()->setTracking(true); 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() void GuiWorkArea::updateScreen()
{ {
GuiPainter pain(&screen_); GuiPainter pain(&screen_);

View File

@ -110,27 +110,8 @@ public:
/// ///
~GuiWorkArea(); ~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; } 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(); BufferView & bufferView();
/// ///
@ -145,7 +126,11 @@ public:
/// This needs to be public because it is accessed externally by GuiView. /// This needs to be public because it is accessed externally by GuiView.
void processKeySym(KeySymbol const & key, KeyModifier mod); 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. /// Adjust the LyX buffer view with the position of the scrollbar.
/** /**
* The action argument is not used in the the code, it is there * 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. /// Slot for Buffer::closing signal.
void close(); void close();
Q_SIGNALS:
///
void titleChanged(GuiWorkArea *);
private: private:
/// update the passed area.
void update(int x, int y, int w, int h);
///
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();
/// This function is called when the buffer readonly status change. /// This function is called when the buffer readonly status change.
void setReadOnly(bool); void setReadOnly(bool);
@ -227,8 +219,6 @@ private:
/// ///
CursorWidget * cursor_; CursorWidget * cursor_;
/// ///
void updateScreen();
///
QPixmap screen_; QPixmap screen_;
/// ///
bool need_resize_; bool need_resize_;