mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-27 02:19:10 +00:00
conmsolidate scrolling code
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10204 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6719871884
commit
f5ecca49d6
@ -1,3 +1,10 @@
|
|||||||
|
|
||||||
|
2005-07-14 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
* insetcollapsable.[Ch]:
|
||||||
|
* updatableinset.[Ch]: (scroll, setScroll)
|
||||||
|
sanitize things
|
||||||
|
|
||||||
2005-07-14 Angus Leeming <leeming@lyx.org>
|
2005-07-14 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* insetbibtex.C (latex): when processing the LaTeX file in
|
* insetbibtex.C (latex): when processing the LaTeX file in
|
||||||
|
@ -28,14 +28,13 @@ using std::string;
|
|||||||
|
|
||||||
|
|
||||||
InsetOld::InsetOld()
|
InsetOld::InsetOld()
|
||||||
: scx(0),
|
: //background_color_(LColor::inherit)
|
||||||
//background_color_(LColor::inherit)
|
|
||||||
background_color_(LColor::background)
|
background_color_(LColor::background)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
InsetOld::InsetOld(InsetOld const & in)
|
InsetOld::InsetOld(InsetOld const & in)
|
||||||
: InsetBase(in), scx(0), name_(in.name_),
|
: InsetBase(in), name_(in.name_),
|
||||||
background_color_(in.background_color_)
|
background_color_(in.background_color_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -70,12 +69,6 @@ int InsetOld::width() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetOld::scroll(bool) const
|
|
||||||
{
|
|
||||||
return scx;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetOld::setPosCache(PainterInfo const &, int x, int y) const
|
void InsetOld::setPosCache(PainterInfo const &, int x, int y) const
|
||||||
{
|
{
|
||||||
//lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl;
|
//lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl;
|
||||||
|
@ -50,15 +50,11 @@ public:
|
|||||||
LColor_color backgroundColor() const;
|
LColor_color backgroundColor() const;
|
||||||
/// set x/y drawing position cache
|
/// set x/y drawing position cache
|
||||||
void setPosCache(PainterInfo const &, int, int) const;
|
void setPosCache(PainterInfo const &, int, int) const;
|
||||||
/// returns the actual scroll-value
|
|
||||||
virtual int scroll(bool recursive = true) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
InsetOld(InsetOld const & in);
|
InsetOld(InsetOld const & in);
|
||||||
///
|
///
|
||||||
mutable int scx;
|
|
||||||
///
|
|
||||||
mutable Dimension dim_;
|
mutable Dimension dim_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -272,8 +272,8 @@ InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y)
|
|||||||
|
|
||||||
void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd)
|
void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||||
{
|
{
|
||||||
lyxerr << "InsetCollapsable::doDispatch (begin): cmd: " << cmd
|
//lyxerr << "InsetCollapsable::doDispatch (begin): cmd: " << cmd
|
||||||
<< " cur: " << cur << " bvcur: " << cur.bv().cursor() << endl;
|
// << " cur: " << cur << " bvcur: " << cur.bv().cursor() << endl;
|
||||||
|
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
case LFUN_MOUSE_PRESS:
|
case LFUN_MOUSE_PRESS:
|
||||||
@ -305,7 +305,7 @@ void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
switch (status_) {
|
switch (status_) {
|
||||||
|
|
||||||
case Collapsed:
|
case Collapsed:
|
||||||
lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
|
//lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
|
||||||
setStatus(cur, Open);
|
setStatus(cur, Open);
|
||||||
edit(cur, true);
|
edit(cur, true);
|
||||||
cur.bv().cursor() = cur;
|
cur.bv().cursor() = cur;
|
||||||
@ -313,18 +313,18 @@ void InsetCollapsable::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
|
|
||||||
case Open: {
|
case Open: {
|
||||||
if (hitButton(cmd)) {
|
if (hitButton(cmd)) {
|
||||||
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
|
//lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
|
||||||
setStatus(cur, Collapsed);
|
setStatus(cur, Collapsed);
|
||||||
cur.bv().cursor() = cur;
|
cur.bv().cursor() = cur;
|
||||||
} else {
|
} else {
|
||||||
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
|
//lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
|
||||||
InsetText::doDispatch(cur, cmd);
|
InsetText::doDispatch(cur, cmd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Inlined:
|
case Inlined:
|
||||||
lyxerr << "InsetCollapsable::lfunMouseRelease 4" << endl;
|
//lyxerr << "InsetCollapsable::lfunMouseRelease 4" << endl;
|
||||||
InsetText::doDispatch(cur, cmd);
|
InsetText::doDispatch(cur, cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -399,14 +399,3 @@ void InsetCollapsable::setLabelFont(LyXFont & font)
|
|||||||
labelfont_ = font;
|
labelfont_ = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetCollapsable::scroll(BufferView & bv, double sx) const
|
|
||||||
{
|
|
||||||
UpdatableInset::scroll(bv, sx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetCollapsable::scroll(BufferView & bv, int offset) const
|
|
||||||
{
|
|
||||||
UpdatableInset::scroll(bv, offset);
|
|
||||||
}
|
|
||||||
|
@ -67,10 +67,6 @@ public:
|
|||||||
///
|
///
|
||||||
int scroll(bool recursive = true) const;
|
int scroll(bool recursive = true) const;
|
||||||
///
|
///
|
||||||
void scroll(BufferView & bv, double sx) const;
|
|
||||||
///
|
|
||||||
void scroll(BufferView & bv, int offset) const;
|
|
||||||
///
|
|
||||||
bool isOpen() const { return status_ == Open || status_ == Inlined; }
|
bool isOpen() const { return status_ == Open || status_ == Inlined; }
|
||||||
///
|
///
|
||||||
bool inlined() const { return status_ == Inlined; }
|
bool inlined() const { return status_ == Inlined; }
|
||||||
|
@ -433,7 +433,7 @@ void InsetTabular::edit(LCursor & cur, bool left)
|
|||||||
|
|
||||||
void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
|
void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||||
{
|
{
|
||||||
lyxerr << "# InsetTabular::dispatch: cmd: " << cmd << endl;
|
//lyxerr << "# InsetTabular::dispatch: cmd: " << cmd << endl;
|
||||||
//lyxerr << " cur:\n" << cur << endl;
|
//lyxerr << " cur:\n" << cur << endl;
|
||||||
CursorSlice sl = cur.top();
|
CursorSlice sl = cur.top();
|
||||||
LCursor & bvcur = cur.bv().cursor();
|
LCursor & bvcur = cur.bv().cursor();
|
||||||
@ -441,7 +441,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
|
|
||||||
case LFUN_MOUSE_PRESS:
|
case LFUN_MOUSE_PRESS:
|
||||||
lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
|
//lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
|
||||||
|
|
||||||
if (cmd.button() == mouse_button::button1) {
|
if (cmd.button() == mouse_button::button1) {
|
||||||
cur.selection() = false;
|
cur.selection() = false;
|
||||||
@ -465,7 +465,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MOUSE_MOTION:
|
case LFUN_MOUSE_MOTION:
|
||||||
lyxerr << "# InsetTabular::MouseMotion\n" << bvcur << endl;
|
//lyxerr << "# InsetTabular::MouseMotion\n" << bvcur << endl;
|
||||||
if (cmd.button() == mouse_button::button1) {
|
if (cmd.button() == mouse_button::button1) {
|
||||||
// only accept motions to places not deeper nested than the real anchor
|
// only accept motions to places not deeper nested than the real anchor
|
||||||
if (bvcur.anchor_.hasPart(cur)) {
|
if (bvcur.anchor_.hasPart(cur)) {
|
||||||
@ -478,7 +478,7 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MOUSE_RELEASE:
|
case LFUN_MOUSE_RELEASE:
|
||||||
lyxerr << "# InsetTabular::MouseRelease\n" << bvcur << endl;
|
//lyxerr << "# InsetTabular::MouseRelease\n" << bvcur << endl;
|
||||||
if (cmd.button() == mouse_button::button3)
|
if (cmd.button() == mouse_button::button3)
|
||||||
InsetTabularMailer(*this).showDialog(&cur.bv());
|
InsetTabularMailer(*this).showDialog(&cur.bv());
|
||||||
break;
|
break;
|
||||||
@ -493,13 +493,14 @@ void InsetTabular::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
cur.selection() = false;
|
cur.selection() = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_SCROLL_INSET:
|
case LFUN_SCROLL_INSET:
|
||||||
if (cmd.argument.empty())
|
if (!cmd.argument.empty()) {
|
||||||
break;
|
int const ww = cur.bv().workWidth();
|
||||||
if (cmd.argument.find('.') != cmd.argument.npos)
|
if (cmd.argument.find('.') != cmd.argument.npos)
|
||||||
scroll(cur.bv(), static_cast<float>(convert<double>(cmd.argument)));
|
setScroll(ww, static_cast<float>(convert<double>(cmd.argument)));
|
||||||
else
|
else
|
||||||
scroll(cur.bv(), convert<int>(cmd.argument));
|
setScroll(ww, convert<int>(cmd.argument));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_RIGHTSEL:
|
case LFUN_RIGHTSEL:
|
||||||
@ -1138,22 +1139,20 @@ int InsetTabular::dist(idx_type const cell, int x, int y) const
|
|||||||
+ tabular.getAdditionalHeight(row);
|
+ tabular.getAdditionalHeight(row);
|
||||||
int const yend = ybeg + rowheight;
|
int const yend = ybeg + rowheight;
|
||||||
|
|
||||||
if (x < xbeg) {
|
if (x < xbeg)
|
||||||
xx = xbeg - x;
|
xx = xbeg - x;
|
||||||
} else if (x > xend) {
|
else if (x > xend)
|
||||||
xx = x - xend;
|
xx = x - xend;
|
||||||
}
|
|
||||||
|
|
||||||
if (y < ybeg) {
|
if (y < ybeg)
|
||||||
yy = ybeg - y;
|
yy = ybeg - y;
|
||||||
} else if (y > yend) {
|
else if (y > yend)
|
||||||
yy = y - yend;
|
yy = y - yend;
|
||||||
}
|
|
||||||
|
|
||||||
lyxerr << " xbeg=" << xbeg << " xend=" << xend
|
//lyxerr << " xbeg=" << xbeg << " xend=" << xend
|
||||||
<< " ybeg=" << ybeg << " yend=" << yend
|
// << " ybeg=" << ybeg << " yend=" << yend
|
||||||
<< " xx=" << xx << " yy=" << yy
|
// << " xx=" << xx << " yy=" << yy
|
||||||
<< " dist=" << xx + yy << endl;
|
// << " dist=" << xx + yy << endl;
|
||||||
return xx + yy;
|
return xx + yy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1181,7 +1180,7 @@ void InsetTabular::setCursorFromCoordinates(LCursor & cur, int x, int y) const
|
|||||||
|
|
||||||
InsetTabular::idx_type InsetTabular::getNearestCell(int x, int y) const
|
InsetTabular::idx_type InsetTabular::getNearestCell(int x, int y) const
|
||||||
{
|
{
|
||||||
lyxerr << "# InsetTabular::getNearestCell() x=" << x << " y=" << y << endl;
|
//lyxerr << "# InsetTabular::getNearestCell() x=" << x << " y=" << y << endl;
|
||||||
idx_type idx_min = 0;
|
idx_type idx_min = 0;
|
||||||
int dist_min = std::numeric_limits<int>::max();
|
int dist_min = std::numeric_limits<int>::max();
|
||||||
for (idx_type i = 0; i < nargs(); ++i) {
|
for (idx_type i = 0; i < nargs(); ++i) {
|
||||||
@ -1214,6 +1213,7 @@ int InsetTabular::getCellXPos(idx_type const cell) const
|
|||||||
void InsetTabular::resetPos(LCursor & cur) const
|
void InsetTabular::resetPos(LCursor & cur) const
|
||||||
{
|
{
|
||||||
BufferView & bv = cur.bv();
|
BufferView & bv = cur.bv();
|
||||||
|
int const maxwidth = bv.workWidth();
|
||||||
// col_type const actcol = tabular.column_of_cell(cur.idx());
|
// col_type const actcol = tabular.column_of_cell(cur.idx());
|
||||||
// int const offset = ADD_TO_TABULAR_WIDTH + 2;
|
// int const offset = ADD_TO_TABULAR_WIDTH + 2;
|
||||||
// int const new_x = getCellXPos(cur.idx()) + offset;
|
// int const new_x = getCellXPos(cur.idx()) + offset;
|
||||||
@ -1222,32 +1222,32 @@ void InsetTabular::resetPos(LCursor & cur) const
|
|||||||
// cursorx_ = new_x;
|
// cursorx_ = new_x;
|
||||||
// cursor.x(getCellXPos(cur.idx()) + offset);
|
// cursor.x(getCellXPos(cur.idx()) + offset);
|
||||||
// if (actcol < tabular.columns() - 1 && scroll(false) &&
|
// if (actcol < tabular.columns() - 1 && scroll(false) &&
|
||||||
// tabular.getWidthOfTabular() < bv.workWidth()-20)
|
// tabular.getWidthOfTabular() < maxwidth - 20)
|
||||||
// {
|
// {
|
||||||
// scroll(bv, 0.0F);
|
// setScroll(maxwidth, 0.0F);
|
||||||
// } else if (cursorx_ - offset > 20 &&
|
// } else if (cursorx_ - offset > 20 &&
|
||||||
// cursorx_ - offset + col_width > bv.workWidth() - 20) {
|
// cursorx_ - offset + col_width > maxwidth - 20) {
|
||||||
// scroll(bv, - col_width - 20);
|
// setScroll(maxwidth, - col_width - 20);
|
||||||
// } else if (cursorx_ - offset < 20) {
|
// } else if (cursorx_ - offset < 20) {
|
||||||
// scroll(bv, 20 - cursorx_ + offset);
|
// setScroll(maxwidth, 20 - cursorx_ + offset);
|
||||||
// } else if (scroll() && xo() > 20 &&
|
// } else if (scroll() && xo() > 20 &&
|
||||||
// xo() + tabular.getWidthOfTabular() > bv.workWidth() - 20) {
|
// xo() + tabular.getWidthOfTabular() > maxwidth - 20) {
|
||||||
// scroll(bv, old_x - cursorx_);
|
// setScroll(maxwidth, old_x - cursorx_);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (&cur.inset() != this) {
|
if (&cur.inset() != this) {
|
||||||
scroll(bv, 0.0F);
|
setScroll(maxwidth, 0.0f);
|
||||||
} else {
|
} else {
|
||||||
int const X1 = 0;
|
int const X1 = 0;
|
||||||
int const X2 = bv.workWidth();
|
int const X2 = maxwidth;
|
||||||
int const offset = ADD_TO_TABULAR_WIDTH + 2;
|
int const offset = ADD_TO_TABULAR_WIDTH + 2;
|
||||||
int const x1 = xo() + scroll() + getCellXPos(cur.idx()) + offset;
|
int const x1 = xo() + scroll() + getCellXPos(cur.idx()) + offset;
|
||||||
int const x2 = x1 + tabular.getWidthOfColumn(cur.idx());
|
int const x2 = x1 + tabular.getWidthOfColumn(cur.idx());
|
||||||
|
|
||||||
if (x1 < X1)
|
if (x1 < X1)
|
||||||
scroll(bv, X1 + 20 - x1);
|
setScroll(maxwidth, X1 + 20 - x1);
|
||||||
else if (x2 > X2)
|
else if (x2 > X2)
|
||||||
scroll(bv, X2 - 20 - x2);
|
setScroll(maxwidth, X2 - 20 - x2);
|
||||||
}
|
}
|
||||||
|
|
||||||
cur.needsUpdate();
|
cur.needsUpdate();
|
||||||
@ -1258,9 +1258,7 @@ void InsetTabular::resetPos(LCursor & cur) const
|
|||||||
|
|
||||||
void InsetTabular::moveNextCell(LCursor & cur)
|
void InsetTabular::moveNextCell(LCursor & cur)
|
||||||
{
|
{
|
||||||
lyxerr << "InsetTabular::moveNextCell 1 cur: " << cur.top() << endl;
|
|
||||||
if (isRightToLeft(cur)) {
|
if (isRightToLeft(cur)) {
|
||||||
lyxerr << "InsetTabular::moveNextCell A cur: " << endl;
|
|
||||||
if (tabular.isFirstCellInRow(cur.idx())) {
|
if (tabular.isFirstCellInRow(cur.idx())) {
|
||||||
row_type const row = tabular.row_of_cell(cur.idx());
|
row_type const row = tabular.row_of_cell(cur.idx());
|
||||||
if (row == tabular.rows() - 1)
|
if (row == tabular.rows() - 1)
|
||||||
@ -1272,14 +1270,12 @@ void InsetTabular::moveNextCell(LCursor & cur)
|
|||||||
--cur.idx();
|
--cur.idx();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lyxerr << "InsetTabular::moveNextCell B cur: " << endl;
|
|
||||||
if (tabular.isLastCell(cur.idx()))
|
if (tabular.isLastCell(cur.idx()))
|
||||||
return;
|
return;
|
||||||
++cur.idx();
|
++cur.idx();
|
||||||
}
|
}
|
||||||
cur.pit() = 0;
|
cur.pit() = 0;
|
||||||
cur.pos() = 0;
|
cur.pos() = 0;
|
||||||
lyxerr << "InsetTabular::moveNextCell 2 cur: " << cur.top() << endl;
|
|
||||||
resetPos(cur);
|
resetPos(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,34 +35,41 @@ InsetBase::EDITABLE UpdatableInset::editable() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UpdatableInset::scroll(BufferView & bv, double s) const
|
int UpdatableInset::scroll(bool) const
|
||||||
{
|
{
|
||||||
|
return scx;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UpdatableInset::setScroll(int maxwidth, double s) const
|
||||||
|
{
|
||||||
|
lyxerr << "UpdatableInset::setScroll: (int) " << maxwidth << std::endl;
|
||||||
if (!s) {
|
if (!s) {
|
||||||
scx = 0;
|
scx = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int const workW = bv.workWidth();
|
|
||||||
int xo_ = theCoords.getInsets().x(this);
|
int xo_ = theCoords.getInsets().x(this);
|
||||||
int const tmp_xo_ = xo_ - scx;
|
int const tmp_xo_ = xo_ - scx;
|
||||||
|
|
||||||
if (tmp_xo_ > 0 && tmp_xo_ + width() < workW)
|
if (tmp_xo_ > 0 && tmp_xo_ + width() < maxwidth)
|
||||||
return;
|
return;
|
||||||
if (s > 0.0 && xo_ > 0)
|
if (s > 0.0 && xo_ > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
scx = int(s * workW / 2);
|
scx = int(s * maxwidth / 2);
|
||||||
|
|
||||||
#ifdef WITH_WARNINGS
|
#ifdef WITH_WARNINGS
|
||||||
#warning metrics?
|
#warning metrics?
|
||||||
#endif
|
#endif
|
||||||
if (tmp_xo_ + scx + width() < workW / 2)
|
if (tmp_xo_ + scx + width() < maxwidth / 2)
|
||||||
scx = workW / 2 - tmp_xo_ - width();
|
scx = maxwidth / 2 - tmp_xo_ - width();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UpdatableInset::scroll(BufferView & bv, int offset) const
|
void UpdatableInset::setScroll(int maxwidth, int offset) const
|
||||||
{
|
{
|
||||||
|
lyxerr << "UpdatableInset::setScroll: (double) " << maxwidth << std::endl;
|
||||||
int const xo_ = theCoords.getInsets().x(this);
|
int const xo_ = theCoords.getInsets().x(this);
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
if (!scx && xo_ >= 20)
|
if (!scx && xo_ >= 20)
|
||||||
@ -76,13 +83,13 @@ void UpdatableInset::scroll(BufferView & bv, int offset) const
|
|||||||
#ifdef WITH_WARNINGS
|
#ifdef WITH_WARNINGS
|
||||||
#warning metrics?
|
#warning metrics?
|
||||||
#endif
|
#endif
|
||||||
if (!scx && xo_ + width() < bv.workWidth() - 20)
|
if (!scx && xo_ + width() < maxwidth - 20)
|
||||||
return;
|
return;
|
||||||
if (xo_ - scx + offset + width() < bv.workWidth() - 20) {
|
|
||||||
scx += bv.workWidth() - width() - xo_ - 20;
|
if (xo_ - scx + offset + width() < maxwidth - 20)
|
||||||
} else {
|
scx += maxwidth - width() - xo_ - 20;
|
||||||
|
else
|
||||||
scx += offset;
|
scx += offset;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,15 +97,13 @@ void UpdatableInset::scroll(BufferView & bv, int offset) const
|
|||||||
void UpdatableInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
void UpdatableInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||||
{
|
{
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
//case LFUN_MOUSE_RELEASE:
|
|
||||||
// return DispatchResult(editable() == IS_EDITABLE);
|
|
||||||
|
|
||||||
case LFUN_SCROLL_INSET:
|
case LFUN_SCROLL_INSET:
|
||||||
if (cmd.argument.empty()) {
|
if (cmd.argument.empty()) {
|
||||||
|
const int maxwidth = cur.bv().workWidth();
|
||||||
if (cmd.argument.find('.') != cmd.argument.npos)
|
if (cmd.argument.find('.') != cmd.argument.npos)
|
||||||
scroll(cur.bv(), static_cast<float>(convert<double>(cmd.argument)));
|
setScroll(maxwidth, static_cast<float>(convert<double>(cmd.argument)));
|
||||||
else
|
else
|
||||||
scroll(cur.bv(), convert<int>(cmd.argument));
|
setScroll(maxwidth, convert<int>(cmd.argument));
|
||||||
} else
|
} else
|
||||||
cur.noUpdate();
|
cur.noUpdate();
|
||||||
break;
|
break;
|
||||||
@ -113,3 +118,4 @@ void UpdatableInset::getCursorDim(int &, int &) const
|
|||||||
{
|
{
|
||||||
BOOST_ASSERT(false);
|
BOOST_ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
class UpdatableInset : public InsetOld {
|
class UpdatableInset : public InsetOld {
|
||||||
public:
|
public:
|
||||||
|
///
|
||||||
|
UpdatableInset() : scx(0) {}
|
||||||
///
|
///
|
||||||
virtual EDITABLE editable() const;
|
virtual EDITABLE editable() const;
|
||||||
/// identification as text inset in a cursor slice
|
/// identification as text inset in a cursor slice
|
||||||
@ -30,19 +32,20 @@ public:
|
|||||||
|
|
||||||
/// return the cursor dim
|
/// return the cursor dim
|
||||||
virtual void getCursorDim(int &, int &) const;
|
virtual void getCursorDim(int &, int &) const;
|
||||||
// We need this method to not clobber the real method in Inset
|
|
||||||
int scroll(bool recursive = true) const
|
|
||||||
{ return InsetOld::scroll(recursive); }
|
|
||||||
///
|
///
|
||||||
virtual bool showInsetDialog(BufferView *) const { return false; }
|
virtual bool showInsetDialog(BufferView *) const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// An updatable inset could handle lyx editing commands
|
/// An updatable inset could handle lyx editing commands
|
||||||
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
||||||
/// scrolls to absolute position in bufferview-workwidth * sx units
|
/// scrolls to absolute position in maxwidth * sx units
|
||||||
void scroll(BufferView &, double sx) const;
|
void setScroll(int maxwidth, double sx) const;
|
||||||
/// scrolls offset pixels
|
/// scrolls offset pixels
|
||||||
void scroll(BufferView &, int offset) const;
|
void setScroll(int maxwidth, int offset) const;
|
||||||
|
/// returns the actual scroll value
|
||||||
|
virtual int scroll(bool recursive = true) const;
|
||||||
|
///
|
||||||
|
mutable int scx;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user