}
+int BufferView::top_y() const
+{
+ return pimpl_->top_y();
+}
+
+
+void BufferView::top_y(int y)
+{
+ pimpl_->top_y(y);
+}
+
+
string const BufferView::getClipboard() const
{
return pimpl_->workarea().getClipboard();
/// return the owning main view
LyXView * owner() const;
+ /// return the visible top y
+ int top_y() const;
+
+ /// set the visible top y
+ void top_y(int);
+
/// resize event has happened
void resize();
}
+void BufferView::Pimpl::top_y(int y)
+{
+ top_y_ = y;
+}
+
+
+int BufferView::Pimpl::top_y() const
+{
+ return top_y_;
+}
+
+
void BufferView::Pimpl::buffer(Buffer * b)
{
lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
// set current buffer
buffer_ = b;
+ top_y_ = 0;
+
// if we're quitting lyx, don't bother updating stuff
if (quitting)
return;
resizeCurrentBuffer();
// FIXME: needed when ?
- bv_->text->top_y(screen().topCursorVisible(bv_->text));
+ top_y(screen().topCursorVisible(bv_->text));
// Buffer-dependent dialogs should be updated or
// hidden. This should go here because some dialogs (eg ToC)
bv_->theLockingInset(the_locking_inset);
}
- bv_->text->top_y(screen().topCursorVisible(bv_->text));
+ top_y(screen().topCursorVisible(bv_->text));
switchKeyMap();
owner_->busy(false);
LyXText const & t = *bv_->text;
lyxerr[Debug::GUI] << "Updating scrollbar: h " << t.height << ", top_y() "
- << t.top_y() << ", default height " << defaultRowHeight() << endl;
+ << top_y() << ", default height " << defaultRowHeight() << endl;
- workarea().setScrollbarParams(t.height, t.top_y(), defaultRowHeight());
+ workarea().setScrollbarParams(t.height, top_y(), defaultRowHeight());
}
screen().hideCursor();
- bv_->text->top_y(value);
+ top_y(value);
screen().redraw(*bv_);
if (!lyxrc.cursor_follows_scrollbar)
return;
int const height = defaultRowHeight();
- int const first = int((bv_->text->top_y() + height));
- int const last = int((bv_->text->top_y() + workarea().workHeight() - height));
+ int const first = top_y() + height;
+ int const last = top_y() + workarea().workHeight() - height;
LyXText * text = bv_->text;
if (text->cursor.y() < first)
int const line_height = defaultRowHeight();
// The new absolute coordinate
- int new_top_y = t->top_y() + lines * line_height;
+ int new_top_y = top_y() + lines * line_height;
// Restrict to a valid value
new_top_y = std::min(t->height - 4 * line_height, new_top_y);
scrollDocView(new_top_y);
// Update the scrollbar.
- workarea().setScrollbarParams(t->height, t->top_y(), defaultRowHeight());
+ workarea().setScrollbarParams(t->height, top_y(), defaultRowHeight());
}
// 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->top_y()
- text->top_y(new_y);
+ top_y(new_y);
//screen().draw();
update();
}
bool workAreaDispatch(FuncRequest const & ev);
/// a function should be executed
bool dispatch(FuncRequest const & ev);
+ ///
+ int top_y() const;
+ ///
+ void top_y(int y);
private:
+ /// the y coordinate of the top of the screen
+ int top_y_;
/// An error list (replaces the error insets)
ErrorList errorlist_;
/// add an error to the list
+
+2003-08-27 Alfredo Braunstein <abraunst@libero.it>
+
+ * lyxtext.h (top_y): move top_y from here
+ * text.C:
+ * text2.C:
+ * text3.C:
+ * BufferView.[Ch]:
+ * BufferView_pimpl.[Ch]: to here
+ * frontends/screen.C:
+ * insets/insettabular.C:
+ * insets/insettext.C: adjust
+ * rowpainter.[Ch] (paintRows): remove LyXText & argument
+
2003-08-27 Alfredo Braunstein <abraunst@libero.it>
* BufferView.[Ch]:
int h = ascent + descent;
int x = 0;
int y = 0;
- int const top_y = bv.text->top_y();
+ int const top_y = bv.top_y();
if (bv.theLockingInset()) {
// Would be nice to clean this up to make some understandable sense...
}
-bool LyXScreen::fitManualCursor(BufferView * /*bv*/, LyXText * text,
+bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text,
int /*x*/, int y, int asc, int desc)
{
int const vheight = workarea().workHeight();
- int newtop = text->top_y();
-
- if (y + desc - text->top_y() >= vheight)
+ int const topy = bv->top_y();
+ int newtop = topy;
+
+
+ if (y + desc - topy >= vheight)
newtop = y - 3 * vheight / 4; // the scroll region must be so big!!
- else if (y - asc < text->top_y() && text->top_y() > 0)
+ else if (y - asc < topy && topy > 0)
newtop = y - vheight / 4;
newtop = max(newtop, 0); // can newtop ever be < 0? (Lgb)
- if (newtop == text->top_y())
+ if (newtop == topy)
return false;
- text->top_y(newtop);
+ bv->top_y(newtop);
return true;
}
unsigned int LyXScreen::topCursorVisible(LyXText * text)
{
LyXCursor const & cursor = text->cursor;
- int top_y = text->top_y();
+ int top_y = text->bv()->top_y();
int newtop = top_y;
int const vheight = workarea().workHeight();
{
// Is a change necessary?
int const newtop = topCursorVisible(text);
- bool const result = (newtop != text->top_y());
- text->top_y(newtop);
+ bool const result = (newtop != bv->top_y());
+ bv->top_y(newtop);
return result;
}
hideCursor();
- int const y = paintText(bv, *bv.text);
+ int const y = paintText(bv);
// maybe we have to clear the screen at the bottom
int const y2 = workarea().workHeight();
clearSelection();
int column = actcol;
unlockInsetInInset(bv, the_locking_inset);
- if (bv->text->top_y() + bv->painter().paperHeight() <
+ if (bv->top_y() + bv->painter().paperHeight() <
top_baseline + tabular.getHeightOfTabular())
{
- bv->scrollDocView(bv->text->top_y() + bv->painter().paperHeight());
+ bv->scrollDocView(bv->top_y() + bv->painter().paperHeight());
actcell = tabular.getCellBelow(first_visible_cell) + column;
} else {
actcell = tabular.getFirstCellInRow(tabular.rows() - 1) + column;
int column = actcol;
unlockInsetInInset(bv, the_locking_inset);
if (top_baseline < 0) {
- bv->scrollDocView(bv->text->top_y() - bv->painter().paperHeight());
+ bv->scrollDocView(bv->top_y() - bv->painter().paperHeight());
if (top_baseline > 0)
actcell = column;
else
lockInset(bv);
int tmp_x = cmd.x - drawTextXOffset;
- int tmp_y = cmd.y + dim_.asc - getLyXText(bv)->top_y();
+ int tmp_y = cmd.y + dim_.asc - bv->top_y();
InsetOld * inset = getLyXText(bv)->checkInsetHit(tmp_x, tmp_y);
if (the_locking_inset) {
localDispatch(FuncRequest(bv, LFUN_COPY));
paste_internally = true;
}
- int old_top_y = text_.top_y();
+ int old_top_y = bv->top_y();
text_.setCursorFromCoordinates(cmd.x - drawTextXOffset,
cmd.y + dim_.asc);
bv->owner()->setLayout(cpar()->layout()->name());
// we moved the view we cannot do mouse selection in this case!
- if (getLyXText(bv)->top_y() != old_top_y)
+ if (bv->top_y() != old_top_y)
no_selection = true;
old_par = cpar();
// Insert primary selection with middle mouse
return the_locking_inset->localDispatch(cmd1);
int tmp_x = cmd.x - drawTextXOffset;
- int tmp_y = cmd.y + dim_.asc - getLyXText(bv)->top_y();
+ int tmp_y = cmd.y + dim_.asc - bv->top_y();
InsetOld * inset = getLyXText(bv)->checkInsetHit(tmp_x, tmp_y);
bool ret = false;
if (inset) {
public:
/// update all cached row positions
void updateRowPositions();
- /// get the y coord. of the top of the screen (relative to doc start)
- int top_y() const;
- /// set the y coord. of the top of the screen (relative to doc start)
- void top_y(int newy);
- /// set the anchoring row. top_y will be computed relative to this
- void anchor_row(RowList::iterator rit);
///
InsetText * inset_owner;
///
if (row == rit)
active = true;
if (active) {
- RowPainter painter(bv, text, pit, row, y + yo, xo, y + text.top_y());
+ RowPainter painter(bv, text, pit, row, y + yo, xo, y + bv.top_y());
painter.paint();
y += row->height();
if (yy + y >= y2)
} // namespace anon
-int paintText(BufferView & bv, LyXText & text)
+int paintText(BufferView & bv)
{
- int const topy = text.top_y();
+ int const topy = bv.top_y();
ParagraphList::iterator pit;
- RowList::iterator rit = text.getRowNearY(topy, pit);
+ RowList::iterator rit = bv.text->getRowNearY(topy, pit);
int y = rit->y() - topy;
- return paintRows(bv, text, pit, rit, 0, y, y, 0);
+ return paintRows(bv, *bv.text, pit, rit, 0, y, y, 0);
}
y += rit->height();
text.nextRow(pit, rit);
}
- if (y_offset < 0) {
- text.top_y(-y_offset);
+ if (y_offset < 0)
paintRows(bv, text, pit, rit, x, 0, y, y);
- } else {
- text.top_y(y - y_offset);
+ else
paintRows(bv, text, pit, rit, x, 0, y_offset, y_offset);
- }
}
int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp);
/// paint the rows of the main text, return last drawn y value
-int paintText(BufferView & bv, LyXText & text);
+int paintText(BufferView & bv);
/// paint the rows of a text inset
void paintTextInset(BufferView & bv, LyXText & text, int x, int y);
}
-int LyXText::top_y() const
-{
- return anchor_y_;
-}
-
-
-void LyXText::top_y(int newy)
-{
- anchor_y_ = newy;
- lyxerr[Debug::GUI] << "changing reference to offset: " << anchor_y_ << endl;
-}
-
-
int LyXText::workWidth() const
{
return inset_owner ? inset_owner->textWidth() : bv()->workWidth();
cur.ix(int(x));
} else
cur.ix(cur.x());
-/* We take out this for the time being because 1) the redraw code is not
- prepared to this yet and 2) because some good policy has yet to be decided
- while editting: for instance how to act on rows being created/deleted
- because of DEPM.
-*/
-#if 0
- //if the cursor is in a visible row, anchor to it
- int topy = top_y();
- if (topy < y && y < topy + bv()->workHeight())
- anchor_row(row);
-#endif
}
int y = cursor.y() - cursorRow()->baseline() - 1;
setCursorFromCoordinates(x, y);
if (!selecting) {
- int topy = top_y();
+ int topy = bv_owner->top_y();
int y1 = cursor.iy() - topy;
int y2 = y1;
y -= topy;
int y = cursor.y() - cursorRow()->baseline() + cursorRow()->height() + 1;
setCursorFromCoordinates(x, y);
if (!selecting && cursorRow() == cursorIRow()) {
- int topy = top_y();
+ int topy = bv_owner->top_y();
int y1 = cursor.iy() - topy;
int y2 = y1;
y -= topy;
InsetOld * LyXText::checkInsetHit(int & x, int & y)
{
- int y_tmp = y + top_y();
+ int y_tmp = y + bv_owner->top_y();
LyXCursor cur;
setCursorFromCoordinates(cur, x, y_tmp);
void LyXText::cursorPrevious()
{
- int y = top_y();
+ int y = bv_owner->top_y();
RowList::iterator rit = cursorRow();
ParagraphList::iterator pit = cursor.par();
previousRow(pit, rit);
setCursor(cur, pit, rit->pos(), false);
- if (cur.y() > top_y())
+ if (cur.y() > bv_owner->top_y())
cursorUp(true);
bv()->updateScrollbar();
}
void LyXText::cursorNext()
{
- int topy = top_y();
+ int topy = bv_owner->top_y();
RowList::iterator rit = cursorRow();
if (rit == lastRow()) {
int y = cursor.y() - rit->baseline() + cursorRow()->height();
if (y > topy + bv()->workHeight())
- bv()->updateScrollbar();
+ bv_owner->updateScrollbar();
return;
}
- int y = topy + bv()->workHeight();
+ int y = topy + bv_owner->workHeight();
if (inset_owner && !topy) {
- y -= (bv()->text->cursor.iy()
- - bv()->text->top_y()
- + bv()->theLockingInset()->insetInInsetY());
+ y -= (bv_owner->text->cursor.iy()
+ - bv_owner->top_y()
+ + bv_owner->theLockingInset()->insetInInsetY());
}
ParagraphList::iterator dummypit;
finishUndo();
int new_y;
- if (rit == bv()->text->cursorRow()) {
+ if (rit == bv_owner->text->cursorRow()) {
// we have a row which is taller than the workarea. The
// simplest solution is to move to the next row instead.
cursorDown(true);
// 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->top_y() + bv->workHeight();
+ new_y = bv->top_y() + bv->workHeight();
#endif
} else {
if (inset_owner) {
nextRow(pit, rit);
LyXCursor cur;
setCursor(cur, pit, rit->pos(), false);
- if (cur.y() < top_y() + bv()->workHeight())
+ if (cur.y() < bv_owner->top_y() + bv()->workHeight())
cursorDown(true);
bv()->updateScrollbar();
}
int start_x = inset_x + tli->scroll();
FuncRequest cmd1 = cmd;
cmd1.x = cmd.x - start_x;
- cmd1.y = cmd.y - cursor.iy() + bv->text->top_y();
+ cmd1.y = cmd.y - cursor.iy() + bv->top_y();
tli->localDispatch(cmd1);
break;
}
}
RowList::iterator cursorrow = bv->text->cursorRow();
- bv->text->setCursorFromCoordinates(cmd.x, cmd.y + bv->text->top_y());
+ bv->text->setCursorFromCoordinates(cmd.x, cmd.y + bv->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
paste_internally = true;
}
- int const screen_first = bv->text->top_y();
+ int const screen_first = bv->top_y();
if (bv->theLockingInset()) {
// We are in inset locking mode