]> git.lyx.org Git - lyx.git/commitdiff
7 out
authorAndré Pönitz <poenitz@gmx.net>
Tue, 27 Aug 2002 16:16:17 +0000 (16:16 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 27 Aug 2002 16:16:17 +0000 (16:16 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5126 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/BufferView_pimpl.h

index 737d6aaea2483700f2a6ef8aecab3dde69d1350c..c38baae6b813ac41e0a62fcd746219ef72c98789 100644 (file)
@@ -40,6 +40,7 @@
 #include "ParagraphParameters.h"
 #include "undo_funcs.h"
 #include "funcrequest.h"
+#include "box.h"
 
 #include "insets/insetbib.h"
 #include "insets/insettext.h"
@@ -110,6 +111,72 @@ boost::signals::connection kpresscon;
 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
 
 
@@ -801,63 +868,6 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
 }
 
 
-Box BufferView::Pimpl::insetDimensions(LyXText const & text,
-                                      LyXCursor const & cursor) const
-{
-       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(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));
-}
-
-
-Inset * BufferView::Pimpl::checkInset(LyXText const & text,
-                                     LyXCursor const & cursor,
-                                     int & x, int & y) const
-{
-       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(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;
-}
 
 
 Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y)
@@ -867,7 +877,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y)
        LyXCursor cursor;
        text->setCursorFromCoordinates(bv_, cursor, x, y_tmp);
 
-       Inset * inset = checkInset(*text, cursor, x, y_tmp);
+       Inset * inset = checkInset(bv_, *text, cursor, x, y_tmp);
 
        if (inset) {
                y = y_tmp;
@@ -882,7 +892,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y)
        // move back one
        text->setCursor(bv_, cursor, cursor.par(), cursor.pos() - 1, true);
 
-       inset = checkInset(*text, cursor, x, y_tmp);
+       inset = checkInset(bv_, *text, cursor, x, y_tmp);
        if (inset) {
                y = y_tmp;
        }
index 3e0c025597ddebbca8f6056d78eac2f0a52dbd05..df5292b32a22c91aafb7a25f6c0466686e6638e0 100644 (file)
@@ -15,8 +15,6 @@
 #include "frontends/key_state.h"
 #include "frontends/mouse_state.h"
 #include "frontends/LyXKeySym.h"
-#include "box.h"
-#include "insets/insetspecialchar.h"
 #include "support/types.h"
 
 #include <boost/scoped_ptr.hpp>
@@ -73,8 +71,7 @@ struct BufferView::Pimpl : public boost::signals::trackable {
        /// wheel mouse scroll
        int scroll(long time);
        ///
-       void workAreaKeyPress(LyXKeySymPtr key,
-                             key_modifier::state state);
+       void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
        ///
        void workAreaMotionNotify(int x, int y, mouse_button::state state);
        ///
@@ -122,22 +119,8 @@ struct BufferView::Pimpl : public boost::signals::trackable {
        ///
        bool dispatch(FuncRequest const & ev);
 private:
-       /**
-        * Return the on-screen dimensions of the inset at the cursor.
-        * Pre-condition: the cursor must be at an inset.
-        */
-       Box insetDimensions(LyXText const & text, LyXCursor const & cursor) const;
-       /**
-        * 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(LyXText const & text, LyXCursor const & cursor,
-                          int & x, int & y) const;
        ///
        friend class BufferView;
-       ///
-       void hfill();
 
        ///
        BufferView * bv_;