re-enable click on button insets

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8394 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-02-03 16:44:57 +00:00
parent 7ffc9e9175
commit 29ef6251e8
8 changed files with 40 additions and 37 deletions

View File

@ -355,7 +355,6 @@ void BufferView::Pimpl::buffer(Buffer * b)
bool BufferView::Pimpl::fitCursor()
{
lyxerr << "BufferView::Pimpl::fitCursor." << endl;
if (screen().fitCursor(bv_)) {
updateScrollbar();
return true;

View File

@ -92,19 +92,15 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
// remove one level of cursor
switch (res.val()) {
case FINISHED:
pop(i);
cmd = FuncRequest(LFUN_FINISHED_LEFT);
break;
case FINISHED_RIGHT:
pop(i);
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
break;
case FINISHED_UP:
pop(i);
cmd = FuncRequest(LFUN_FINISHED_UP);
break;
case FINISHED_DOWN:
pop(i);
cmd = FuncRequest(LFUN_FINISHED_DOWN);
break;
default:
@ -112,7 +108,9 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
break;
}
}
lyxerr << "trying to dispatch to main text " << bv_->text() << endl;
current_ = 0;
lyxerr << "trying to dispatch to main text " << bv_->text()
<< " with cursor: " << *this << endl;
DispatchResult res = bv_->text()->dispatch(*this, cmd);
lyxerr << " result: " << res.val() << endl;
return res;
@ -131,24 +129,18 @@ void LCursor::push(InsetBase * inset)
void LCursor::pop(int depth)
{
//lyxerr << "LCursor::pop() to depth " << depth << endl;
while (int(cursor_.size()) > depth)
while (int(cursor_.size()) > depth + 1)
pop();
lyxerr << "LCursor::pop() result: " << *this << endl;
}
void LCursor::pop()
{
BOOST_ASSERT(!cursor_.empty());
//lyxerr << "LCursor::pop() a level" << endl;
if (cursor_.size() <= 1)
lyxerr << "### TRYING TO POP FROM EMPTY CURSOR" << endl;
else {
BOOST_ASSERT(cursor_.size() >= 1);
cursor_.pop_back();
anchor_.pop_back();
current_ = cursor_.size() - 1;
}
//lyxerr << "LCursor::pop() current now: " << current_ << endl;
}

View File

@ -82,6 +82,8 @@ public:
CursorSlice const & current() const;
/// how many nested insets do we have?
size_t depth() const { return cursor_.size(); }
/// depth of current slice
int currentDepth() const { return current_; }
//
// selection

View File

@ -212,9 +212,9 @@ bool LyXScreen::fitCursor(BufferView * bv)
int x, y, asc, desc;
bv->cursor().getPos(x, y);
lyxerr << "LyXScreen::fitCursor: x: " << x << " y: " << y
<< " top_y: " << top_y << endl;
bv->cursor().getDim(asc, desc);
//lyxerr << "LyXScreen::fitCursor: x: " << x << " y: " << y
// << " top_y: " << top_y << endl;
bool const big_row = h / 4 < asc + desc && asc + desc < h;

View File

@ -89,7 +89,7 @@ int InsetOld::scroll(bool recursive) 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;
xo_ = x;
yo_ = y;
}

View File

@ -63,20 +63,19 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & in)
void InsetCollapsable::write(Buffer const & buf, ostream & os) const
{
string st;
os << "status ";
switch (status_) {
case Open:
st = "open";
os << "open";
break;
case Collapsed:
st = "collapsed";
os << "collapsed";
break;
case Inlined:
st = "inlined";
os << "inlined";
break;
}
os << "status " << st << "\n";
os << "\n";
inset.text_.write(buf, os);
}
@ -170,12 +169,11 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
} else {
Dimension dimc;
dimension_collapsed(dimc);
int const aa = ascent();
button_dim.x1 = 0;
button_dim.x2 = dimc.width();
button_dim.y1 = -aa;
button_dim.y2 = -aa + dimc.height();
button_dim.x1 = x + 0;
button_dim.x2 = x + dimc.width();
button_dim.y1 = y - aa;
button_dim.y2 = y - aa + dimc.height();
draw_collapsed(pi, x, y);
if (status_ == Open) {
@ -219,6 +217,8 @@ InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
if (hitButton(cmd)) {
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
setStatus(Collapsed);
// drop one level
cur.bv().cursor() = cur;
return DispatchResult(false, FINISHED_RIGHT);
}
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
@ -227,7 +227,8 @@ InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
case Inlined:
return inset.dispatch(cur, cmd);
}
BOOST_ASSERT(false);
// shut up compiler
return DispatchResult(true, true);
}

View File

@ -210,6 +210,7 @@ int InsetERT::docbook(Buffer const &, ostream & os,
DispatchResult InsetERT::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
{
lyxerr << "\nInsetERT::priv_dispatch (begin): cmd: " << cmd << endl;
switch (cmd.action) {
case LFUN_INSET_MODIFY: {

View File

@ -1464,24 +1464,32 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
break;
case LFUN_FINISHED_LEFT:
lyxerr << "swallow LFUN_FINISHED_LEFT" << endl;
lyxerr << "handle LFUN_FINISHED_LEFT" << endl;
cur.pop(cur.currentDepth());
cur.bv().cursor() = cur;
if (rtl())
cursorLeft(true);
break;
case LFUN_FINISHED_RIGHT:
lyxerr << "swallow LFUN_FINISHED_RIGHT" << endl;
lyxerr << "handle LFUN_FINISHED_RIGHT" << endl;
cur.pop(cur.currentDepth());
cur.bv().cursor() = cur;
if (!rtl())
cursorRight(true);
break;
case LFUN_FINISHED_UP:
lyxerr << "swallow LFUN_FINISHED_UP" << endl;
lyxerr << "handle LFUN_FINISHED_UP" << endl;
cur.pop(cur.currentDepth());
cur.bv().cursor() = cur;
cursorUp(true);
break;
case LFUN_FINISHED_DOWN:
lyxerr << "swallow LFUN_FINISHED_DOWN" << endl;
lyxerr << "handle LFUN_FINISHED_DOWN" << endl;
cur.pop(cur.currentDepth());
cur.bv().cursor() = cur;
cursorDown(true);
break;