]> git.lyx.org Git - features.git/commitdiff
xy0_->xyo_ + two fixes
authorAlfredo Braunstein <abraunst@lyx.org>
Fri, 21 Nov 2003 08:35:15 +0000 (08:35 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Fri, 21 Nov 2003 08:35:15 +0000 (08:35 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8111 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/insets/ChangeLog
src/insets/insettext.C
src/lyxtext.h
src/rowpainter.C
src/text2.C
src/text3.C

index 6f2bad6d21d6daf0e93d1216513e9c46a2dc8149..f6c5a45dca366046b0467507c15ef5f557afb99c 100644 (file)
@@ -1,3 +1,10 @@
+2003-11-21  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * 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  <abraunst@lyx.org>
 
        * text2.C (cursorUp, cursorDown): small fix (insettext::edit takes
index a2dc0c85602267493511c4e7d6c2fd0198621bd7..ab6a38e7b4af534d901d1bd6b2f99f043cabe99b 100644 (file)
@@ -1,3 +1,7 @@
+2003-11-21  Alfredo Braunstein  <abraunst@lyx.org>
+
+       * insettext.C (edit): x0_,y0_ -> xo_,yo_
+
 2003-11-20  Alfredo Braunstein  <abraunst@lyx.org>
 
        * insettext.C (draw): sets LyXText absolute coordinates
index e90b8d18986fda0382d724936fcc94a2bbea7a40..5235866cab02ca76d5a6d3b28afcdf674bd3069e 100644 (file)
@@ -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();
 
index 62ceb7071cf9c2a338226492290b0bef9e40ac65..06b6aedf1f3237d2c289f027d6d2a0fc1a4c8745 100644 (file)
@@ -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
index 4541b61b3936abdfd618476b71121fe182bb9ee8..9f5dde9d1e23326fa491a04b25036aca5416820c 100644 (file)
@@ -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;
index e7ee7adf0d2c6bcc1648b56c03f8810c9cc898c6..c9046dfc680a08f6ff38e8a293b0abce6848fb3d 100644 (file)
@@ -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_(&paragraphs),
-         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);
        }
 }
 
index 77ae09de389ee2c48813e8e03ee4b8ba7756376f..cb721b8486942cde0f790aee49451c6207a179dc 100644 (file)
@@ -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;