From c1ef1ac5e4990ac8f1f02d77d7b4f3c8e864d915 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 15 Jul 2005 12:50:10 +0000 Subject: [PATCH] some consolidation of inset scrolling git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10205 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/insettabular.C | 14 ++--------- src/insets/updatableinset.C | 50 +++---------------------------------- src/insets/updatableinset.h | 4 --- 3 files changed, 5 insertions(+), 63 deletions(-) diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 1b072f5fb8..36ea3c0ccc 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -493,16 +493,6 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd) cur.selection() = false; break; - case LFUN_SCROLL_INSET: - if (!cmd.argument.empty()) { - int const ww = cur.bv().workWidth(); - if (cmd.argument.find('.') != cmd.argument.npos) - setScroll(ww, static_cast(convert(cmd.argument))); - else - setScroll(ww, convert(cmd.argument)); - } - break; - case LFUN_RIGHTSEL: case LFUN_RIGHT: cell(cur.idx())->dispatch(cur, cmd); @@ -1224,7 +1214,7 @@ void InsetTabular::resetPos(LCursor & cur) const // if (actcol < tabular.columns() - 1 && scroll(false) && // tabular.getWidthOfTabular() < maxwidth - 20) // { -// setScroll(maxwidth, 0.0F); +// scx = 0; // } else if (cursorx_ - offset > 20 && // cursorx_ - offset + col_width > maxwidth - 20) { // setScroll(maxwidth, - col_width - 20); @@ -1236,7 +1226,7 @@ void InsetTabular::resetPos(LCursor & cur) const // } if (&cur.inset() != this) { - setScroll(maxwidth, 0.0f); + scx = 0; } else { int const X1 = 0; int const X2 = maxwidth; diff --git a/src/insets/updatableinset.C b/src/insets/updatableinset.C index 68fb6bd547..71ff522583 100644 --- a/src/insets/updatableinset.C +++ b/src/insets/updatableinset.C @@ -41,35 +41,11 @@ int UpdatableInset::scroll(bool) const } -void UpdatableInset::setScroll(int maxwidth, double s) const -{ - lyxerr << "UpdatableInset::setScroll: (int) " << maxwidth << std::endl; - if (!s) { - scx = 0; - return; - } - - int xo_ = theCoords.getInsets().x(this); - int const tmp_xo_ = xo_ - scx; - - if (tmp_xo_ > 0 && tmp_xo_ + width() < maxwidth) - return; - if (s > 0.0 && xo_ > 0) - return; - - scx = int(s * maxwidth / 2); - -#ifdef WITH_WARNINGS -#warning metrics? -#endif - if (tmp_xo_ + scx + width() < maxwidth / 2) - scx = maxwidth / 2 - tmp_xo_ - width(); -} - - void UpdatableInset::setScroll(int maxwidth, int offset) const { - lyxerr << "UpdatableInset::setScroll: (double) " << maxwidth << std::endl; + lyxerr << "UpdatableInset::setScroll: (int) " << maxwidth << ' ' << +offset<< std::endl; + int const xo_ = theCoords.getInsets().x(this); if (offset > 0) { if (!scx && xo_ >= 20) @@ -94,26 +70,6 @@ void UpdatableInset::setScroll(int maxwidth, int offset) const } -void UpdatableInset::doDispatch(LCursor & cur, FuncRequest & cmd) -{ - switch (cmd.action) { - case LFUN_SCROLL_INSET: - if (cmd.argument.empty()) { - const int maxwidth = cur.bv().workWidth(); - if (cmd.argument.find('.') != cmd.argument.npos) - setScroll(maxwidth, static_cast(convert(cmd.argument))); - else - setScroll(maxwidth, convert(cmd.argument)); - } else - cur.noUpdate(); - break; - - default: - InsetBase::dispatch(cur, cmd); - } -} - - void UpdatableInset::getCursorDim(int &, int &) const { BOOST_ASSERT(false); diff --git a/src/insets/updatableinset.h b/src/insets/updatableinset.h index b2074d21d5..3c29e649ba 100644 --- a/src/insets/updatableinset.h +++ b/src/insets/updatableinset.h @@ -36,10 +36,6 @@ public: virtual bool showInsetDialog(BufferView *) const { return false; } protected: - /// An updatable inset could handle lyx editing commands - virtual void doDispatch(LCursor & cur, FuncRequest & cmd); - /// scrolls to absolute position in maxwidth * sx units - void setScroll(int maxwidth, double sx) const; /// scrolls offset pixels void setScroll(int maxwidth, int offset) const; /// returns the actual scroll value -- 2.39.5