From 43637efd25e8dcf90d5bd53e133dfdac31b837f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 15 Aug 2003 13:12:24 +0000 Subject: [PATCH] better fix for anchorrow problem git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7555 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/qscreen.C | 3 ++- src/lyxtext.h | 9 ++------- src/text.C | 33 +++------------------------------ src/text2.C | 32 ++++++++------------------------ 4 files changed, 15 insertions(+), 62 deletions(-) diff --git a/src/frontends/qt2/qscreen.C b/src/frontends/qt2/qscreen.C index 02e4e66db6..6afb4444ba 100644 --- a/src/frontends/qt2/qscreen.C +++ b/src/frontends/qt2/qscreen.C @@ -76,7 +76,8 @@ void QScreen::draw(LyXText * text, BufferView * bv, unsigned int y) text->top_y(y); - drawFromTo(text, bv, 0, owner_.height(), 0, 0); + // not needed in the xforms frontend anymore + //drawFromTo(text, bv, 0, owner_.height(), 0, 0); repaint(); owner_.getPainter().end(); diff --git a/src/lyxtext.h b/src/lyxtext.h index 59140c7f89..b0374573ed 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -66,13 +66,8 @@ public: /// our buffer's default layout font LyXFont defaultfont_; private: - /** the 'anchor' row: the position of this row remains constant - * with respect to the top of the screen - */ - RowList::iterator anchor_row_; - /** the pixel offset with respect to this row of top_y - */ - int anchor_row_offset_; + /// offset of dran area to document start. + int anchor_y_; public: /// update all cached row positions void updateRowPositions(); diff --git a/src/text.C b/src/text.C index ebbe4e107d..1cd7375d0d 100644 --- a/src/text.C +++ b/src/text.C @@ -97,10 +97,7 @@ void LyXText::updateRowPositions() int LyXText::top_y() const { - if (anchor_row_ == endRow()) - return 0; - - return anchor_row_->y() + anchor_row_offset_; + return anchor_y_; } @@ -109,32 +106,8 @@ void LyXText::top_y(int newy) if (ownerParagraphs().begin()->rows.empty()) return; - if (isInInset()) { - anchor_row_ = firstRow(); - anchor_row_offset_ = newy; - return; - } - - lyxerr[Debug::GUI] << "setting top y = " << newy << endl; - - int y = newy; - ParagraphList::iterator dummypit; - anchor_row_ = getRowNearY(y, dummypit); - anchor_row_offset_ = newy - y; - lyxerr[Debug::GUI] << "changing reference to row: " << &*anchor_row_ - << " offset: " << anchor_row_offset_ << endl; -} - - -void LyXText::anchor_row(RowList::iterator rit) -{ - int old_y = top_y(); - anchor_row_offset_ = 0; - anchor_row_ = rit; - anchor_row_offset_ = old_y - top_y(); - lyxerr[Debug::GUI] << "anchor_row(): changing reference to row: " - << &*anchor_row_ << " offset: " - << anchor_row_offset_ << endl; + anchor_y_ = newy; + lyxerr[Debug::GUI] << "changing reference to offset: " << anchor_y_ << endl; } diff --git a/src/text2.C b/src/text2.C index b86338ad45..74219602a0 100644 --- a/src/text2.C +++ b/src/text2.C @@ -60,19 +60,15 @@ using lyx::pos_type; LyXText::LyXText(BufferView * bv) - : height(0), width(0), anchor_row_offset_(0), + : height(0), width(0), anchor_y_(0), inset_owner(0), the_locking_inset(0), bv_owner(bv) -{ - anchor_row_ = endRow(); -} +{} LyXText::LyXText(BufferView * bv, InsetText * inset) - : height(0), width(0), anchor_row_offset_(0), + : height(0), width(0), anchor_y_(0), inset_owner(inset), the_locking_inset(0), bv_owner(bv) -{ - anchor_row_ = endRow(); -} +{} void LyXText::init(BufferView * bview) @@ -87,8 +83,7 @@ void LyXText::init(BufferView * bview) width = 0; height = 0; - anchor_row_ = endRow(); - anchor_row_offset_ = 0; + anchor_y_ = 0; current_font = getFont(beg, 0); @@ -559,12 +554,9 @@ void LyXText::redoParagraph(ParagraphList::iterator pit) RowList::iterator end = pit->rows.end(); // remove rows of paragraph - int anchor_cnt = -1; - for (int i = 0; rit != end; ++rit, ++i) { - if (rit == anchor_row_) - anchor_cnt = i; + for (int i = 0; rit != end; ++rit, ++i) height -= rit->height(); - } + pit->rows.clear(); // rebreak the paragraph @@ -589,13 +581,6 @@ void LyXText::redoParagraph(ParagraphList::iterator pit) setHeightOfRow(pit, tmprow); } - if (anchor_cnt == -1) { - if (anchor_cnt >= pit->rows.size()) - anchor_cnt = pit->rows.size(); - anchor_row_ = pit->rows.begin(); - advance(anchor_row_, anchor_cnt); - } - //lyxerr << "redoParagraph: " << pit->rows.size() << " rows\n"; } @@ -617,8 +602,7 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim) width = 0; height = 0; - anchor_row_ = endRow(); - anchor_row_offset_ = 0; + //anchor_y_ = 0; ParagraphList::iterator pit = ownerParagraphs().begin(); ParagraphList::iterator end = ownerParagraphs().end();