some consolidation of inset scrolling

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10205 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2005-07-15 12:50:10 +00:00
parent f5ecca49d6
commit c1ef1ac5e4
3 changed files with 5 additions and 63 deletions

View File

@ -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<float>(convert<double>(cmd.argument)));
else
setScroll(ww, convert<int>(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;

View File

@ -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<float>(convert<double>(cmd.argument)));
else
setScroll(maxwidth, convert<int>(cmd.argument));
} else
cur.noUpdate();
break;
default:
InsetBase::dispatch(cur, cmd);
}
}
void UpdatableInset::getCursorDim(int &, int &) const
{
BOOST_ASSERT(false);

View File

@ -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