diff --git a/src/ChangeLog b/src/ChangeLog index 6f2bad6d21..f6c5a45dca 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2003-11-21 Alfredo Braunstein + + * lyxtext.h: x0_,y0_ -> xo_,yo_ + * text2.C (cursorUp, cursorDown): adjust + some cursorRow use + * text3.C (checkInsetHit): fix coordinates using absolute xo_,yo_ + * rowpainter.C (paintRows): paint full paragraphs + 2003-11-20 Alfredo Braunstein * text2.C (cursorUp, cursorDown): small fix (insettext::edit takes diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index a2dc0c8560..ab6a38e7b4 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2003-11-21 Alfredo Braunstein + + * insettext.C (edit): x0_,y0_ -> xo_,yo_ + 2003-11-20 Alfredo Braunstein * insettext.C (draw): sets LyXText absolute coordinates diff --git a/src/insets/insettext.C b/src/insets/insettext.C index e90b8d1898..5235866cab 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -258,8 +258,8 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const x += TEXT_TO_INSET_OFFSET; - text_.x0_ = x; - text_.y0_ = y - text_.firstRow()->ascent_of_text() + bv->top_y(); + text_.xo_ = x; + text_.yo_ = y - text_.firstRow()->ascent_of_text() + bv->top_y(); paintTextInset(*bv, text_, x, y); @@ -344,8 +344,8 @@ void InsetText::edit(BufferView * bv, int x, int y) lyxerr << "InsetText::edit xy" << endl; old_par = -1; sanitizeEmptyText(bv); - text_.setCursorFromCoordinates(x - text_.x0_, y + bv->top_y() - - text_.y0_); + text_.setCursorFromCoordinates(x - text_.xo_, y + bv->top_y() + - text_.yo_); text_.clearSelection(); finishUndo(); diff --git a/src/lyxtext.h b/src/lyxtext.h index 62ceb7071c..06b6aedf1f 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -472,8 +472,8 @@ private: public: /// absolute document pixel coordinates of this LyXText - int x0_; - int y0_; + int xo_; + int yo_; }; /// return the default height of a row in pixels, considering font zoom diff --git a/src/rowpainter.C b/src/rowpainter.C index 4541b61b39..9f5dde9d1e 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -993,12 +993,12 @@ int paintRows(BufferView const & bv, LyXText const & text, RowPainter painter(bv, text, pit, row, y + yo, xo, y + bv.top_y()); painter.paint(); y += row->height(); - if (yy + y >= y2) - return y; } else { //lyxerr << " paintRows: row: " << &*row << " ignored" << endl; } } + if (yy + y >= y2) + return y; } return y; diff --git a/src/text2.C b/src/text2.C index e7ee7adf0d..c9046dfc68 100644 --- a/src/text2.C +++ b/src/text2.C @@ -74,7 +74,7 @@ LyXText::LyXText(BufferView * bv, InsetText * inset, bool ininset, ParagraphList & paragraphs) : height(0), width(0), inset_owner(inset), bv_owner(bv), in_inset_(ininset), paragraphs_(¶graphs), - cache_pos_(-1), x0_(0), y0_(0) + cache_pos_(-1), xo_(0), yo_(0) {} @@ -1300,6 +1300,7 @@ void LyXText::setCursor(LyXCursor & cur, paroffset_type par, ParagraphList::iterator pit = getPar(par); Row const & row = *pit->getRow(pos); + int y = pit->y + row.y_offset(); // y is now the beginning of the cursor row @@ -1404,7 +1405,7 @@ void LyXText::setCursorIntern(paroffset_type par, pos_type pos, bool setfont, bool boundary) { setCursor(cursor, par, pos, boundary); - bv()->x_target(cursor.x() + x0_); + bv()->x_target(cursor.x() + xo_); if (setfont) setCurrentFont(); } @@ -1708,33 +1709,32 @@ bool LyXText::cursorRight(bool internal) void LyXText::cursorUp(bool selecting) { - ParagraphList::iterator cpit = cursorPar(); - Row const & crow = *cpit->getRow(cursor.pos()); - int x = bv()->x_target() - x0_; - int y = cursor.y() - crow.baseline() - 1; + Row const & row = *cursorRow(); + int x = bv()->x_target() - xo_; + int y = cursor.y() - row.baseline() - 1; setCursorFromCoordinates(x, y); + if (!selecting) { - y += y0_ - bv()->top_y(); - lyxerr << "y:" << y << " y0: " << y0_ << endl; - InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y); + int y_abs = y + yo_ - bv()->top_y(); + InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y_abs); if (inset_hit && isHighlyEditableInset(inset_hit)) - inset_hit->edit(bv(), bv()->x_target(), y); + inset_hit->edit(bv(), bv()->x_target(), y_abs); } } void LyXText::cursorDown(bool selecting) { - ParagraphList::iterator cpit = cursorPar(); - Row const & crow = *cpit->getRow(cursor.pos()); - int x = bv()->x_target() - x0_; - int y = cursor.y() - crow.baseline() + crow.height() + 1; + Row const & row = *cursorRow(); + int x = bv()->x_target() - xo_; + int y = cursor.y() - row.baseline() + row.height() + 1; setCursorFromCoordinates(x, y); + if (!selecting) { - y += y0_ - bv()->top_y(); - InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y); + int y_abs = y + yo_ - bv()->top_y(); + InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y_abs); if (inset_hit && isHighlyEditableInset(inset_hit)) - inset_hit->edit(bv(), bv()->x_target(), y); + inset_hit->edit(bv(), bv()->x_target(), y_abs); } } diff --git a/src/text3.C b/src/text3.C index 77ae09de38..cb721b8486 100644 --- a/src/text3.C +++ b/src/text3.C @@ -260,7 +260,8 @@ InsetOld * LyXText::checkInsetHit(int x, int y) ParagraphList::iterator end; getParsInRange(ownerParagraphs(), - bv()->top_y(), bv()->top_y() + bv()->workHeight(), + bv()->top_y() - yo_, + bv()->top_y() - yo_ + bv()->workHeight(), pit, end); lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl; @@ -365,8 +366,8 @@ void LyXText::cursorPrevious() RowList::iterator crit = cursorRow(); - int x = bv()->x_target() - x0_; - int y = bv()->top_y() - y0_; + int x = bv()->x_target() - xo_; + int y = bv()->top_y() - yo_; setCursorFromCoordinates(x, y); if (crit == cursorRow()) { @@ -384,8 +385,8 @@ void LyXText::cursorNext() { RowList::iterator crit = cursorRow(); - int x = bv()->x_target() - x0_; - int y = bv()->top_y() + bv()->workHeight() - y0_; + int x = bv()->x_target() - xo_; + int y = bv()->top_y() + bv()->workHeight() - yo_; setCursorFromCoordinates(x, y); if (crit == cursorRow()) { @@ -1242,9 +1243,9 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd) // FIXME: shouldn't be top-text-specific if (cursorrow == cursorRow() && !in_inset_) { if (cmd.y - bv->top_y() >= bv->workHeight()) - cursorDown(false); + cursorDown(true); else if (cmd.y - bv->top_y() < 0) - cursorUp(false); + cursorUp(true); } setSelection(); break; @@ -1292,7 +1293,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd) setCursorFromCoordinates(cmd.x, cmd.y); selection.cursor = cursor; finishUndo(); - bv->x_target(cursor.x() + x0_); + bv->x_target(cursor.x() + xo_); if (bv->fitCursor()) selection_possible = false;