2 * \file updatableinset.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alejandro Aguilar Sierra
8 * \author Lars Gullik Bjønnes
9 * \author Matthias Ettrich
11 * Full author contact details are available in file CREDITS.
16 #include "updatableinset.h"
18 #include "BufferView.h"
21 #include "dispatchresult.h"
22 #include "funcrequest.h"
25 #include "support/lstrings.h"
27 #include <boost/assert.hpp>
29 using lyx::support::strToDbl;
30 using lyx::support::strToInt;
34 // An updatable inset is highly editable by definition
35 InsetOld::EDITABLE UpdatableInset::editable() const
37 return HIGHLY_EDITABLE;
41 void UpdatableInset::scroll(BufferView & bv, float s) const
48 int const workW = bv.workWidth();
49 int const tmp_xo_ = xo_ - scx;
51 if (tmp_xo_ > 0 && tmp_xo_ + width() < workW)
56 scx = int(s * workW / 2);
61 if (tmp_xo_ + scx + width() < workW / 2)
62 scx = workW / 2 - tmp_xo_ - width();
66 void UpdatableInset::scroll(BufferView & bv, int offset) const
69 if (!scx && xo_ >= 20)
71 if (xo_ + offset > 20)
78 if (!scx && xo_ + width() < bv.workWidth() - 20)
80 if (xo_ - scx + offset + width() < bv.workWidth() - 20) {
81 scx += bv.workWidth() - width() - xo_ - 20;
89 void UpdatableInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
92 //case LFUN_MOUSE_RELEASE:
93 // return DispatchResult(editable() == IS_EDITABLE);
95 case LFUN_SCROLL_INSET:
96 if (cmd.argument.empty()) {
97 if (cmd.argument.find('.') != cmd.argument.npos)
98 scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
100 scroll(cur.bv(), strToInt(cmd.argument));
106 InsetOld::dispatch(cur, cmd);
111 void UpdatableInset::getCursorDim(int &, int &) const