]> git.lyx.org Git - lyx.git/commitdiff
100 lines moved, 33 dead.
authorAndré Pönitz <poenitz@gmx.net>
Wed, 28 Aug 2002 12:09:19 +0000 (12:09 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 28 Aug 2002 12:09:19 +0000 (12:09 +0000)
Just for the record:

1.2.1:
  3666    8203   85497 BufferView_pimpl.C
  2693    8230   72506 text2.C
  6359   16433  158003 total

1.3cvs equivalent:
  1451    3413   34098 BufferView_pimpl.C
  2407    7391   64931 text2.C
  1588    4040   39668 text3.C
    94     203    2167 factory.C
  5540   15047  140864 total

so we saved over 800 lines by just moving stuff around...

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5134 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView.h
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/insets/insettext.C
src/lyxtext.h
src/text2.C
src/text3.C

index a89be01ea82fc1b2308c829d0d6f86fadc106563..53e1ffd55cfcd67d5f1e1096f905767b406834d9 100644 (file)
@@ -110,12 +110,6 @@ void BufferView::scrollDocView(int value)
 }
 
 
-Inset * BufferView::checkInsetHit(LyXText * text, int & x, int & y)
-{
-       return pimpl_->checkInsetHit(text, x, y);
-}
-
-
 void BufferView::redoCurrentBuffer()
 {
        pimpl_->redoCurrentBuffer();
index 8d72e59c0c50569ef4bd798a69763499a30f5cb0..712bdba8ba6c3f93b3a40f7072d243ecfc75c51c 100644 (file)
@@ -78,8 +78,6 @@ public:
        ///
        void updateScrollbar();
        ///
-       Inset * checkInsetHit(LyXText *, int & x, int & y);
-       ///
        void redoCurrentBuffer();
        ///
        bool available() const;
index 01bbd70f642223418ad6b9b5a2931c54b1725266..696f9197c14093ed3baec1bc7fa8a8cd03040c0b 100644 (file)
@@ -41,7 +41,6 @@
 #include "ParagraphParameters.h"
 #include "undo_funcs.h"
 #include "funcrequest.h"
-#include "box.h"
 
 #include "insets/insetbib.h"
 #include "insets/insettext.h"
@@ -104,71 +103,6 @@ boost::signals::connection selectioncon;
 boost::signals::connection lostcon;
 
 
-       /**
-        * Return the on-screen dimensions of the inset at the cursor.
-        * Pre-condition: the cursor must be at an inset.
-        */
-Box insetDimensions(BufferView * bv, LyXText const & text,
-                                      LyXCursor const & cursor)
-{
-       Paragraph /*const*/ & par = *cursor.par();
-       pos_type const pos = cursor.pos();
-
-       lyx::Assert(par.getInset(pos));
-
-       Inset const & inset(*par.getInset(pos));
-
-       LyXFont const & font = text.getFont(bv->buffer(), &par, pos);
-
-       int const width = inset.width(bv, font);
-       int const inset_x = font.isVisibleRightToLeft()
-               ? (cursor.ix() - width) : cursor.ix();
-
-       return Box(
-               inset_x + inset.scroll(),
-               inset_x + width,
-               cursor.iy() - inset.ascent(bv, font),
-               cursor.iy() + inset.descent(bv, font));
-}
-
-
-/**
- * check if the given co-ordinates are inside an inset at the
- * given cursor, if one exists. If so, the inset is returned,
- * and the co-ordinates are made relative. Otherwise, 0 is returned.
- */
-Inset * checkInset(BufferView * bv, LyXText const & text,
-                                     LyXCursor const & cursor, int & x, int & y)
-{
-       pos_type const pos = cursor.pos();
-       Paragraph /*const*/ & par(*cursor.par());
-
-       if (pos >= par.size() || !par.isInset(pos)) {
-               return 0;
-       }
-
-       Inset /*const*/ * inset = par.getInset(pos);
-
-       if (!isEditableInset(inset)) 
-               return 0;
-
-       Box b = insetDimensions(bv, text, cursor);
-
-       if (!b.contained(x, y)) {
-               lyxerr[Debug::GUI] << "Missed inset at x,y " << x << "," << y
-                       << " box " << b << endl;
-               return 0;
-       }
-
-       text.setCursor(bv, &par, pos, true);
-
-       x -= b.x1;
-       // The origin of an inset is on the baseline
-       y -= text.cursor.iy();
-
-       return inset;
-}
-
 } // anon namespace
 
 
@@ -514,37 +448,6 @@ void BufferView::Pimpl::selectionLost()
 }
 
 
-
-Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y)
-{
-       int y_tmp = y + text->first_y;
-
-       LyXCursor cursor;
-       text->setCursorFromCoordinates(bv_, cursor, x, y_tmp);
-
-       Inset * inset = checkInset(bv_, *text, cursor, x, y_tmp);
-
-       if (inset) {
-               y = y_tmp;
-               return inset;
-       }
-
-       // look at previous position
-       if (cursor.pos() == 0) {
-               return 0;
-       }
-
-       // move back one
-       text->setCursor(bv_, cursor, cursor.par(), cursor.pos() - 1, true);
-
-       inset = checkInset(bv_, *text, cursor, x, y_tmp);
-       if (inset) {
-               y = y_tmp;
-       }
-       return inset;
-}
-
-
 void BufferView::Pimpl::workAreaResize()
 {
        static int work_area_width;
index b1832f9b3603001d605e30f2a879cb35b67f05bf..15f320bf8f905693c15ac957505665f94194bd14 100644 (file)
@@ -62,12 +62,6 @@ struct BufferView::Pimpl : public boost::signals::trackable {
        void updateScrollbar();
        ///
        void scrollDocView(int value);
-       /**
-        * Returns an inset if inset was hit, or 0 if not.
-        *
-        * If hit, the coordinates are changed relative to the inset.
-        */
-       Inset * checkInsetHit(LyXText *, int & x, int & y);
        /// wheel mouse scroll
        int scroll(long time);
        ///
index 7a8111fe2f60d87460e55851bee7032b211a07d5..bb7c5221fd3daf97a032e6ca4225ed2279a0ef39 100644 (file)
@@ -1004,7 +1004,7 @@ void InsetText::lfunMousePress(FuncRequest const & cmd)
 
        int tmp_x = cmd.x - drawTextXOffset;
        int tmp_y = cmd.y + insetAscent - getLyXText(bv)->first_y;
-       Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y);
+       Inset * inset = getLyXText(bv)->checkInsetHit(bv, tmp_x, tmp_y);
 
        hideInsetCursor(bv);
        if (the_locking_inset) {
@@ -1113,7 +1113,7 @@ bool InsetText::lfunMouseRelease(FuncRequest const & cmd)
 
        int tmp_x = cmd.x - drawTextXOffset;
        int tmp_y = cmd.y + insetAscent - getLyXText(bv)->first_y;
-       Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y);
+       Inset * inset = getLyXText(bv)->checkInsetHit(bv, tmp_x, tmp_y);
        bool ret = false;
        if (inset) {
                if (isHighlyEditableInset(inset))
@@ -2050,7 +2050,7 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
        x -= drawTextXOffset;
        int dummyx = x;
        int dummyy = y + insetAscent;
-       Inset * inset = bv->checkInsetHit(getLyXText(bv), dummyx, dummyy);
+       Inset * inset = getLyXText(bv)->checkInsetHit(bv, dummyx, dummyy);
        // we only do the edit() call if the inset was hit by the mouse
        // or if it is a highly editable inset. So we should call this
        // function from our own edit with button < 0.
index 3f8dc0569d21ce658129333e3b60d9a617ce5cd9..01ffb481f796f8e00b9bd041dcdc057d1314907a 100644 (file)
@@ -624,6 +624,12 @@ public:
        void updateCounters(BufferView *) const;
        /// 
        void update(BufferView * bv, bool changed = true);
+       /**
+        * Returns an inset if inset was hit, or 0 if not.
+        * If hit, the coordinates are changed relative to the inset.
+        */
+       Inset * checkInsetHit(BufferView * bv, int & x, int & y) const;
+
 private:
        ///
        void setCounter(Buffer const *, Paragraph * par) const;
index 228a5039c65bbe70b09fc362a5e7569c35e4d0d8..984a3f4cad759ef3edfd5bac568430c76f0a5230 100644 (file)
@@ -2078,8 +2078,7 @@ void LyXText::cursorUp(BufferView * bview, bool selecting) const
                int y1 = cursor.iy() - first_y;
                int y2 = y1;
                y -= first_y;
-               Inset * inset_hit =
-                       bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
+               Inset * inset_hit = checkInsetHit(bview, x, y1);
                if (inset_hit && isHighlyEditableInset(inset_hit)) {
                        inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none);
                }
@@ -2102,8 +2101,7 @@ void LyXText::cursorDown(BufferView * bview, bool selecting) const
                int y1 = cursor.iy() - first_y;
                int y2 = y1;
                y -= first_y;
-               Inset * inset_hit =
-                       bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
+               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 f4a50ab3e36242533c6208cb28710d6d98c03d90..13b5db34b058af9fa78a7eddf27c90611a1c0c63 100644 (file)
@@ -23,6 +23,7 @@
 #include "gettext.h"
 #include "factory.h"
 #include "intl.h"
+#include "box.h"
 #include "language.h"
 #include "support/lstrings.h"
 #include "frontends/LyXView.h"
@@ -87,6 +88,80 @@ namespace {
                bv->owner()->view_state_changed();
        }
 
+       // check if the given co-ordinates are inside an inset at the
+       // given cursor, if one exists. If so, the inset is returned,
+       // and the co-ordinates are made relative. Otherwise, 0 is returned.
+       Inset * checkInset(BufferView * bv, LyXText const & text, int & x, int & y)
+       {
+               LyXCursor const & cursor = text.cursor;
+               lyx::pos_type const pos = cursor.pos();
+               Paragraph /*const*/ & par = *cursor.par();
+
+               if (pos >= par.size() || !par.isInset(pos))
+                       return 0;
+
+               Inset /*const*/ * inset = par.getInset(pos);
+
+               if (!isEditableInset(inset)) 
+                       return 0;
+
+               // get inset dimensions
+               lyx::Assert(par.getInset(pos));
+
+               LyXFont const & font = text.getFont(bv->buffer(), &par, pos);
+
+               int const width = inset->width(bv, font);
+               int const inset_x = font.isVisibleRightToLeft()
+                       ? (cursor.ix() - width) : cursor.ix();
+
+               Box b(
+                       inset_x + inset->scroll(),
+                       inset_x + width,
+                       cursor.iy() - inset->ascent(bv, font),
+                       cursor.iy() + inset->descent(bv, font));
+
+               if (!b.contained(x, y)) {
+                       lyxerr[Debug::GUI] << "Missed inset at x,y " << x << "," << y
+                               << " box " << b << endl;
+                       return 0;
+               }
+
+               text.setCursor(bv, &par, pos, true);
+
+               x -= b.x1;
+               // The origin of an inset is on the baseline
+               y -= text.cursor.iy();
+
+               return inset;
+       }
+
+} // anon namespace
+
+
+Inset * LyXText::checkInsetHit(BufferView * bv, int & x, int & y) const
+{
+       int y_tmp = y + first_y;
+
+       LyXCursor cursor;
+       setCursorFromCoordinates(bv, cursor, x, y_tmp);
+
+       Inset * inset = checkInset(bv, *this, x, y_tmp);
+       if (inset) {
+               y = y_tmp;
+               return inset;
+       }
+
+       // look at previous position
+       if (cursor.pos() == 0)
+               return 0;
+
+       // move back one
+       setCursor(bv, cursor, cursor.par(), cursor.pos() - 1, true);
+
+       inset = checkInset(bv, *this, x, y_tmp);
+       if (inset)
+               y = y_tmp;
+       return inset;
 }
 
 
@@ -1231,16 +1306,15 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        #endif
                // This is to allow jumping over large insets
                if (cursorrow == bv->text->cursor.row()) {
-                       if (cmd.y >= int(bv->workarea().workHeight())) {
+                       if (cmd.y >= int(bv->workarea().workHeight()))
                                bv->text->cursorDown(bv, false);
-                       } else if (cmd.y < 0) {
+                       else if (cmd.y < 0)
                                bv->text->cursorUp(bv, false);
-                       }
                }
 
+               // Maybe an empty line was deleted
                if (!bv->text->selection.set())
-                       bv->update(bv->text, BufferView::UPDATE); // Maybe an empty line was deleted
-
+                       bv->update(bv->text, BufferView::UPDATE);
                bv->text->setSelection(bv);
                bv->screen().toggleToggle(bv->text, bv);
                bv->fitCursor();
@@ -1269,7 +1343,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
 
                int x = cmd.x;
                int y = cmd.y;
-               Inset * inset_hit = bv->checkInsetHit(bv->text, x, y);
+               Inset * inset_hit = bv->text->checkInsetHit(bv, x, y);
 
                // Middle button press pastes if we have a selection
                // We do this here as if the selection was inside an inset
@@ -1369,7 +1443,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                // inset, inset_hit is 0, and inset_x == x, inset_y == y.
                int x = cmd.x;
                int y = cmd.y;
-               Inset * inset_hit = bv->checkInsetHit(bv->text, x, y);
+               Inset * inset_hit = bv->text->checkInsetHit(bv, x, y);
 
                if (bv->theLockingInset()) {
                        // We are in inset locking mode.