From bc2017704562ca48a2c6a646c5ea27d2024ef917 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Mon, 17 Dec 2001 13:33:22 +0000 Subject: [PATCH] Fixed poping up of Layout-Dialogs on Mouse-Button-3 press. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3225 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 18 ++++++++++++++ src/insets/inset.C | 3 ++- src/insets/inset.h | 15 +++++++++--- src/insets/insetcollapsable.C | 11 ++++++--- src/insets/insetcollapsable.h | 2 +- src/insets/insetert.C | 7 ++++-- src/insets/insetert.h | 2 +- src/insets/insetfloat.C | 20 --------------- src/insets/insetfloat.h | 2 -- src/insets/insetminipage.C | 11 --------- src/insets/insetminipage.h | 2 -- src/insets/insettabular.C | 27 ++++++++------------ src/insets/insettabular.h | 2 +- src/insets/insettext.C | 46 +++++++++++++++++------------------ src/insets/insettext.h | 2 +- src/mathed/formulabase.C | 7 +++--- src/mathed/formulabase.h | 2 +- 17 files changed, 86 insertions(+), 93 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 984d306d01..eebc28ef2e 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,21 @@ +2001-12-17 Juergen Vigna + + * insetert.C (read): removed piece of compatibility code only needed + for 1.2.0. + + * insettabular.C (insetButtonRelease): fixed so that sub-dialogs + can be opened. + + * insetcollapsable.C (insetButtonRelease): changed so that it can + open evetual existing popup dialogs on mousebutton==3. + + * insetfloat.C (insetButtonRelease): removed not needed anymore! + + * insetminipage.C (insetButtonRelease): removed not needed anymore! + + * inset.C (insetButtonRelease): return a bool for telling the outer + world that we opened a dialog. + 2001-12-07 Juergen Vigna * insettext.C (paragraph): remove the deleteing of paragraphs as diff --git a/src/insets/inset.C b/src/insets/inset.C index 39e9a31685..85248d564c 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -164,10 +164,11 @@ void UpdatableInset::insetButtonPress(BufferView *, int x, int y, int button) } -void UpdatableInset::insetButtonRelease(BufferView *, int x, int y, int button) +bool UpdatableInset::insetButtonRelease(BufferView *, int x, int y, int button) { lyxerr[Debug::INFO] << "Inset Button Release x=" << x << ", y=" << y << ", button=" << button << endl; + return false; } diff --git a/src/insets/inset.h b/src/insets/inset.h index 9e9c654d1a..8e070260b1 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -159,7 +159,12 @@ public: /// This is called when the user clicks inside an inset virtual void insetButtonPress(BufferView *, int, int, int) {} /// This is called when the user releases the button inside an inset - virtual void insetButtonRelease(BufferView *, int, int, int) {} + // the bool return is used to see if we opened a dialog so that we can + // check this from an outer inset and open the dialog of the outer inset + // if that one has one! + /// + virtual bool insetButtonRelease(BufferView *, int, int, int) + { return false; } /// This is called when the user moves the mouse inside an inset virtual void insetMotionNotify(BufferView *, int , int , int) {} /// @@ -430,8 +435,12 @@ public: /// virtual void insetButtonPress(BufferView *, int x, int y, int button); /// - virtual void insetButtonRelease(BufferView *, - int x, int y, int button); + // the bool return is used to see if we opened a dialog so that we can + // check this from an outer inset and open the dialog of the outer inset + // if that one has one! + /// + virtual bool insetButtonRelease(BufferView *, + int x, int y, int button); /// virtual void insetKeyPress(XKeyEvent * ev); /// diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 01e0d11abf..c314aa2f82 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -322,10 +322,11 @@ void InsetCollapsable::insetButtonPress(BufferView * bv, } -void InsetCollapsable::insetButtonRelease(BufferView * bv, +bool InsetCollapsable::insetButtonRelease(BufferView * bv, int x, int y, int button) { - if ((x >= 0) && (x < button_length) && + bool ret = false; + if ((button != 3) && (x >= 0) && (x < button_length) && (y >= button_top_y) && (y <= button_bottom_y)) { if (collapsed_) { @@ -345,8 +346,12 @@ void InsetCollapsable::insetButtonRelease(BufferView * bv, (ascent_collapsed() + descent_collapsed() + inset.ascent(bv, font)); - inset.insetButtonRelease(bv, x, yy, button); + ret = inset.insetButtonRelease(bv, x, yy, button); } + if ((button == 3) && !ret) { + return showInsetDialog(bv); + } + return false; } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 9f73fbbbe8..3a53cce625 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -89,7 +89,7 @@ public: /// unsigned int insetInInsetY(); /// - void insetButtonRelease(BufferView *, int, int, int); + bool insetButtonRelease(BufferView *, int, int, int); /// void insetButtonPress(BufferView *, int, int, int); /// diff --git a/src/insets/insetert.C b/src/insets/insetert.C index e964ea2b9d..6b3c6f61cf 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -126,6 +126,7 @@ void InsetERT::read(Buffer const * buf, LyXLex & lex) lex.pushToken(token); } } +#if 0 #warning this should be really short lived only for compatibility to #warning files written 07/08/2001 so this has to go before 1.2.0! (Jug) if (lex.isOK()) { @@ -139,6 +140,7 @@ void InsetERT::read(Buffer const * buf, LyXLex & lex) lex.pushToken(token); } } +#endif inset.read(buf, lex); #ifndef INHERIT_LANG @@ -299,11 +301,11 @@ void InsetERT::insetButtonPress(BufferView * bv, } -void InsetERT::insetButtonRelease(BufferView * bv, int x, int y, int button) +bool InsetERT::insetButtonRelease(BufferView * bv, int x, int y, int button) { if (button == 3) { showInsetDialog(bv); - return; + return true; } if (status_ != Inlined && (x >= 0) && (x < button_length) && @@ -322,6 +324,7 @@ void InsetERT::insetButtonRelease(BufferView * bv, int x, int y, int button) inset.insetButtonRelease(bv, x, yy, button); } } + return false; } diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 78b89be521..7d24a6f139 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -73,7 +73,7 @@ public: /// void insetButtonPress(BufferView *, int x, int y, int button); /// - void insetButtonRelease(BufferView * bv, int x, int y, int button); + bool insetButtonRelease(BufferView * bv, int x, int y, int button); /// void insetMotionNotify(BufferView *, int x, int y, int state); /// diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 93ae48a21f..1d4c3614cb 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -271,26 +271,6 @@ bool InsetFloat::showInsetDialog(BufferView * bv) const } -void InsetFloat::insetButtonRelease(BufferView * bv, int x, int y, int button) -{ -#if 1 - if ((x >= 0) && (x < button_length) && - (y >= button_top_y) && (y <= button_bottom_y) && - (button == 3)) - { - showInsetDialog(bv); - return; - } -#else - if (button == 3) { - showInsetDialog(bv); - return; - } -#endif - InsetCollapsable::insetButtonRelease(bv, x, y, button); -} - - string const & InsetFloat::type() const { return floatType_; diff --git a/src/insets/insetfloat.h b/src/insets/insetfloat.h index 9376c626be..4228886716 100644 --- a/src/insets/insetfloat.h +++ b/src/insets/insetfloat.h @@ -51,8 +51,6 @@ public: /// bool insetAllowed(Inset::Code) const; /// - void insetButtonRelease(BufferView * bv, int x, int y, int button); - /// string const & type() const; /// void placement(string const & p); diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index 81523d353c..069cd6958c 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -324,17 +324,6 @@ bool InsetMinipage::showInsetDialog(BufferView * bv) const } -void InsetMinipage::insetButtonRelease(BufferView * bv, int x, int y, - int button) -{ - if (button == 3) { - showInsetDialog(bv); - return; - } - InsetCollapsable::insetButtonRelease(bv, x, y, button); -} - - int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const { diff --git a/src/insets/insetminipage.h b/src/insets/insetminipage.h index 4171e03d48..4b1797d804 100644 --- a/src/insets/insetminipage.h +++ b/src/insets/insetminipage.h @@ -81,8 +81,6 @@ public: /// SigC::Signal0 hideDialog; /// - void insetButtonRelease(BufferView * bv, int x, int y, int button); - /// int getMaxWidth(BufferView *, UpdatableInset const *) const; /// bool needFullRow() const { return false; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 2da68f6db4..4745b27075 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -745,6 +745,7 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button) if (actrow != orow) updateLocal(bv, NONE, false); clearSelection(); +#if 0 if (button == 3) { if ((ocell != actcell) && the_locking_inset) { the_locking_inset->insetUnlock(bv); @@ -753,6 +754,7 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button) showInsetCursor(bv); return; } +#endif bool const inset_hit = insetHit(bv, x, y); @@ -782,26 +784,17 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button) } -void InsetTabular::insetButtonRelease(BufferView * bv, - int x, int y, int button) +bool InsetTabular::insetButtonRelease(BufferView * bv, + int x, int y, int button) { - if (button == 3) { - if (the_locking_inset) { - UpdatableInset * i; - if ((i = the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE))) { - i->insetButtonRelease(bv, x, y, button); - return; - } - } + bool ret = false; + if (the_locking_inset) + ret = the_locking_inset->insetButtonRelease(bv, x, y, button); + if (button == 3 && !ret) { bv->owner()->getDialogs()->showTabular(this); - return; - } - if (the_locking_inset) { - the_locking_inset->insetButtonRelease(bv, - x - inset_x, y - inset_y, - button); - return; + return true; } + return ret; } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index d53d4305d2..e495a272d9 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -131,7 +131,7 @@ public: /// bool display() const { return tabular->IsLongTabular(); } /// - void insetButtonRelease(BufferView *, int, int, int); + bool insetButtonRelease(BufferView *, int, int, int); /// void insetButtonPress(BufferView *, int, int, int); /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 1e0a9906fb..15afebff95 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -995,34 +995,32 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button) } -void InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button) +bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button) { - UpdatableInset * inset = 0; - if (the_locking_inset) { - the_locking_inset->insetButtonRelease(bv, - x - inset_x, y - inset_y, - button); - } else { - if (cpar(bv)->isInset(cpos(bv))) { - inset = static_cast(cpar(bv)->getInset(cpos(bv))); - if (isHighlyEditableInset(inset)) { - inset->insetButtonRelease(bv, - x - inset_x, - y - inset_y, button); - } else { - inset_x = cx(bv) - top_x + drawTextXOffset; - inset_y = cy(bv) + drawTextYOffset; - inset->insetButtonRelease(bv, - x - inset_x, - y - inset_y, button); - inset->edit(bv, - x - inset_x, y - inset_y, button); - } - updateLocal(bv, CURSOR_PAR, false); + return the_locking_inset->insetButtonRelease(bv, + x - inset_x, y - inset_y, + button); + } + int tmp_x = x - drawTextXOffset; + int tmp_y = y + insetAscent - getLyXText(bv)->first; + Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y, button); + bool ret = false; + if (inset) { + if (isHighlyEditableInset(inset)) { + ret = inset->insetButtonRelease(bv, x - inset_x, + y - inset_y, button); + } else { + inset_x = cx(bv) - top_x + drawTextXOffset; + inset_y = cy(bv) + drawTextYOffset; + ret = inset->insetButtonRelease(bv, x - inset_x, + y - inset_y, button); + inset->edit(bv, x - inset_x, + y - inset_y, button); } + updateLocal(bv, CURSOR_PAR, false); } - no_selection = false; + return ret; } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 5ffc127287..aeae6f8662 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -122,7 +122,7 @@ public: /// bool updateInsetInInset(BufferView *, Inset *); /// - void insetButtonRelease(BufferView *, int, int, int); + bool insetButtonRelease(BufferView *, int, int, int); /// void insetButtonPress(BufferView *, int, int, int); /// diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 7a54dc02b1..fc2b83b1ff 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -252,15 +252,16 @@ void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty) } -void InsetFormulaBase::insetButtonRelease(BufferView * bv, - int /*x*/, int /*y*/, int /*button*/) +bool InsetFormulaBase::insetButtonRelease(BufferView * bv, + int /*x*/, int /*y*/, int /*button*/) { if (!mathcursor) - return; + return false; //lyxerr << "insetButtonRelease: " << x << " " << y << "\n"; hideInsetCursor(bv); showInsetCursor(bv); bv->updateInset(this, false); + return false; } diff --git a/src/mathed/formulabase.h b/src/mathed/formulabase.h index 4f7e588ee1..21e856578c 100644 --- a/src/mathed/formulabase.h +++ b/src/mathed/formulabase.h @@ -80,7 +80,7 @@ public: /// virtual void insetButtonPress(BufferView *, int x, int y, int button); /// - virtual void insetButtonRelease(BufferView *, int x, int y, int button); + virtual bool insetButtonRelease(BufferView *, int x, int y, int button); /// virtual void insetKeyPress(XKeyEvent * ev); /// -- 2.39.5