This is a proposal for the new scrollbar code, as discussed in the list. qt
and xforms seem to work, gtk compiles (doesn't work ok but I hope should be
easy to fix)

This patch does quite a lot of things, and I'm sure is still rough around
the edges, but IMO is what needs to be done to have a decent scrollbar
again. There is a couple of things that can be commited separately (once
tested):

- there is some polishing of BufferView::Pimpl::metrics to compute stricter
top and bottom paragraphs to be drawn: this may give a small speed
improvement in update (not so much because out-of screen paragraphs are
drawn with nullpainter anyway), and also makes scrollbar computations a bit
easier.

- there is a bv::update() call replaced by update(false, true) to avoid
fitting the cursor when an image has finished loading.

Main changes are:

Simplified signature of WorkArea::setScrollBarParam, now takes two doubles
(position and height, both in [0,1]). Frontends work internally with
integer values as always.

An implementation of the WorkArea class, which is no more pure virtual. This
is to allow to introduce a couple of hooks before scrollDocView and
updateScrollbarParameters calls. In particular makes doSetScrollbarParams
to follow the NVI thing. Added 4 more signals: scroll{Page,Line}{Up,Down}.

Reworking of BufferView::Pimpl::updateScrollbar.

Lots of testing needed...

Regards, Alfredo
? frontends/WorkArea.C
Index: BufferView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.C,v
retrieving revision 1.260
diff -u -p -u -r1.260 BufferView.C
--- BufferView.C	22 Feb 2005 11:41:19 -0000	1.260
+++ BufferView.C	30 Mar 2005 13:56:49 -0000
@@ -148,12 +148,6 @@ void BufferView::update(bool fitcursor, 
 }
 
 
-void BufferView::updateScrollbar()
-{
-	pimpl_->updateScrollbar();
-}
-
-
 void BufferView::scrollDocView(int value)
 {
 	pimpl_->scrollDocView(value);
Index: BufferView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView.h,v
retrieving revision 1.185
diff -u -p -u -r1.185 BufferView.h
--- BufferView.h	22 Feb 2005 11:41:19 -0000	1.185
+++ BufferView.h	30 Mar 2005 13:56:49 -0000
@@ -85,8 +85,6 @@ public:
 	/// move the screen to fit the cursor. Only to be called with
 	/// good y coordinates (after a bv::metrics)
 	bool fitCursor();
-	/// reset the scrollbar to reflect current view position
-	void updateScrollbar();
 
 	/// FIXME
 	bool available() const;
Index: BufferView_pimpl.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.580
diff -u -p -u -r1.580 BufferView_pimpl.C
--- BufferView_pimpl.C	25 Feb 2005 11:55:29 -0000	1.580
+++ BufferView_pimpl.C	30 Mar 2005 13:56:50 -0000
@@ -100,7 +100,6 @@ using std::string;
 using std::mem_fun_ref;
 using std::vector;
 
-
 extern BufferList bufferlist;
 
 
@@ -113,6 +112,10 @@ unsigned int const saved_positions_num =
 // to these connections we avoid a segfault upon startup, and also at exit.
 // (Lgb)
 
+boost::signals::connection pagedowncon;
+boost::signals::connection pageupcon;
+boost::signals::connection lineupcon;
+boost::signals::connection linedowncon;
 boost::signals::connection dispatchcon;
 boost::signals::connection timecon;
 boost::signals::connection doccon;
@@ -152,6 +155,15 @@ BufferView::Pimpl::Pimpl(BufferView & bv
 	// Setup the signals
 	doccon = workarea().scrollDocView
 		.connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
+	pageupcon = workarea().scrollPageUp
+		.connect(boost::bind(&BufferView::Pimpl::scrollPageUp, this));
+
+	pagedowncon = workarea().scrollPageDown
+		.connect(boost::bind(&BufferView::Pimpl::scrollPageDown, this));
+	lineupcon = workarea().scrollLineUp
+		.connect(boost::bind(&BufferView::Pimpl::scrollLineUp, this));
+	linedowncon = workarea().scrollLineDown
+		.connect(boost::bind(&BufferView::Pimpl::scrollLineDown, this));
 	resizecon = workarea().workAreaResize
 		.connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
 	dispatchcon = workarea().dispatch
@@ -365,7 +377,6 @@ void BufferView::Pimpl::setBuffer(Buffer
 	}
 
 	update();
-	updateScrollbar();
 	owner_->updateMenubar();
 	owner_->updateToolbars();
 	owner_->updateLayoutChoice();
@@ -399,16 +410,15 @@ void BufferView::Pimpl::resizeCurrentBuf
 	// Reset the "Formatting..." message
 	owner_->clearMessage();
 
-	updateScrollbar();
 }
 
 
-void BufferView::Pimpl::updateScrollbar()
+void BufferView::Pimpl::updateScrollbar(ViewMetricsInfo const & vi)
 {
 	if (!bv_->text()) {
 		lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
 				     << " no text in updateScrollbar" << endl;
-		workarea().setScrollbarParams(0, 0, 0);
+		workarea().setScrollbarParams(0, 0);
 		return;
 	}
 
@@ -424,35 +434,71 @@ void BufferView::Pimpl::updateScrollbar(
 		<< " curr par: " << cursor_.bottom().pit()
 		<< " default height " << defaultRowHeight() << endl;
 
-	// It would be better to fix the scrollbar to understand
-	// values in [0..1] and divide everything by wh
-	int const wh = workarea().workHeight() / 4;
-	int const h = t.getPar(anchor_ref_).height();
-	workarea().setScrollbarParams(t.paragraphs().size() * wh, anchor_ref_ * wh + int(offset_ref_ * wh / float(h)), int (wh * defaultRowHeight() / float(h)));
-//	workarea().setScrollbarParams(t.paragraphs().size(), anchor_ref_, 1);
+	int const h1 = t.getPar(vi.p1).height();
+	int const h2 = t.getPar(vi.p2).height();
+	double const chop1 = (- vi.y1) / double(h1);
+	double const chop2 = (vi.y2 - workarea().workHeight()) / double(h2);
+	double const tot = t.paragraphs().size();
+	double const pos = (vi.p1 + chop1) / tot;
+	double const size = (vi.p2 - vi.p1 + 1 - chop1 - chop2) / tot;
+	lyxerr << vi.p1 << ' ' << vi.p2 << ' ' << chop1 << ' ' << chop2 << ' ' << tot << ' ' << pos << ' ' << size << endl;
+	if (vi.p1 == vi.p2) {
+		BOOST_ASSERT(chop1 + chop2 <= 1);
+	}
+	BOOST_ASSERT(size > 0);
+	
+
+	
+	workarea().setScrollbarParams(size, pos);
+}
+
+
+void BufferView::Pimpl::scrollLineUp()
+{
+	offset_ref_ -= defaultRowHeight();
+	update();
 }
 
 
-void BufferView::Pimpl::scrollDocView(int value)
+void BufferView::Pimpl::scrollLineDown()
+{
+	offset_ref_ += defaultRowHeight();
+	update();
+}
+
+
+void BufferView::Pimpl::scrollPageUp()
+{
+	offset_ref_ -= workarea().workHeight();
+	update();
+}
+
+
+void BufferView::Pimpl::scrollPageDown()
+{
+	offset_ref_ += workarea().workHeight();
+	update();
+}
+
+
+void BufferView::Pimpl::scrollDocView(double bar)
 {
 	lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
-			   << "[ value = " << value << "]" << endl;
+			   << "[ value = " << bar << "]" << endl;
 
 	if (!buffer_)
 		return;
 
 	screen().hideCursor();
 
-	int const wh = workarea().workHeight() / 4;
-
 	LyXText & t = *bv_->text();
 
-	float const bar = value / float(wh * t.paragraphs().size());
-
-	anchor_ref_ = int(bar * t.paragraphs().size());
+	int tot = t.paragraphs().size();
+	
+	anchor_ref_ = min(tot - 1, int(bar * tot));
 	t.redoParagraph(anchor_ref_);
 	int const h = t.getPar(anchor_ref_).height();
-	offset_ref_ = int((bar * t.paragraphs().size() - anchor_ref_) * h);
+	offset_ref_ = int(( bar * tot - anchor_ref_) * h);
 	update();
 
 	if (!lyxrc.cursor_follows_scrollbar)
@@ -586,7 +632,6 @@ void BufferView::Pimpl::workAreaResize()
 		update();
 
 	// Always make sure that the scrollbar is sane.
-	updateScrollbar();
 	owner_->updateLayoutChoice();
 }
 
@@ -606,6 +651,7 @@ bool BufferView::Pimpl::fitCursor()
 }
 
 
+
 void BufferView::Pimpl::update(bool fitcursor, bool forceupdate)
 {
 	lyxerr << BOOST_CURRENT_FUNCTION
@@ -613,6 +659,7 @@ void BufferView::Pimpl::update(bool fitc
 	       << " forceupdate = " << forceupdate
 	       << "]  buffer: " << buffer_ << endl;
 
+	
 	// Check needed to survive LyX startup
 	if (buffer_) {
 		// Update macro store
@@ -636,11 +683,14 @@ void BufferView::Pimpl::update(bool fitc
 			// Abort updating of the coord cache - just restore the old one
 			std::swap(theCoords, backup);
 		}
-	} else
+		// And the scrollbar
+		updateScrollbar(vi);
+	} else {
 		screen().greyOut();
+		updateScrollbar(ViewMetricsInfo(0,0,0,0));
+	}
+	
 
-	// And the scrollbar
-	updateScrollbar();
 	owner_->view_state_changed();
 }
 
@@ -1244,6 +1294,8 @@ ViewMetricsInfo BufferView::Pimpl::metri
 	theCoords.clear();
 	BufferView & bv = *bv_;
 	LyXText * const text = bv.text();
+	int const wh =  workarea().workHeight();
+
 	if (anchor_ref_ > int(text->paragraphs().size() - 1)) {
 		anchor_ref_ = int(text->paragraphs().size() - 1);
 		offset_ref_ = 0;
@@ -1255,31 +1307,24 @@ ViewMetricsInfo BufferView::Pimpl::metri
 	size_t const npit = text->paragraphs().size();
 
 	lyxerr << BOOST_CURRENT_FUNCTION
-	       << " npit: " << npit
-	       << " pit1: " << pit1
-	       << " pit2: " << pit2
-	       << endl;
+	       << " anchor: " << pit2 << " offset: " << offset_ref_ << endl;
 
 	// Rebreak anchor par
 	text->redoParagraph(pit);
-	int y0 = text->getPar(pit1).ascent() - offset_ref_;
+	int y0 = int(text->getPar(pit1).ascent()) - offset_ref_;
 
-	// Redo paragraphs above cursor if necessary
+	// Redo paragraphs above anchor if necessary
 	int y1 = y0;
 	while (y1 > 0 && pit1 > 0) {
-		y1 -= text->getPar(pit1).ascent();
+		y1 -= int(text->getPar(pit1).ascent());
 		--pit1;
 		text->redoParagraph(pit1);
-		y1 -= text->getPar(pit1).descent();
+		y1 -= int(text->getPar(pit1).descent());
 	}
 
 
 	// Take care of ascent of first line
-	y1 -= text->getPar(pit1).ascent();
-
-	// Normalize anchor for next time
-	anchor_ref_ = pit1;
-	offset_ref_ = -y1;
+	y1 -= int(text->getPar(pit1).ascent());
 
 	// Grey at the beginning is ugly
 	if (pit1 == 0 && y1 > 0) {
@@ -1288,9 +1333,9 @@ ViewMetricsInfo BufferView::Pimpl::metri
 		anchor_ref_ = 0;
 	}
 
-	// Redo paragraphs below cursor if necessary
+	// Redo paragraphs below anchor if necessary
 	int y2 = y0;
-	while (y2 < bv.workHeight() && pit2 < int(npit) - 1) {
+	while (y2 < wh && pit2 < int(npit) - 1) {
 		y2 += text->getPar(pit2).descent();
 		++pit2;
 		text->redoParagraph(pit2);
@@ -1301,8 +1346,24 @@ ViewMetricsInfo BufferView::Pimpl::metri
 	y2 += text->getPar(pit2).descent();
 
 	// The coordinates of all these paragraphs are correct, cache them
+	// also adjust pit1 and pit2 more strictly
 	int y = y1;
 	for (lyx::pit_type pit = pit1; pit <= pit2; ++pit) {
+
+		int const h = text->getPar(pit).height();
+		if (y < 0 && y + h >= 0) {
+			// Normalize anchor for next time
+			anchor_ref_ = pit;
+			offset_ref_ = -y;
+			pit1 = pit;
+			y1 = y;
+
+		}
+		if (y <= wh && y + h > wh) {
+			pit2 = pit;
+			y2 = y + h;
+		}
+
 		y += text->getPar(pit).ascent();
 		theCoords.parPos()[text][pit] = Point(0, y);
 		y += text->getPar(pit).descent();
Index: BufferView_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.h,v
retrieving revision 1.127
diff -u -p -u -r1.127 BufferView_pimpl.h
--- BufferView_pimpl.h	19 Jan 2005 15:03:26 -0000	1.127
+++ BufferView_pimpl.h	30 Mar 2005 13:56:50 -0000
@@ -68,9 +68,17 @@ public:
 	///
 	void workAreaResize();
 	///
-	void updateScrollbar();
+	void updateScrollbar(ViewMetricsInfo const &);
 	///
-	void scrollDocView(int value);
+	void scrollDocView(double value);
+	///
+	void scrollLineUp();
+	///
+	void scrollLineDown();
+	///
+	void scrollPageUp();
+	///
+	void scrollPageDown();
 	/// Wheel mouse scroll, move by multiples of text->defaultRowHeight().
 	void scroll(int lines);
 	///
Index: lyxfunc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v
retrieving revision 1.649
diff -u -p -u -r1.649 lyxfunc.C
--- lyxfunc.C	7 Mar 2005 11:03:44 -0000	1.649
+++ lyxfunc.C	30 Mar 2005 13:56:51 -0000
@@ -1077,8 +1077,6 @@ void LyXFunc::dispatch(FuncRequest const
 			view()->setCursorFromRow(row);
 
 			view()->center();
-			// see BufferView_pimpl::center()
-			view()->updateScrollbar();
 			break;
 		}
 
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.286
diff -u -p -u -r1.286 text3.C
--- text3.C	7 Mar 2005 11:03:45 -0000	1.286
+++ text3.C	30 Mar 2005 13:56:51 -0000
@@ -198,7 +198,6 @@ bool LyXText::cursorPrevious(LCursor & c
 		updated |= cursorUp(cur);
 	}
 
-	cur.bv().updateScrollbar();
 	finishUndo();
 	return updated;
 }
@@ -219,7 +218,6 @@ bool LyXText::cursorNext(LCursor & cur)
 		updated |= cursorDown(cur);
 	}
 
-	cur.bv().updateScrollbar();
 	finishUndo();
 	return updated;
 }
@@ -1135,9 +1133,12 @@ void LyXText::dispatch(LCursor & cur, Fu
 		moveCursor(cur, false);
 
 		// real_current_font.number can change so we need to
-		// update the minibuffer
+		// update the minibuffer.
+
+		//Please have a look here, whoever removed whatever
+		//was inside the if below (Ab)
 		if (old_font != real_current_font)
-		bv->updateScrollbar();
+			;
 		break;
 	}
 
Index: frontends/LyXView.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXView.C,v
retrieving revision 1.50
diff -u -p -u -r1.50 LyXView.C
--- frontends/LyXView.C	8 Feb 2005 13:18:02 -0000	1.50
+++ frontends/LyXView.C	30 Mar 2005 13:56:51 -0000
@@ -202,7 +202,8 @@ Buffer const * const LyXView::updateInse
 	Buffer const * buffer_ptr = 0;
 	if (inset) {
 		buffer_ptr = bufferview_->buffer();
-		bufferview_->update();
+		//do not fit the cursor
+		bufferview_->update(false, true);
 	}
 	return buffer_ptr;
 }
Index: frontends/Makefile.am
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/Makefile.am,v
retrieving revision 1.65
diff -u -p -u -r1.65 Makefile.am
--- frontends/Makefile.am	6 Mar 2005 04:29:27 -0000	1.65
+++ frontends/Makefile.am	30 Mar 2005 13:56:51 -0000
@@ -27,6 +27,7 @@ libfrontends_la_SOURCES = \
 	Timeout.h \
 	Toolbars.C \
 	Toolbars.h \
+	WorkArea.C \
 	WorkArea.h \
 	WorkAreaFactory.h \
 	font_metrics.h \
Index: frontends/WorkArea.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/WorkArea.h,v
retrieving revision 1.23
diff -u -p -u -r1.23 WorkArea.h
--- frontends/WorkArea.h	26 Sep 2004 14:19:46 -0000	1.23
+++ frontends/WorkArea.h	30 Mar 2005 13:56:51 -0000
@@ -34,7 +34,7 @@ class WorkArea {
 public:
 	typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
 
-	WorkArea() {}
+	WorkArea();
 
 	virtual ~WorkArea() {}
 
@@ -47,12 +47,16 @@ public:
 	virtual int workHeight() const = 0;
 
 	/**
-	 * 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
+	 * Update the scrollbar. All values are in [0,1]
+	 * @param height of the bar
+	 * @param pos the current position of the top of the scrollbar
+	 * @param line_height the line-scroll amount
 	 */
-	virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
+	void setScrollbarParams(double height, double pos);
+
+	void scrollDocViewInternal(int value);
+	
+	virtual void doSetScrollbarParams(int total, int height, int  pos, int line_height) = 0;
 
 	// FIXME: this is an odd place to have it, but xforms needs it here ...
 	/// a selection exists
@@ -65,7 +69,15 @@ public:
 	/// work area dimensions have changed
 	boost::signal<void()> workAreaResize;
 	/// the scrollbar has changed
-	boost::signal<void(int)> scrollDocView;
+	boost::signal<void(double)> scrollDocView;
+	/// the scrollbar has changed
+	boost::signal<void(void)> scrollPageUp;
+	/// the scrollbar has changed
+	boost::signal<void(void)> scrollPageDown;
+	/// the scrollbar has changed
+	boost::signal<void(void)> scrollLineUp;
+	/// the scrollbar has changed
+	boost::signal<void(void)> scrollLineDown;
 	/// a key combination has been pressed
 	boost::signal<void(LyXKeySymPtr, key_modifier::state)> workAreaKeyPress;
 	/// some mouse event
@@ -74,6 +86,9 @@ public:
 	boost::signal<void()> selectionRequested;
 	/// emitted when another X client has stolen our selection
 	boost::signal<void()> selectionLost;
+private:
+	int scroll_;
+	int page_;
 };
 
 #endif // WORKAREA_H
Index: frontends/gtk/GWorkArea.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/GWorkArea.C,v
retrieving revision 1.23
diff -u -p -u -r1.23 GWorkArea.C
--- frontends/gtk/GWorkArea.C	20 Mar 2005 17:13:17 -0000	1.23
+++ frontends/gtk/GWorkArea.C	30 Mar 2005 13:56:51 -0000
@@ -336,7 +336,7 @@ bool GWorkArea::onConfigure(GdkEventConf
 }
 
 
-void GWorkArea::setScrollbarParams(int height, int pos, int line_height)
+void GWorkArea::doSetScrollbarParams(int total, int height, int pos, int line_height)
 {
 	if (adjusting_)
 		return;
@@ -345,21 +345,21 @@ void GWorkArea::setScrollbarParams(int h
 	
 	Gtk::Adjustment * adjustment = vscrollbar_.get_adjustment();
 	adjustment->set_lower(0);
-	int workAreaHeight = workHeight();
-	if (!height || height < workAreaHeight) {
-		adjustment->set_upper(workAreaHeight);
-		adjustment->set_page_size(workAreaHeight);
+
+	if (!total) {
+		adjustment->set_upper(total);
+		adjustment->set_page_size(height);
 		adjustment->set_value(0);
 		adjustment->changed();
 		adjusting_ = false;
 		return;
 	}
-	adjustment->set_step_increment(line_height * 3);
-	adjustment->set_page_increment(workAreaHeight - line_height);
+	adjustment->set_step_increment(line_height);
+	adjustment->set_page_increment(height);
 	// Allow the user half a screen of blank at the end
 	// to make scrollbar consistant with centering the cursor
-	adjustment->set_upper(height + workAreaHeight / 2);
-	adjustment->set_page_size(workAreaHeight);
+	adjustment->set_upper(total);
+	adjustment->set_page_size(height);
 	adjustment->set_value(pos);
 	adjustment->changed();
 	adjusting_ = false;
@@ -374,7 +374,7 @@ void GWorkArea::onScroll()
 	adjusting_ = true;
 	
 	double val = vscrollbar_.get_adjustment()->get_value();
-	scrollDocView(static_cast<int>(val));
+	scrollDocViewInternal(static_cast<int>(val));
 	adjusting_ = false;
 }
 
Index: frontends/gtk/GWorkArea.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/GWorkArea.h,v
retrieving revision 1.15
diff -u -p -u -r1.15 GWorkArea.h
--- frontends/gtk/GWorkArea.h	20 Mar 2005 17:13:17 -0000	1.15
+++ frontends/gtk/GWorkArea.h	30 Mar 2005 13:56:51 -0000
@@ -78,7 +78,7 @@ public:
 	XftDraw * getXftDraw();
 	ColorHandler & getColorHandler();
 
-	virtual void setScrollbarParams(int height, int pos, int line_height);
+	virtual void doSetScrollbarParams(int total, int height, int pos, int line_height);
 	/// a selection exists
 	virtual void haveSelection(bool) const;
 	///
Index: frontends/qt2/QContentPane.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.C,v
retrieving revision 1.32
diff -u -p -u -r1.32 QContentPane.C
--- frontends/qt2/QContentPane.C	1 Aug 2004 21:24:03 -0000	1.32
+++ frontends/qt2/QContentPane.C	30 Mar 2005 13:56:51 -0000
@@ -122,7 +122,7 @@ void QContentPane::generateSyntheticMous
 void QContentPane::scrollBarChanged(int val)
 {
 	if (track_scrollbar_)
-		wa_->scrollDocView(val);
+		wa_->scrollDocViewInternal(val);
 }
 
 
Index: frontends/qt2/QWorkArea.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QWorkArea.C,v
retrieving revision 1.28
diff -u -p -u -r1.28 QWorkArea.C
--- frontends/qt2/QWorkArea.C	20 May 2004 09:36:28 -0000	1.28
+++ frontends/qt2/QWorkArea.C	30 Mar 2005 13:56:51 -0000
@@ -72,19 +72,14 @@ QWorkArea::~QWorkArea()
 }
 
 
-void QWorkArea::setScrollbarParams(int h, int pos, int line_h)
+void QWorkArea::doSetScrollbarParams(int total, int height, int pos, int line_h)
 {
-	// do what cursor movement does (some grey)
-	h += height() / 4;
-
-	int max = std::max(0, h - height());
-
-	scrollbar_->setRange(0, max);
+	scrollbar_->setRange(0, total);
 	content_->trackScrollbar(false);
 	scrollbar_->setValue(pos);
 	content_->trackScrollbar(true);
 	scrollbar_->setLineStep(line_h);
-	scrollbar_->setPageStep(height());
+	scrollbar_->setPageStep(height);
 }
 
 #ifdef Q_WS_X11
Index: frontends/qt2/QWorkArea.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QWorkArea.h,v
retrieving revision 1.15
diff -u -p -u -r1.15 QWorkArea.h
--- frontends/qt2/QWorkArea.h	28 Apr 2004 17:22:04 -0000	1.15
+++ frontends/qt2/QWorkArea.h	30 Mar 2005 13:56:51 -0000
@@ -45,7 +45,7 @@ public:
 	/// return the height of the content pane
 	virtual int workHeight() const { return content_->height(); }
 	///
-	virtual void setScrollbarParams(int height, int pos, int line_height);
+	virtual void doSetScrollbarParams(int total, int height, int pos, int line_height);
 
 	/// a selection exists
 	virtual void haveSelection(bool) const;
Index: frontends/xforms/XWorkArea.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XWorkArea.C,v
retrieving revision 1.51
diff -u -p -u -r1.51 XWorkArea.C
--- frontends/xforms/XWorkArea.C	30 Nov 2004 15:56:13 -0000	1.51
+++ frontends/xforms/XWorkArea.C	30 Mar 2005 13:56:51 -0000
@@ -222,45 +222,41 @@ void XWorkArea::redraw(int width, int he
 }
 
 
-void XWorkArea::setScrollbarParams(int height, int pos, int line_height)
+void XWorkArea::doSetScrollbarParams(int total, int height, int pos, int line_height)
 {
 	// we need to cache this for scroll_cb
-	doc_height_ = height;
+	doc_height_ = total;
 
 	if (height == 0) {
 		fl_set_scrollbar_value(scrollbar, 0.0);
-		fl_set_scrollbar_size(scrollbar, scrollbar->h);
+		fl_set_scrollbar_size(scrollbar, 1.0);
 		return;
 	}
 
-	long const work_height = workHeight();
-
-	if (lyxerr.debugging(Debug::GUI)) {
-		lyxerr << "scroll: height now " << height << '\n'
-		       << "scroll: work_height " << work_height << endl;
-	}
+	lyxerr[Debug::GUI] << "scroll: doc height " << total << '\n'
+			   << "scroll: height " << height << endl;
 
 	/* If the text is smaller than the working area, the scrollbar
 	 * maximum must be the working area height. No scrolling will
 	 * be possible */
-	if (height <= work_height) {
+	if (total <= height) {
 		lyxerr[Debug::GUI] << "scroll: doc smaller than workarea !"
 				   << endl;
 		fl_set_scrollbar_bounds(scrollbar, 0.0, 0.0);
 		fl_set_scrollbar_value(scrollbar, pos);
-		fl_set_scrollbar_size(scrollbar, scrollbar->h);
+		fl_set_scrollbar_size(scrollbar, 1.0);
 		return;
 	}
 
-	fl_set_scrollbar_bounds(scrollbar, 0.0, height - work_height);
-	fl_set_scrollbar_increment(scrollbar, work_area->h - line_height, line_height);
+	fl_set_scrollbar_bounds(scrollbar, 0.0, total);
+	fl_set_scrollbar_increment(scrollbar, height, line_height);
 
 	fl_set_scrollbar_value(scrollbar, pos);
 
 	double const slider_size =
-		(height == 0) ? 1.0 : 1.0 / double(height);
+		(height == 0) ? 1.0 : (height / double(total));
 
-	fl_set_scrollbar_size(scrollbar, scrollbar->h * slider_size);
+	fl_set_scrollbar_size(scrollbar, slider_size);
 }
 
 
@@ -275,7 +271,7 @@ void XWorkArea::scroll_cb()
 		       << "scroll: docheight: " << doc_height_ << endl;
 	}
 
-	scrollDocView(int(val));
+	scrollDocViewInternal(int(val));
 	waitForX(false);
 }
 
Index: frontends/xforms/XWorkArea.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XWorkArea.h,v
retrieving revision 1.29
diff -u -p -u -r1.29 XWorkArea.h
--- frontends/xforms/XWorkArea.h	30 Nov 2004 15:56:13 -0000	1.29
+++ frontends/xforms/XWorkArea.h	30 Mar 2005 13:56:52 -0000
@@ -40,7 +40,7 @@ public:
 	///
 	Window getWin() const { return work_area->form->window; }
 	///
-	virtual void setScrollbarParams(int height, int pos, int line_height);
+	virtual void doSetScrollbarParams(int total, int height, int pos, int line_height);
 	///
 	Pixmap getPixmap() const { return workareapixmap; }
 	/// xforms callback

Reply via email to