Alfredo Braunstein wrote:

> John Levon wrote:
> 
>> No dice, scrolling through the user guide with the scroll bar gave me
>> this :
>> 
> 
> Damn, will look at it. Sorry.
>         Alfredo

Found it. It seem that top_y(int) got called before the existence of any
row. Should be ok now.

Alfredo
Index: BufferView_pimpl.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/BufferView_pimpl.C,v
retrieving revision 1.338
diff -u -p -u -r1.338 BufferView_pimpl.C
--- BufferView_pimpl.C	2003/03/06 10:02:36	1.338
+++ BufferView_pimpl.C	2003/03/06 19:16:37
@@ -184,8 +184,7 @@ void BufferView::Pimpl::buffer(Buffer * 
 		}
 
 		// FIXME: needed when ?
-		bv_->text->first_y =
-			screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
+		bv_->text->top_y(screen().topCursorVisible(bv_->text->cursor, bv_->text->top_y()));
 
 		// Similarly, buffer-dependent dialogs should be updated or
 		// hidden. This should go here because some dialogs (eg ToC)
@@ -322,7 +321,7 @@ int BufferView::Pimpl::resizeCurrentBuff
 		bv_->theLockingInset(the_locking_inset);
 	}
 
-	bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
+	bv_->text->top_y(screen().topCursorVisible(bv_->text->cursor, bv_->text->top_y()));
 
 	switchKeyMap();
 	owner_->busy(false);
@@ -350,10 +349,10 @@ void BufferView::Pimpl::updateScrollbar(
 
 	LyXText const & t = *bv_->text;
 
-	lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", first_y "
-		<< t.first_y << ", default height " << defaultRowHeight() << endl;
+	lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", top_y() "
+		<< t.top_y() << ", default height " << defaultRowHeight() << endl;
 
-	workarea().setScrollbarParams(t.height, t.first_y, defaultRowHeight());
+	workarea().setScrollbarParams(t.height, t.top_y(), defaultRowHeight());
 }
 
 
@@ -372,8 +371,8 @@ void BufferView::Pimpl::scrollDocView(in
 	LyXText * vbt = bv_->text;
 
 	int const height = defaultRowHeight();
-	int const first = static_cast<int>((bv_->text->first_y + height));
-	int const last = static_cast<int>((bv_->text->first_y + workarea().workHeight() - height));
+	int const first = static_cast<int>((bv_->text->top_y() + height));
+	int const last = static_cast<int>((bv_->text->top_y() + workarea().workHeight() - height));
 
 	if (vbt->cursor.y() < first)
 		vbt->setCursorFromCoordinates(bv_, 0, first);
@@ -392,16 +391,16 @@ void BufferView::Pimpl::scroll(int lines
 	int const line_height = defaultRowHeight();
 
 	// The new absolute coordinate
-	int new_first_y = t->first_y + lines * line_height;
+	int new_top_y = t->top_y() + lines * line_height;
 
 	// Restrict to a valid value
-	new_first_y = std::min(t->height - 4 * line_height, new_first_y);
-	new_first_y = std::max(0, new_first_y);
+	new_top_y = std::min(t->height - 4 * line_height, new_top_y);
+	new_top_y = std::max(0, new_top_y);
 
-	scrollDocView(new_first_y);
+	scrollDocView(new_top_y);
 
 	// Update the scrollbar.
-	workarea().setScrollbarParams(t->height, t->first_y, defaultRowHeight());
+	workarea().setScrollbarParams(t->height, t->top_y(), defaultRowHeight());
 }
 
 
@@ -777,14 +776,14 @@ void BufferView::Pimpl::center()
 	}
 
 	// FIXME: can we do this w/o calling screen directly ?
-	// This updates first_y but means the fitCursor() call
+	// This updates top_y() but means the fitCursor() call
 	// from the update(FITCUR) doesn't realise that we might
 	// have moved (e.g. from GOTOPARAGRAPH), so doesn't cause
 	// the scrollbar to be updated as it should, so we have
 	// to do it manually. Any operation that does a center()
-	// and also might have moved first_y must make sure to call
+	// and also might have moved top_y() must make sure to call
 	// updateScrollbar() currently. Never mind that this is a
-	// pretty obfuscated way of updating t->first_y
+	// pretty obfuscated way of updating t->top_y()
 	screen().draw(t, bv_, new_y);
 
 	update(t, BufferView::SELECT | BufferView::FITCUR);
Index: ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v
retrieving revision 1.1073
diff -u -p -u -r1.1073 ChangeLog
--- ChangeLog	2003/03/06 15:39:36	1.1073
+++ ChangeLog	2003/03/06 19:16:57
@@ -1,3 +1,13 @@
+2003-03-06  Alfredo Braunstein  <[EMAIL PROTECTED]>
+
+	* lyxtext.h (top_y): added these 2 methods, and private vars top_row_ 
+	and top_row_offset_. removed var first_y.
+	* text.C (top_y): 
+	* text2.C (LyXText, removeRow): 
+	* text3.C:
+	* BufferView_pimpl.C: 
+	use these methods instead of using first_y
+
 2003-03-06  Lars Gullik Bjønnes  <[EMAIL PROTECTED]>
 
 	* CutAndPaste.h: make CutAndPaste a namespace.
Index: lyxtext.h
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/lyxtext.h,v
retrieving revision 1.136
diff -u -p -u -r1.136 lyxtext.h
--- lyxtext.h	2003/03/06 10:02:37	1.136
+++ lyxtext.h	2003/03/06 19:16:58
@@ -79,9 +79,20 @@ public:
 	mutable LyXFont current_font;
 	/// the current font
 	mutable LyXFont real_current_font;
-	/// first visible pixel-row is set from LyXScreen!!!
-	// unsigned is wrong here for text-insets!
-	int first_y;
+private:
+	/** the first visible row on screen
+	 *  declared mutable because removeRow is const
+	 */
+	mutable Row * top_row_;
+	/** the pixel offset with respect to this row of top_y 
+	 *  declared mutable because removeRow is const
+	 */
+	mutable int top_row_offset_;
+public:
+	/// get the y coord. of the top of the screen (relative to doc start)
+	int top_y() const;
+	/// set it
+	void top_y(int newy);
 	///
 	InsetText * inset_owner;
 	///
Index: text.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/text.C,v
retrieving revision 1.298
diff -u -p -u -r1.298 text.C
--- text.C	2003/03/06 10:02:37	1.298
+++ text.C	2003/03/06 19:17:03
@@ -58,6 +58,33 @@ extern int const LEFT_MARGIN = PAPER_MAR
 extern int bibitemMaxWidth(BufferView *, LyXFont const &);
 
 
+int LyXText::top_y() const
+{
+	if (!top_row_)
+		return 0;
+	
+	int y = 0;
+	for (Row * row = firstrow; row && row != top_row_; row = row->next()) {
+		y += row->height();
+	}
+	return y + top_row_offset_;
+}
+
+
+void LyXText::top_y(int newy)
+{
+	if (!firstrow)
+		return;
+	lyxerr[Debug::GUI] << "setting top y = " << newy << endl;
+	
+	int y = newy;
+	top_row_ = getRowNearY(y);
+	top_row_offset_ = newy - y;
+	lyxerr[Debug::GUI] << "changing reference to row: " << top_row_
+	       << " offset: " << top_row_offset_ << endl;
+}
+
+
 int LyXText::workWidth(BufferView & bview) const
 {
 	if (inset_owner) {
Index: text2.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/text2.C,v
retrieving revision 1.279
diff -u -p -u -r1.279 text2.C
--- text2.C	2003/03/03 23:18:59	1.279
+++ text2.C	2003/03/06 19:17:06
@@ -52,7 +52,7 @@ using lyx::pos_type;
 
 
 LyXText::LyXText(BufferView * bv)
-	: height(0), width(0), first_y(0),
+	: height(0), width(0), top_row_(0), top_row_offset_(0), 
 	  inset_owner(0), the_locking_inset(0), need_break_row(0),
 	  refresh_y(0), refresh_row(0), bv_owner(bv),
 	  status_(LyXText::UNCHANGED), firstrow(0), lastrow(0)
@@ -60,7 +60,7 @@ LyXText::LyXText(BufferView * bv)
 
 
 LyXText::LyXText(InsetText * inset)
-	: height(0), width(0), first_y(0),
+	: height(0), width(0), top_row_(0), top_row_offset_(0), 
 	  inset_owner(inset), the_locking_inset(0), need_break_row(0),
 	  refresh_y(0), refresh_row(0), bv_owner(0),
 	  status_(LyXText::UNCHANGED), firstrow(0), lastrow(0)
@@ -83,7 +83,7 @@ void LyXText::init(BufferView * bview, b
 		need_break_row = 0;
 		width = height = 0;
 		copylayouttype.erase();
-		first_y = refresh_y = 0;
+		top_y(refresh_y = 0);
 		status_ = LyXText::UNCHANGED;
 	} else if (firstrow)
 		return;
@@ -326,6 +326,15 @@ void LyXText::removeRow(Row * row) const
 		refresh_row = row_prev ? row_prev : row->next();
 		// what about refresh_y, refresh_height
 	}
+	if (top_row_ == row) {
+		if (row->next()) {
+			top_row_ = row->next();
+			top_row_offset_ -= row->height();
+		} else {
+			top_row_ = row_prev;
+			top_row_offset_ = 0;
+		}
+	}
 
 	height -= row->height(); // the text becomes smaller
 
@@ -2034,9 +2043,10 @@ void LyXText::cursorUp(BufferView * bvie
 	int y = cursor.y() - cursor.row()->baseline() - 1;
 	setCursorFromCoordinates(bview, x, y);
 	if (!selecting) {
-		int y1 = cursor.iy() - first_y;
+		int topy = top_y();
+		int y1 = cursor.iy() - topy;
 		int y2 = y1;
-		y -= first_y;
+		y -= topy;
 		Inset * inset_hit = checkInsetHit(bview, x, y1);
 		if (inset_hit && isHighlyEditableInset(inset_hit)) {
 			inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none);
@@ -2057,9 +2067,10 @@ void LyXText::cursorDown(BufferView * bv
 		cursor.row()->height() + 1;
 	setCursorFromCoordinates(bview, x, y);
 	if (!selecting && cursor.row() == cursor.irow()) {
-		int y1 = cursor.iy() - first_y;
+		int topy = top_y();
+		int y1 = cursor.iy() - topy;
 		int y2 = y1;
-		y -= first_y;
+		y -= topy;
 		Inset * inset_hit = checkInsetHit(bview, x, y1);
 		if (inset_hit && isHighlyEditableInset(inset_hit)) {
 			inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none);
Index: text3.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/text3.C,v
retrieving revision 1.39
diff -u -p -u -r1.39 text3.C
--- text3.C	2003/03/06 10:02:39	1.39
+++ text3.C	2003/03/06 19:17:09
@@ -143,7 +143,7 @@ namespace {
 
 Inset * LyXText::checkInsetHit(BufferView * bv, int & x, int & y) const
 {
-	int y_tmp = y + first_y;
+	int y_tmp = y + top_y();
 
 	LyXCursor cur;
 	setCursorFromCoordinates(bv, cur, x, y_tmp);
@@ -241,15 +241,15 @@ void LyXText::gotoInset(BufferView * bv,
 void LyXText::cursorPrevious(BufferView * bv)
 {
 	if (!cursor.row()->previous()) {
-		if (first_y > 0) {
-			int new_y = bv->text->first_y - bv->workHeight();
+		if (top_y() > 0) {
+			int new_y = top_y() - bv->workHeight();
 			bv->screen().draw(bv->text, bv, new_y < 0 ? 0 : new_y);
 			bv->updateScrollbar();
 		}
 		return;
 	}
 
-	int y = first_y;
+	int y = top_y();
 	Row * cursorrow = cursor.row();
 
 	setCursorFromCoordinates(bv, cursor.x_fix(), y);
@@ -264,7 +264,7 @@ void LyXText::cursorPrevious(BufferView 
 		// This is what we used to do, so we wouldn't skip right past
 		// tall rows, but it's not working right now.
 #if 0
-		new_y = bv->text->first_y - bv->workHeight();
+		new_y = bv->text->top_y() - bv->workHeight();
 #endif
 	} else {
 		if (inset_owner) {
@@ -284,7 +284,7 @@ void LyXText::cursorPrevious(BufferView 
 		LyXCursor cur;
 		setCursor(bv, cur, cursor.row()->previous()->par(),
 						cursor.row()->previous()->pos(), false);
-		if (cur.y() > first_y) {
+		if (cur.y() > top_y()) {
 			cursorUp(bv, true);
 		}
 	}
@@ -297,18 +297,17 @@ void LyXText::cursorNext(BufferView * bv
 	if (!cursor.row()->next()) {
 		int y = cursor.y() - cursor.row()->baseline() +
 			cursor.row()->height();
-		if (y > int(first_y + bv->workHeight())) {
-			bv->screen().draw(bv->text, bv,
-						  bv->text->first_y + bv->workHeight());
+		if (y > top_y() + bv->workHeight()) {
+			bv->screen().draw(bv->text, bv, top_y() + bv->workHeight());
 			bv->updateScrollbar();
 		}
 		return;
 	}
 
-	int y = first_y + bv->workHeight();
-	if (inset_owner && !first_y) {
+	int y = top_y() + bv->workHeight();
+	if (inset_owner && !top_y()) {
 		y -= (bv->text->cursor.iy()
-			  - bv->text->first_y
+			  - bv->text->top_y()
 			  + bv->theLockingInset()->insetInInsetY());
 	}
 
@@ -328,7 +327,7 @@ void LyXText::cursorNext(BufferView * bv
 		// This is what we used to do, so we wouldn't skip right past
 		// tall rows, but it's not working right now.
 #if 0
-		new_y = bv->text->first_y + bv->workHeight();
+		new_y = bv->text->top_y() + bv->workHeight();
 #endif
 	} else {
 		if (inset_owner) {
@@ -344,7 +343,7 @@ void LyXText::cursorNext(BufferView * bv
 		LyXCursor cur;
 		setCursor(bv, cur, cursor.row()->next()->par(),
 						cursor.row()->next()->pos(), false);
-		if (cur.y() < int(first_y + bv->workHeight())) {
+		if (cur.y() < top_y() + bv->workHeight()) {
 			cursorDown(bv, true);
 		}
 	}
@@ -1298,7 +1297,7 @@ Inset::RESULT LyXText::dispatch(FuncRequ
 			int start_x = inset_x + tli->scroll();
 			FuncRequest cmd1 = cmd;
 			cmd1.x = cmd.x - start_x;
-			cmd1.y = cmd.y - cursor.iy() + bv->text->first_y;
+			cmd1.y = cmd.y - cursor.iy() + bv->text->top_y();
 			tli->localDispatch(cmd1);
 			break;
 		}
@@ -1315,7 +1314,7 @@ Inset::RESULT LyXText::dispatch(FuncRequ
 		bv->screen().hideCursor();
 
 		Row * cursorrow = bv->text->cursor.row();
-		bv->text->setCursorFromCoordinates(bv, cmd.x, cmd.y + bv->text->first_y);
+		bv->text->setCursorFromCoordinates(bv, cmd.x, cmd.y + bv->text->top_y());
 	#if 0
 		// sorry for this but I have a strange error that the y value jumps at
 		// a certain point. This seems like an error in my xforms library or
@@ -1327,7 +1326,7 @@ Inset::RESULT LyXText::dispatch(FuncRequ
 	#endif
 		// This is to allow jumping over large insets
 		if (cursorrow == bv->text->cursor.row()) {
-			if (cmd.y >= int(bv->workHeight()))
+			if (cmd.y >= bv->workHeight())
 				bv->text->cursorDown(bv, false);
 			else if (cmd.y < 0)
 				bv->text->cursorUp(bv, false);
@@ -1376,7 +1375,7 @@ Inset::RESULT LyXText::dispatch(FuncRequ
 			paste_internally = true;
 		}
 
-		int const screen_first = bv->text->first_y;
+		int const screen_first = bv->text->top_y();
 
 		if (bv->theLockingInset()) {
 			// We are in inset locking mode
Index: frontends/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/ChangeLog,v
retrieving revision 1.161
diff -u -p -u -r1.161 ChangeLog
--- frontends/ChangeLog	2003/03/05 23:19:44	1.161
+++ frontends/ChangeLog	2003/03/06 19:17:10
@@ -1,3 +1,7 @@
+2003-03-06  Alfredo Braunstein  <[EMAIL PROTECTED]>
+
+	* screen.C: use LyXText::top_y() instead of LyXText::first_y
+
 2003-03-05  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* Dialogs.h: remove showWrap.
Index: frontends/screen.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/screen.C,v
retrieving revision 1.30
diff -u -p -u -r1.30 screen.C
--- frontends/screen.C	2003/02/27 09:39:24	1.30
+++ frontends/screen.C	2003/03/06 19:17:11
@@ -160,20 +160,20 @@ bool LyXScreen::fitManualCursor(BufferVi
 	int /*x*/, int y, int asc, int desc)
 {
 	int const vheight = workarea().workHeight();
-	int newtop = text->first_y;
+	int newtop = text->top_y();
 
-	if (y + desc - text->first_y >= vheight)
+	if (y + desc - text->top_y() >= vheight)
 		newtop = y - 3 * vheight / 4;  // the scroll region must be so big!!
-	else if (y - asc < text->first_y
-		&& text->first_y > 0) {
+	else if (y - asc < text->top_y()
+		&& text->top_y() > 0) {
 		newtop = y - vheight / 4;
 	}
 
 	newtop = max(newtop, 0); // can newtop ever be < 0? (Lgb)
 
-	if (newtop != text->first_y) {
+	if (newtop != text->top_y()) {
 		draw(text, bv, newtop);
-		text->first_y = newtop;
+		text->top_y(newtop);
 		return true;
 	}
 
@@ -234,8 +234,8 @@ unsigned int LyXScreen::topCursorVisible
 bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
 {
 	// Is a change necessary?
-	int const newtop = topCursorVisible(text->cursor, text->first_y);
-	bool const result = (newtop != text->first_y);
+	int const newtop = topCursorVisible(text->cursor, text->top_y());
+	bool const result = (newtop != text->top_y());
 	if (result) {
 		draw(text, bv, newtop);
 	}
@@ -255,7 +255,7 @@ void LyXScreen::update(LyXText * text, B
 	switch (text->status()) {
 	case LyXText::NEED_MORE_REFRESH:
 	{
-		int const y = max(int(text->refresh_y - text->first_y), 0);
+		int const y = max(int(text->refresh_y - text->top_y()), 0);
 		drawFromTo(text, bv, y, vheight, yo, xo);
 		text->refresh_y = 0;
 		// otherwise this is called ONLY from BufferView_pimpl(update)
@@ -277,7 +277,7 @@ void LyXScreen::update(LyXText * text, B
 			// or we should see to set this flag accordingly
 			if (text != bv->text)
 				text->status(bv, LyXText::UNCHANGED);
-			expose(0, text->refresh_y - text->first_y + yo,
+			expose(0, text->refresh_y - text->top_y() + yo,
 				   vwidth, text->refresh_row->height());
 		}
 	}
@@ -303,24 +303,24 @@ void LyXScreen::toggleSelection(LyXText 
 		max(static_cast<int>(text->selection.end.y()
 				     - text->selection.end.row()->baseline()
 				     + text->selection.end.row()->height()),
-		    text->first_y),
-		static_cast<int>(text->first_y + workarea().workHeight()));
+		    text->top_y()),
+		static_cast<int>(text->top_y() + workarea().workHeight()));
 	int const top = min(
 		max(static_cast<int>(text->selection.start.y() -
 				     text->selection.start.row()->baseline()),
-		    text->first_y),
-		static_cast<int>(text->first_y + workarea().workHeight()));
+		    text->top_y()),
+		static_cast<int>(text->top_y() + workarea().workHeight()));
 
 	if (kill_selection)
 		text->selection.set(false);
 
 	workarea().getPainter().start();
 
-	drawFromTo(text, bv, top - text->first_y, bottom - text->first_y,
+	drawFromTo(text, bv, top - text->top_y(), bottom - text->top_y(),
 		   yo, xo);
-	expose(0, top - text->first_y,
+	expose(0, top - text->top_y(),
 	       workarea().workWidth(),
-	       bottom - text->first_y - (top - text->first_y));
+	       bottom - text->top_y() - (top - text->top_y()));
 
 	workarea().getPainter().end();
 }
@@ -340,18 +340,18 @@ void LyXScreen::toggleToggle(LyXText * t
 		+ text->toggle_end_cursor.row()->height();
 
 	int const offset = yo < 0 ? yo : 0;
-	int const bottom = min(max(bottom_tmp, text->first_y),
-		static_cast<int>(text->first_y + workarea().workHeight())) - offset;
-	int const top = min(max(top_tmp, text->first_y),
-		static_cast<int>(text->first_y + workarea().workHeight())) - offset;
+	int const bottom = min(max(bottom_tmp, text->top_y()),
+		static_cast<int>(text->top_y() + workarea().workHeight())) - offset;
+	int const top = min(max(top_tmp, text->top_y()),
+		static_cast<int>(text->top_y() + workarea().workHeight())) - offset;
 
 	workarea().getPainter().start();
 
-	drawFromTo(text, bv, top - text->first_y,
-		   bottom - text->first_y, yo,
+	drawFromTo(text, bv, top - text->top_y(),
+		   bottom - text->top_y(), yo,
 		   xo);
-	expose(0, top - text->first_y, workarea().workWidth(),
-	       bottom - text->first_y - (top - text->first_y));
+	expose(0, top - text->top_y(), workarea().workWidth(),
+	       bottom - text->top_y() - (top - text->top_y()));
 
 	workarea().getPainter().end();
 }
@@ -366,6 +366,8 @@ void LyXScreen::redraw(LyXText * text, B
 		return;
 	}
 
+	
+
 	workarea().getPainter().start();
 
 	drawFromTo(text, bv, 0, workarea().workHeight(), 0, 0, text == bv->text);
@@ -423,22 +425,24 @@ void LyXScreen::drawFromTo(LyXText * tex
 {
 	lyxerr[Debug::GUI] << "screen: drawFromTo " << y1 << '-' << y2 << endl;
 
-	int y_text = text->first_y + y1;
+	int y_text = text->top_y() + y1;
 
 	// get the first needed row
 	Row * row = text->getRowNearY(y_text);
 	// y_text is now the real beginning of the row
 
-	int y = y_text - text->first_y;
+	int y = y_text - text->top_y();
 	// y1 is now the real beginning of row on the screen
 
+
 	while (row != 0 && y < y2) {
 		LyXText::text_status st = text->status();
 		// we need this here as the row pointer may be illegal
 		// at a later time (Jug20020502)
 		Row * prev = row->previous();
 		RowPainter rp(*bv, *text, *row);
-		if (rp.paint(y + yo, xo, y + text->first_y))
+
+		if (rp.paint(y + yo, xo, y + text->top_y()))
 			text->markChangeInDraw(bv, row, prev);
 
 		internal = internal && (st != LyXText::CHANGED_IN_DRAW);
@@ -449,7 +453,7 @@ void LyXScreen::drawFromTo(LyXText * tex
 			text->status(bv, st);
 			Row * prev = row->previous();
 			RowPainter rp(*bv, *text, *row);
-			if (rp.paint(y + yo, xo, y + text->first_y))
+			if (rp.paint(y + yo, xo, y + text->top_y()))
 				text->markChangeInDraw(bv, row, prev);
 		}
 		y += row->height();
@@ -469,13 +473,13 @@ void LyXScreen::drawFromTo(LyXText * tex
 void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
 	int y_text, int yo, int xo)
 {
-	int const y = y_text - text->first_y + yo;
+	int const y = y_text - text->top_y() + yo;
 
 	if (((y + row->height()) > 0) &&
 	    ((y - row->height()) <= static_cast<int>(workarea().workHeight()))) {
 		Row * prev = row->previous();
 		RowPainter rp(*bv, *text, *row);
-		if (rp.paint(y, xo, y + text->first_y))
+		if (rp.paint(y, xo, y + text->top_y()))
 			text->markChangeInDraw(bv, row, prev);
 	}
 	force_clear_ = false;
Index: frontends/qt2/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/ChangeLog,v
retrieving revision 1.424
diff -u -p -u -r1.424 ChangeLog
--- frontends/qt2/ChangeLog	2003/03/06 15:34:28	1.424
+++ frontends/qt2/ChangeLog	2003/03/06 19:17:17
@@ -1,3 +1,7 @@
+2003-03-06  Alfredo Braunstein  <[EMAIL PROTECTED]>
+
+	* qscreen.C: use LyXText::top_y() instead of LyXText::first_y
+
 2003-03-06  John Levon  <[EMAIL PROTECTED]>
 
 	* ui/QPrefUIModule.ui: make max last files reflect reality,
Index: frontends/qt2/qscreen.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/qscreen.C,v
retrieving revision 1.13
diff -u -p -u -r1.13 qscreen.C
--- frontends/qt2/qscreen.C	2003/02/13 16:52:54	1.13
+++ frontends/qt2/qscreen.C	2003/03/06 19:17:18
@@ -58,8 +58,8 @@ void QScreen::showManualCursor(LyXText c
 	if (!qApp->focusWidget())
 		return;
 
-	int const y1 = max(y - text->first_y - asc, 0);
-	int const y_tmp = min(y - text->first_y + desc, owner_.height());
+	int const y1 = max(y - text->top_y() - asc, 0);
+	int const y_tmp = min(y - text->top_y() + desc, owner_.height());
 
 	// secure against very strange situations
 	// which would be when .... ?
@@ -160,9 +160,9 @@ void QScreen::draw(LyXText * text, Buffe
 
 	if (cursor_visible_) hideCursor();
 
-	int const old_first = text->first_y;
+	int const old_first = text->top_y();
 	bool const internal = (text == bv->text);
-	text->first_y = y;
+	text->top_y(y);
 
 	// If you want to fix the warning below, fix it so it
 	// actually scrolls properly. Hint: a cast won't do.
@@ -170,13 +170,13 @@ void QScreen::draw(LyXText * text, Buffe
 	// is any optimization possible?
 	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;
+		if (text->top_y() < old_first) {
+			int const dest_y = old_first - text->top_y();
 			drawFromTo(text, bv, 0, dest_y, 0, 0, internal);
 			copyInPixmap(p, dest_y, 0, owner_.workWidth(), owner_.height() - dest_y);
 			expose(0, 0, owner_.workWidth(), dest_y);
 		} else  {
-			int const src_y = text->first_y - old_first;
+			int const src_y = text->top_y() - old_first;
 			drawFromTo(text, bv, owner_.height() - src_y, owner_.height(), 0, 0, internal);
 			copyInPixmap(p, 0, 0, owner_.workWidth(), owner_.height() - src_y);
 			expose(0, owner_.height() - src_y, owner_.workWidth(), src_y);
Index: frontends/xforms/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/ChangeLog,v
retrieving revision 1.692
diff -u -p -u -r1.692 ChangeLog
--- frontends/xforms/ChangeLog	2003/03/06 08:24:33	1.692
+++ frontends/xforms/ChangeLog	2003/03/06 19:17:35
@@ -1,3 +1,7 @@
+2003-03-06  Alfredo Braunstein  <[EMAIL PROTECTED]>
+
+	* xscreen.C: use LyXText::top_y() instead of LyXText::first_y
+
 2003-02-28  Rob Lahaye  <[EMAIL PROTECTED]>
 
 	* FormTabularCreate.C: remove slider settings (now part of .fd file)
Index: frontends/xforms/xscreen.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/xscreen.C,v
retrieving revision 1.13
diff -u -p -u -r1.13 xscreen.C
--- frontends/xforms/xscreen.C	2003/02/13 16:52:59	1.13
+++ frontends/xforms/xscreen.C	2003/03/06 19:17:37
@@ -95,8 +95,8 @@ void XScreen::showManualCursor(LyXText c
 	// Update the cursor color.
 	setCursorColor();
 
-	int const y1 = max(y - text->first_y - asc, 0);
-	int const y_tmp = min(y - text->first_y + desc,
+	int const y1 = max(y - text->top_y() - asc, 0);
+	int const y_tmp = min(y - text->top_y() + desc,
 			      static_cast<int>(owner_.workHeight()));
 
 	// Secure against very strange situations
@@ -205,17 +205,17 @@ void XScreen::draw(LyXText * text, Buffe
 	if (cursor_visible_)
 		hideCursor();
 
-	int const old_first = text->first_y;
+	int const old_first = text->top_y();
 	bool const internal = (text == bv->text);
-	text->first_y = y;
+	text->top_y(y);
 
 	// is any optimization possible?
 	if ((y - old_first) < owner_.workHeight()
 	    && (old_first - y) < owner_.workHeight())
 	{
-		if (text->first_y < old_first) {
+		if (text->top_y() < old_first) {
 			drawFromTo(text, bv, 0,
-				   old_first - text->first_y, 0, 0, internal);
+				   old_first - text->top_y(), 0, 0, internal);
 			XCopyArea (fl_get_display(),
 				   owner_.getWin(),
 				   owner_.getWin(),
@@ -223,31 +223,31 @@ void XScreen::draw(LyXText * text, Buffe
 				   owner_.xpos(),
 				   owner_.ypos(),
 				   owner_.workWidth(),
-				   owner_.workHeight() - old_first + text->first_y,
+				   owner_.workHeight() - old_first + text->top_y(),
 				   owner_.xpos(),
-				   owner_.ypos() + old_first - text->first_y
+				   owner_.ypos() + old_first - text->top_y()
 				);
 			// expose the area drawn
 			expose(0, 0,
 			       owner_.workWidth(),
-			       old_first - text->first_y);
+			       old_first - text->top_y());
 		} else  {
 			drawFromTo(text, bv,
-				   owner_.workHeight() + old_first - text->first_y,
+				   owner_.workHeight() + old_first - text->top_y(),
 				   owner_.workHeight(), 0, 0, internal);
 			XCopyArea (fl_get_display(),
 				   owner_.getWin(),
 				   owner_.getWin(),
 				   gc_copy,
 				   owner_.xpos(),
-				   owner_.ypos() + text->first_y - old_first,
+				   owner_.ypos() + text->top_y() - old_first,
 				   owner_.workWidth(),
-				   owner_.workHeight() + old_first - text->first_y,
+				   owner_.workHeight() + old_first - text->top_y(),
 				   owner_.xpos(),
 				   owner_.ypos());
 			// expose the area drawn
-			expose(0, owner_.workHeight() + old_first - text->first_y,
-			       owner_.workWidth(), text->first_y - old_first);
+			expose(0, owner_.workHeight() + old_first - text->top_y(),
+			       owner_.workWidth(), text->top_y() - old_first);
 		}
 	} else {
 		// make a dumb new-draw
Index: insets/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.585
diff -u -p -u -r1.585 ChangeLog
--- insets/ChangeLog	2003/03/06 10:02:39	1.585
+++ insets/ChangeLog	2003/03/06 19:17:49
@@ -1,3 +1,8 @@
+2003-03-06  Alfredo Braunstein  <[EMAIL PROTECTED]>
+
+	* insettext.C:
+	* insettabular.C: use LyXText::top_y() instead of LyXText::first_y
+
 2003-03-06  Lars Gullik Bjønnes  <[EMAIL PROTECTED]>
 
 	* insettext.C (updateLocal): un-const function
Index: insets/insettabular.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/insets/insettabular.C,v
retrieving revision 1.241
diff -u -p -u -r1.241 insettabular.C
--- insets/insettabular.C	2003/03/03 23:19:01	1.241
+++ insets/insettabular.C	2003/03/06 19:17:55
@@ -1080,10 +1080,10 @@ Inset::RESULT InsetTabular::localDispatc
 		}
 		int column = actcol;
 		unlockInsetInInset(bv, the_locking_inset);
-		if (bv->text->first_y + bv->painter().paperHeight() <
+		if (bv->text->top_y() + bv->painter().paperHeight() <
 		    (top_baseline + tabular->GetHeightOfTabular()))
 			{
-				bv->scrollDocView(bv->text->first_y + bv->painter().paperHeight());
+				bv->scrollDocView(bv->text->top_y() + bv->painter().paperHeight());
 				code = FULL;
 				actcell = tabular->GetCellBelow(first_visible_cell) + column;
 			} else {
@@ -1102,7 +1102,7 @@ Inset::RESULT InsetTabular::localDispatc
 		int column = actcol;
 		unlockInsetInInset(bv, the_locking_inset);
 		if (top_baseline < 0) {
-			bv->scrollDocView(bv->text->first_y - bv->painter().paperHeight());
+			bv->scrollDocView(bv->text->top_y() - bv->painter().paperHeight());
 			code = FULL;
 			if (top_baseline > 0)
 				actcell = column;
@@ -1495,9 +1495,9 @@ void InsetTabular::hideInsetCursor(Buffe
 void InsetTabular::fitInsetCursor(BufferView * bv) const
 {
 	if (the_locking_inset) {
-		int old_first_y = bv->text->first_y;
+		int old_top_y = bv->text->top_y();
 		the_locking_inset->fitInsetCursor(bv);
-		if (old_first_y != bv->text->first_y)
+		if (old_top_y != bv->text->top_y())
 			need_update = FULL;
 		return;
 	}
Index: insets/insettext.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.349
diff -u -p -u -r1.349 insettext.C
--- insets/insettext.C	2003/03/06 10:02:39	1.349
+++ insets/insettext.C	2003/03/06 19:17:59
@@ -458,11 +458,11 @@ void InsetText::draw(BufferView * bv, Ly
 		row = row->next();
 	}
 	if (y_offset < 0) {
-		lt->first_y = -y_offset;
+		lt->top_y(-y_offset);
 		first = y;
 		y_offset = 0;
 	} else {
-		lt->first_y = first;
+		lt->top_y(first);
 		first = 0;
 	}
 	if (cleared || (need_update&(INIT|FULL))) {
@@ -471,7 +471,7 @@ void InsetText::draw(BufferView * bv, Ly
 		while ((row != 0) && (yf < ph)) {
 			Row * prev = row->previous();
 			RowPainter rp(*bv, *lt, *row);
-			if (rp.paint(y + y_offset + first, int(x), y + lt->first_y, cleared))
+			if (rp.paint(y + y_offset + first, int(x), y + lt->top_y(), cleared))
 				lt->markChangeInDraw(bv, row, prev);
 			if (bv->text->status() == LyXText::CHANGED_IN_DRAW) {
 				lt->need_break_row = row;
@@ -1020,7 +1020,7 @@ void InsetText::lfunMousePress(FuncReque
 		lockInset(bv);
 
 	int tmp_x = cmd.x - drawTextXOffset;
-	int tmp_y = cmd.y + insetAscent - getLyXText(bv)->first_y;
+	int tmp_y = cmd.y + insetAscent - getLyXText(bv)->top_y();
 	Inset * inset = getLyXText(bv)->checkInsetHit(bv, tmp_x, tmp_y);
 
 	hideInsetCursor(bv);
@@ -1075,7 +1075,7 @@ void InsetText::lfunMousePress(FuncReque
 			lt = getLyXText(bv);
 			clear = true;
 		}
-		int old_first_y = lt->first_y;
+		int old_top_y = lt->top_y();
 
 		lt->setCursorFromCoordinates(bv, cmd.x - drawTextXOffset,
 					     cmd.y + insetAscent);
@@ -1098,7 +1098,7 @@ void InsetText::lfunMousePress(FuncReque
 		bv->owner()->setLayout(cpar(bv)->layout()->name());
 
 		// we moved the view we cannot do mouse selection in this case!
-		if (getLyXText(bv)->first_y != old_first_y)
+		if (getLyXText(bv)->top_y() != old_top_y)
 			no_selection = true;
 		old_par = cpar(bv);
 		// Insert primary selection with middle mouse
@@ -1129,7 +1129,7 @@ bool InsetText::lfunMouseRelease(FuncReq
 		return the_locking_inset->localDispatch(cmd1);
 
 	int tmp_x = cmd.x - drawTextXOffset;
-	int tmp_y = cmd.y + insetAscent - getLyXText(bv)->first_y;
+	int tmp_y = cmd.y + insetAscent - getLyXText(bv)->top_y();
 	Inset * inset = getLyXText(bv)->checkInsetHit(bv, tmp_x, tmp_y);
 	bool ret = false;
 	if (inset) {
@@ -2386,7 +2386,7 @@ void InsetText::resizeLyXText(BufferView
 		inset_y = ciy(bv) + drawTextYOffset;
 	}
 
-	t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y);
+	t->top_y(bv->screen().topCursorVisible(t->cursor, t->top_y()));
 	if (!owner()) {
 		const_cast<InsetText*>(this)->updateLocal(bv, FULL, false);
 		// this will scroll the screen such that the cursor becomes visible
@@ -2425,7 +2425,7 @@ void InsetText::reinitLyXText() const
 			inset_x = cix(bv) - top_x + drawTextXOffset;
 			inset_y = ciy(bv) + drawTextYOffset;
 		}
-		t->first_y = bv->screen().topCursorVisible(t->cursor, t->first_y);
+		t->top_y(bv->screen().topCursorVisible(t->cursor, t->top_y()));
 		if (!owner()) {
 			const_cast<InsetText*>(this)->updateLocal(bv, FULL, false);
 			// this will scroll the screen such that the cursor becomes visible

Reply via email to