From 97ef9131ba95f605a48d09595bd2ace0f993a55b Mon Sep 17 00:00:00 2001 From: John Levon Date: Sun, 26 May 2002 17:33:14 +0000 Subject: [PATCH] static_cast-based key/mouse-state. Kill insetKeyPress. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4210 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 55 +++++++++++++-------------- src/BufferView_pimpl.h | 13 ++++--- src/ChangeLog | 12 ++++++ src/frontends/ChangeLog | 9 +++++ src/frontends/Makefile.am | 2 + src/frontends/WorkArea.C | 71 +++++++++++++++++++++++++++++++---- src/frontends/WorkArea.h | 14 ++++--- src/frontends/key_state.h | 39 +++++++++++++++++++ src/frontends/mouse_state.h | 34 +++++++++++++++++ src/insets/ChangeLog | 39 +++++++++++++++++++ src/insets/inset.C | 17 +++------ src/insets/inset.h | 20 +++++----- src/insets/insetbib.C | 8 ++-- src/insets/insetbib.h | 4 +- src/insets/insetcite.C | 4 +- src/insets/insetcite.h | 2 +- src/insets/insetcollapsable.C | 18 +++------ src/insets/insetcollapsable.h | 10 ++--- src/insets/inseterror.C | 4 +- src/insets/inseterror.h | 2 +- src/insets/insetert.C | 14 +++---- src/insets/insetert.h | 8 ++-- src/insets/insetexternal.C | 4 +- src/insets/insetexternal.h | 2 +- src/insets/insetfloatlist.C | 4 +- src/insets/insetfloatlist.h | 2 +- src/insets/insetgraphics.C | 4 +- src/insets/insetgraphics.h | 2 +- src/insets/insetinclude.C | 4 +- src/insets/insetinclude.h | 2 +- src/insets/insetindex.C | 4 +- src/insets/insetindex.h | 4 +- src/insets/insetlabel.C | 4 +- src/insets/insetlabel.h | 2 +- src/insets/insetparent.C | 6 +-- src/insets/insetparent.h | 2 +- src/insets/insetref.C | 6 +-- src/insets/insetref.h | 2 +- src/insets/insettabular.C | 37 +++++++----------- src/insets/insettabular.h | 14 +++---- src/insets/insettext.C | 34 ++++++++--------- src/insets/insettext.h | 12 +++--- src/insets/insettoc.C | 4 +- src/insets/insettoc.h | 2 +- src/insets/inseturl.C | 4 +- src/insets/inseturl.h | 2 +- src/kbmap.C | 31 ++++++++------- src/kbmap.h | 9 +++-- src/kbsequence.C | 26 +++++++------ src/kbsequence.h | 13 +++++-- src/lyxfunc.C | 28 ++++++-------- src/lyxfunc.h | 8 ++-- src/mathed/ChangeLog | 6 +++ src/mathed/formulabase.C | 22 ++++------- src/mathed/formulabase.h | 11 +++--- src/mathed/math_inset.h | 3 +- src/text2.C | 4 +- 57 files changed, 446 insertions(+), 277 deletions(-) create mode 100644 src/frontends/key_state.h create mode 100644 src/frontends/mouse_state.h diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 0b52a1754e..3980058af2 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -541,16 +541,16 @@ int BufferView::Pimpl::scrollDown(long time) } -void BufferView::Pimpl::workAreaKeyPress(KeySym keysym, unsigned int state) +void BufferView::Pimpl::workAreaKeyPress(KeySym keysym, key_modifier::state state) { bv_->owner()->getLyXFunc()->processKeySym(keysym, state); } -void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state) +void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state state) { // Only use motion with button 1 - if (!(state & Button1MotionMask)) + if (!(state & mouse_button::button1)) return; if (!buffer_ || !screen_.get()) return; @@ -613,28 +613,27 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state) // Single-click on work area void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, - unsigned int button) + mouse_button::state button) { if (!buffer_ || !screen_.get()) return; // ok ok, this is a hack. - // Why??? (Jug20020424) - if (button == 4 || button == 5) { - switch (button) { - case 4: - scrollUp(lyxrc.wheel_jump); // default 100, set in lyxrc - break; - case 5: - scrollDown(lyxrc.wheel_jump); - break; - } + + if (button == mouse_button::button4) { + scrollUp(lyxrc.wheel_jump); + // We shouldn't go further down as we really should only do the + // scrolling and be done with this. Otherwise we may open some + // dialogs (Jug 20020424). + return; + } else if (button == mouse_button::button5) { + scrollDown(lyxrc.wheel_jump); // We shouldn't go further down as we really should only do the // scrolling and be done with this. Otherwise we may open some // dialogs (Jug 20020424). return; } - + Inset * inset_hit = checkInsetHit(bv_->text, xpos, ypos); // Middle button press pastes if we have a selection @@ -642,7 +641,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, // it could get cleared on the unlocking of the inset so // we have to check this first bool paste_internally = false; - if (button == 2 && bv_->getLyXText()->selection.set()) { + if (button == mouse_button::button2 && bv_->getLyXText()->selection.set()) { owner_->getLyXFunc()->dispatch(LFUN_COPY); paste_internally = true; } @@ -693,7 +692,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, // I'm not sure we should continue here if we hit an inset (Jug20020403) // Right click on a footnote flag opens float menu - if (button == 3) { + if (button == mouse_button::button3) { selection_possible = false; return; } @@ -712,7 +711,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, // Insert primary selection with middle mouse // if there is a local selection in the current buffer, // insert this - if (button == 2) { + if (button == mouse_button::button2) { if (paste_internally) owner_->getLyXFunc()->dispatch(LFUN_PASTE); else @@ -724,9 +723,8 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, } -void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button) +void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, mouse_button::state button) { - // select a word if (!buffer_) return; @@ -735,7 +733,7 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button) if (text->bv_owner && bv_->theLockingInset()) return; - if (screen_.get() && button == 1) { + if (screen_.get() && button == mouse_button::button1) { if (text->bv_owner) { screen_->hideCursor(); screen_->toggleSelection(text, bv_); @@ -751,9 +749,8 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button) } -void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button) +void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, mouse_button::state button) { - // select a line if (!buffer_) return; @@ -762,7 +759,7 @@ void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button) if (text->bv_owner && bv_->theLockingInset()) return; - if (screen_.get() && (button == 1)) { + if (screen_.get() && (button == mouse_button::button1)) { if (text->bv_owner) { screen_->hideCursor(); screen_->toggleSelection(text, bv_); @@ -838,10 +835,10 @@ void BufferView::Pimpl::leaveView() void BufferView::Pimpl::workAreaButtonRelease(int x, int y, - unsigned int button) + mouse_button::state button) { // do nothing if we used the mouse wheel - if (!buffer_ || !screen_.get() || button == 4 || button == 5) + if (!buffer_ || !screen_.get() || button == mouse_button::button4 || button == mouse_button::button5) return; // If we hit an inset, we have the inset coordinates in these @@ -862,11 +859,11 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, selection_possible = false; - if (button == 2) + if (button == mouse_button::button2) return; // finish selection - if (button == 1) { + if (button == mouse_button::button1) { workarea_.haveSelection(bv_->getLyXText()->selection.set()); } @@ -932,7 +929,7 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, // Maybe we want to edit a bibitem ale970302 if (bv_->text->cursor.par()->bibkey && x < 20 + bibitemMaxWidth(bv_, textclasslist[buffer_->params.textclass].defaultfont())) { - bv_->text->cursor.par()->bibkey->edit(bv_, 0, 0, 0); + bv_->text->cursor.par()->bibkey->edit(bv_, 0, 0, mouse_button::none); } return; diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 3702405385..313e6c459b 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -5,6 +5,7 @@ #include "BufferView.h" #include "commandtags.h" +#include "frontends/mouse_state.h" #include "frontends/Timeout.h" // FIXME remove me #include "frontends/WorkArea.h" @@ -66,17 +67,17 @@ struct BufferView::Pimpl : public SigC::Object { /// int scrollDown(long time); /// - void workAreaKeyPress(KeySym, unsigned int state); + void workAreaKeyPress(KeySym, key_modifier::state state); /// - void workAreaMotionNotify(int x, int y, unsigned int state); + void workAreaMotionNotify(int x, int y, mouse_button::state state); /// - void workAreaButtonPress(int x, int y, unsigned int button); + void workAreaButtonPress(int x, int y, mouse_button::state button); /// - void workAreaButtonRelease(int x, int y, unsigned int button); + void workAreaButtonRelease(int x, int y, mouse_button::state button); /// - void doubleClick(int x, int y, unsigned int button); + void doubleClick(int x, int y, mouse_button::state button); /// - void tripleClick(int x, int y, unsigned int button); + void tripleClick(int x, int y, mouse_button::state button); /// void selectionRequested(); /// diff --git a/src/ChangeLog b/src/ChangeLog index 19fcc5d1bb..c3ae80cceb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2002-05-26 John Levon + + * BufferView_pimpl.h: + * BufferView_pimpl.C: + * kbmap.h: + * kbmap.C: + * kbsequence.h: + * kbsequence.C: + * lyxfunc.h: + * lyxfunc.C: + * text2.C: use key_state/mouse_state + 2002-05-25 Lars Gullik Bjønnes * vc-backend.C (scanMaster): use boost regex and get rid of LRegex diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 33aaccab30..73abcb5239 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,12 @@ +2002-05-26 John Levon + + * key_state.h: + * mouse_state.h: add + + * Makefile.am: + * WorkArea.h: + * WorkArea.C: use above + 2002-05-24 John Levon * Makefile.am: diff --git a/src/frontends/Makefile.am b/src/frontends/Makefile.am index 77ed4fba86..bf3402a592 100644 --- a/src/frontends/Makefile.am +++ b/src/frontends/Makefile.am @@ -38,5 +38,7 @@ libfrontends_la_SOURCES = \ WorkArea.h \ font_loader.h \ font_metrics.h \ + key_state.h \ + mouse_state.h \ screen.C \ screen.h diff --git a/src/frontends/WorkArea.C b/src/frontends/WorkArea.C index 49ee9d69d6..dc5479d69f 100644 --- a/src/frontends/WorkArea.C +++ b/src/frontends/WorkArea.C @@ -47,6 +47,64 @@ void waitForX() XSync(fl_get_display(), 0); } +// FIXME ! +mouse_button::state x_button_state(unsigned int button) +{ + mouse_button::state b = mouse_button::none; + switch (button) { + case Button1: + b = mouse_button::button1; + break; + case Button2: + b = mouse_button::button2; + break; + case Button3: + b = mouse_button::button3; + break; + case Button4: + b = mouse_button::button4; + break; + case Button5: + b = mouse_button::button5; + break; + default: // FIXME + break; + } + return b; +} + + +// FIXME +mouse_button::state x_motion_state(unsigned int state) +{ + mouse_button::state b = mouse_button::none; + if (state & Button1MotionMask) + b |= mouse_button::button1; + if (state & Button2MotionMask) + b |= mouse_button::button2; + if (state & Button3MotionMask) + b |= mouse_button::button3; + if (state & Button4MotionMask) + b |= mouse_button::button4; + if (state & Button5MotionMask) + b |= mouse_button::button5; + return b; +} + + +key_modifier::state x_key_state(unsigned int state) +{ + key_modifier::state k = key_modifier::none; + if (state & ControlMask) + k |= key_modifier::ctrl; + if (state & ShiftMask) + k |= key_modifier::shift; + if (state & Mod1Mask) + k |= key_modifier::alt; + return k; +} + + } // anon namespace @@ -357,8 +415,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl; area->workAreaButtonPress(ev->xbutton.x - ob->x, ev->xbutton.y - ob->y, - ev->xbutton.button); - //area->workAreaKeyPress(XK_Pointer_Button1, ev->xbutton.state); + x_button_state(ev->xbutton.button)); break; case FL_RELEASE: if (!ev || ev->xbutton.button == 0) break; @@ -366,7 +423,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, lyxerr[Debug::WORKAREA] << "Workarea event: RELEASE" << endl; area->workAreaButtonRelease(ev->xbutton.x - ob->x, ev->xbutton.y - ob->y, - ev->xbutton.button); + x_button_state(ev->xbutton.button)); break; #if FL_REVISION < 89 case FL_MOUSE: @@ -381,7 +438,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, lyxerr[Debug::WORKAREA] << "Workarea event: MOUSE" << endl; area->workAreaMotionNotify(ev->xmotion.x - ob->x, ev->xmotion.y - ob->y, - ev->xbutton.state); + x_motion_state(ev->xbutton.state)); } break; #if FL_REVISION < 89 @@ -490,7 +547,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, last_key_pressed = xke->keycode; last_state_pressed = ret_state; - area->workAreaKeyPress(ret_key, ret_state); + area->workAreaKeyPress(ret_key, x_key_state(ret_state)); } break; @@ -521,14 +578,14 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event, lyxerr[Debug::WORKAREA] << "Workarea event: DBLCLICK" << endl; area->workAreaDoubleClick(ev->xbutton.x - ob->x, ev->xbutton.y - ob->y, - ev->xbutton.button); + x_button_state(ev->xbutton.button)); break; case FL_TRPLCLICK: if (!ev) break; lyxerr[Debug::WORKAREA] << "Workarea event: TRPLCLICK" << endl; area->workAreaTripleClick(ev->xbutton.x - ob->x, ev->xbutton.y - ob->y, - ev->xbutton.button); + x_button_state(ev->xbutton.button)); break; case FL_OTHER: if (!ev) break; diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h index 90fc8f690e..cef93f34ad 100644 --- a/src/frontends/WorkArea.h +++ b/src/frontends/WorkArea.h @@ -22,6 +22,8 @@ #include FORMS_H_LOCATION #include "frontends/Painter.h" +#include "frontends/mouse_state.h" +#include "frontends/key_state.h" /// class WorkArea { @@ -107,13 +109,13 @@ public: /// SigC::Signal1 scrollCB; /// - SigC::Signal2 workAreaKeyPress; + SigC::Signal2 workAreaKeyPress; /// - SigC::Signal3 workAreaButtonPress; + SigC::Signal3 workAreaButtonPress; /// - SigC::Signal3 workAreaButtonRelease; + SigC::Signal3 workAreaButtonRelease; /// - SigC::Signal3 workAreaMotionNotify; + SigC::Signal3 workAreaMotionNotify; /// SigC::Signal0 workAreaFocus; /// @@ -123,9 +125,9 @@ public: /// SigC::Signal0 workAreaLeave; /// - SigC::Signal3 workAreaDoubleClick; + SigC::Signal3 workAreaDoubleClick; /// - SigC::Signal3 workAreaTripleClick; + SigC::Signal3 workAreaTripleClick; /// emitted when an X client has requested our selection SigC::Signal0 selectionRequested; /// emitted when another X client has stolen our selection diff --git a/src/frontends/key_state.h b/src/frontends/key_state.h new file mode 100644 index 0000000000..c87972037e --- /dev/null +++ b/src/frontends/key_state.h @@ -0,0 +1,39 @@ +/** + * \file key_state.h + * Copyright 2002 the LyX Team + * Read the file COPYING + * + * Keyboard modifier state representation. + * + * \author John Levon + */ + +#ifndef KEY_STATE_H +#define KEY_STATE_H + +/// modifier key states +namespace key_modifier { + enum state { + none = 0, //< no modifiers held + ctrl = 1, //< control button held + alt = 2, //< alt/meta key held + shift = 4 //< shift key held + }; + + +inline state operator|(state const & s1, state const & s2) +{ + int const i1(static_cast(s1)); + int const i2(static_cast(s2)); + return static_cast(i1 | i2); +} + + +inline void operator|=(state & s1, state s2) +{ + s1 = static_cast(s1 | s2); +} + +} // namespace key_modifier + +#endif // KEY_STATE_H diff --git a/src/frontends/mouse_state.h b/src/frontends/mouse_state.h new file mode 100644 index 0000000000..84072e1855 --- /dev/null +++ b/src/frontends/mouse_state.h @@ -0,0 +1,34 @@ +/** + * \file mouse_state.h + * Copyright 2002 the LyX Team + * Read the file COPYING + * + * GUII representation of mouse presses and + * mouse button states + * + * \author John Levon + */ + +#ifndef MOUSE_STATE_H +#define MOUSE_STATE_H + +/// used both for presses and held during motion +namespace mouse_button { + + enum state { + none = 0, //< no buttons held + button1 = 1, //< mouse button 1 pressed + button2 = 2, + button3 = 4, + button4 = 8, + button5 = 16 + }; + +inline void operator|=(state & s1, state s2) +{ + s1 = static_cast(s1 | s2); +} + +} // namespace mouse_button + +#endif // MOUSE_STATE_H diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index edfa2e5dfa..529e21d512 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,42 @@ +2002-05-26 John Levon + + * inset.C: + * inset.h: + * insetbib.C: + * insetbib.h: + * insetcite.h: + * insetcite.C: + * insetcollapsable.C: + * insetcollapsable.h: + * inseterror.C: + * inseterror.h: + * insetert.C: + * insetert.h: + * insetexternal.C: + * insetexternal.h: + * insetfloatlist.C: + * insetfloatlist.h: + * insetgraphics.C: + * insetgraphics.h: + * insetinclude.C: + * insetinclude.h: + * insetindex.C: + * insetindex.h: + * insetlabel.C: + * insetlabel.h: + * insetparent.C: + * insetparent.h: + * insetref.C: + * insetref.h: + * insettabular.C: + * insettabular.h: + * insettext.C: + * insettext.h: + * insettoc.C: + * insettoc.h: + * inseturl.C: + * inseturl.h: use mouse_state. Kill insetKeyPress + 2002-05-24 John Levon * insetbib.C: diff --git a/src/insets/inset.C b/src/insets/inset.C index cfc35e603b..f20d5e3583 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -19,6 +19,7 @@ #include "BufferView.h" #include "support/lstrings.h" #include "frontends/Painter.h" +#include "frontends/mouse_state.h" #include "commandtags.h" #include "support/lstrings.h" #include "gettext.h" @@ -79,7 +80,7 @@ bool Inset::autoDelete() const } -void Inset::edit(BufferView *, int, int, unsigned int) +void Inset::edit(BufferView *, int, int, mouse_button::state) {} @@ -172,14 +173,14 @@ UpdatableInset::UpdatableInset(UpdatableInset const & in, bool same_id) {} -void UpdatableInset::insetButtonPress(BufferView *, int x, int y, int button) +void UpdatableInset::insetButtonPress(BufferView *, int x, int y, mouse_button::state button) { lyxerr[Debug::INFO] << "Inset Button Press x=" << x << ", y=" << y << ", button=" << button << endl; } -bool UpdatableInset::insetButtonRelease(BufferView *, int x, int y, int button) +bool UpdatableInset::insetButtonRelease(BufferView *, int x, int y, mouse_button::state button) { lyxerr[Debug::INFO] << "Inset Button Release x=" << x << ", y=" << y << ", button=" << button << endl; @@ -187,13 +188,7 @@ bool UpdatableInset::insetButtonRelease(BufferView *, int x, int y, int button) } -void UpdatableInset::insetKeyPress(XKeyEvent *) -{ - lyxerr[Debug::INFO] << "Inset Keypress" << endl; -} - - -void UpdatableInset::insetMotionNotify(BufferView *, int x, int y, int state) +void UpdatableInset::insetMotionNotify(BufferView *, int x, int y, mouse_button::state state) { lyxerr[Debug::INFO] << "Inset Motion Notify x=" << x << ", y=" << y << ", state=" << state << endl; @@ -229,7 +224,7 @@ void UpdatableInset::fitInsetCursor(BufferView *) const {} -void UpdatableInset::edit(BufferView *, int, int, unsigned int) +void UpdatableInset::edit(BufferView *, int, int, mouse_button::state) {} diff --git a/src/insets/inset.h b/src/insets/inset.h index 77c03f1988..3a54462dcf 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -17,8 +17,8 @@ #include #include "LString.h" -#include #include "commandtags.h" +#include "frontends/mouse_state.h" #include "LColor.h" class LyXFont; @@ -151,21 +151,21 @@ public: /// what appears in the minibuffer when opening virtual string const editMessage() const; /// - virtual void edit(BufferView *, int x, int y, unsigned int button); + virtual void edit(BufferView *, int x, int y, mouse_button::state button); /// virtual void edit(BufferView *, bool front = true); /// virtual EDITABLE editable() const; /// This is called when the user clicks inside an inset - virtual void insetButtonPress(BufferView *, int, int, int) {} + virtual void insetButtonPress(BufferView *, int, int, mouse_button::state) {} /// This is called when the user releases the button inside an inset // 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) + virtual bool insetButtonRelease(BufferView *, int, int, mouse_button::state) { return editable() == IS_EDITABLE; } /// This is called when the user moves the mouse inside an inset - virtual void insetMotionNotify(BufferView *, int , int , int) {} + virtual void insetMotionNotify(BufferView *, int , int, mouse_button::state) {} /// virtual bool isTextInset() const { return false; } /// @@ -447,22 +447,20 @@ public: /// virtual void getCursorPos(BufferView *, int &, int &) const {} /// - virtual void insetButtonPress(BufferView *, int x, int y, int button); + virtual void insetButtonPress(BufferView *, int x, int y, mouse_button::state 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); + int x, int y, mouse_button::state button); /// - virtual void insetKeyPress(XKeyEvent * ev); - /// - virtual void insetMotionNotify(BufferView *, int x, int y, int state); + virtual void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state); /// virtual void insetUnlock(BufferView *); /// - virtual void edit(BufferView *, int x, int y, unsigned int button); + virtual void edit(BufferView *, int x, int y, mouse_button::state button); /// virtual void edit(BufferView *, bool front = true); /// diff --git a/src/insets/insetbib.C b/src/insets/insetbib.C index 4e8c99fc59..53b7a89d5b 100644 --- a/src/insets/insetbib.C +++ b/src/insets/insetbib.C @@ -110,7 +110,7 @@ string const InsetBibKey::getScreenLabel(Buffer const *) const } -void InsetBibKey::edit(BufferView * bv, int, int, unsigned int) +void InsetBibKey::edit(BufferView * bv, int, int, mouse_button::state) { bv->owner()->getDialogs()->showBibitem(this); } @@ -118,7 +118,7 @@ void InsetBibKey::edit(BufferView * bv, int, int, unsigned int) void InsetBibKey::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } @@ -278,7 +278,7 @@ vector > const InsetBibtex::getKeys(Buffer const * buffer) } -void InsetBibtex::edit(BufferView * bv, int, int, unsigned int) +void InsetBibtex::edit(BufferView * bv, int, int, mouse_button::state) { bv->owner()->getDialogs()->showBibtex(this); } @@ -286,7 +286,7 @@ void InsetBibtex::edit(BufferView * bv, int, int, unsigned int) void InsetBibtex::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } diff --git a/src/insets/insetbib.h b/src/insets/insetbib.h index e1de692e35..2606948f59 100644 --- a/src/insets/insetbib.h +++ b/src/insets/insetbib.h @@ -43,7 +43,7 @@ public: /// virtual string const getScreenLabel(Buffer const *) const; /// - void edit(BufferView *, int x, int y, unsigned int button); + void edit(BufferView *, int x, int y, mouse_button::state button); /// void edit(BufferView * bv, bool front = true); /// @@ -93,7 +93,7 @@ public: /// Inset::Code lyxCode() const { return Inset::BIBTEX_CODE; } /// - void edit(BufferView *, int x, int y, unsigned int button); + void edit(BufferView *, int x, int y, mouse_button::state button); /// void edit(BufferView * bv, bool front = true); /// diff --git a/src/insets/insetcite.C b/src/insets/insetcite.C index a0b7ccf03b..c5cc7f21ff 100644 --- a/src/insets/insetcite.C +++ b/src/insets/insetcite.C @@ -307,7 +307,7 @@ string const InsetCitation::getScreenLabel(Buffer const * buffer) const } -void InsetCitation::edit(BufferView * bv, int, int, unsigned int) +void InsetCitation::edit(BufferView * bv, int, int, mouse_button::state) { // A call to edit() indicates that we're no longer loading the // buffer but doing some real work. @@ -320,7 +320,7 @@ void InsetCitation::edit(BufferView * bv, int, int, unsigned int) void InsetCitation::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } diff --git a/src/insets/insetcite.h b/src/insets/insetcite.h index 43269b797b..c4390a2e34 100644 --- a/src/insets/insetcite.h +++ b/src/insets/insetcite.h @@ -34,7 +34,7 @@ public: /// Inset::Code lyxCode() const { return Inset::CITE_CODE; } /// - void edit(BufferView *, int, int, unsigned int); + void edit(BufferView *, int, int, mouse_button::state); /// void edit(BufferView * bv, bool front = true); /// diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 39719b9051..00b3e869ec 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -235,7 +235,7 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, void InsetCollapsable::edit(BufferView * bv, int xp, int yp, - unsigned int button) + mouse_button::state button) { UpdatableInset::edit(bv, xp, yp, button); @@ -313,7 +313,7 @@ void InsetCollapsable::insetUnlock(BufferView * bv) void InsetCollapsable::insetButtonPress(BufferView * bv, - int x, int y, int button) + int x, int y, mouse_button::state button) { if (!collapsed_ && (y > button_bottom_y)) { LyXFont font(LyXFont::ALL_SANE); @@ -327,10 +327,10 @@ void InsetCollapsable::insetButtonPress(BufferView * bv, bool InsetCollapsable::insetButtonRelease(BufferView * bv, - int x, int y, int button) + int x, int y, mouse_button::state button) { bool ret = false; - if ((button != 3) && (x >= 0) && (x < button_length) && + if ((button != mouse_button::button3) && (x < button_length) && (y >= button_top_y) && (y <= button_bottom_y)) { if (collapsed_) { @@ -352,7 +352,7 @@ bool InsetCollapsable::insetButtonRelease(BufferView * bv, inset.ascent(bv, font)); ret = inset.insetButtonRelease(bv, x, yy, button); } - if ((button == 3) && !ret) { + if ((button == mouse_button::button3) && !ret) { return showInsetDialog(bv); } return ret; @@ -360,7 +360,7 @@ bool InsetCollapsable::insetButtonRelease(BufferView * bv, void InsetCollapsable::insetMotionNotify(BufferView * bv, - int x, int y, int state) + int x, int y, mouse_button::state state) { if (y > button_bottom_y) { LyXFont font(LyXFont::ALL_SANE); @@ -373,12 +373,6 @@ void InsetCollapsable::insetMotionNotify(BufferView * bv, } -void InsetCollapsable::insetKeyPress(XKeyEvent * xke) -{ - inset.insetKeyPress(xke); -} - - int InsetCollapsable::latex(Buffer const * buf, ostream & os, bool fragile, bool free_spc) const { diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index e7f496e5f8..d3dc3945ef 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -60,7 +60,7 @@ public: /// void update(BufferView *, LyXFont const &, bool =false); /// - void edit(BufferView *, int, int, unsigned int); + void edit(BufferView *, int, int, mouse_button::state); /// void edit(BufferView *, bool front = true); /// @@ -89,13 +89,11 @@ public: /// int insetInInsetY() const; /// - bool insetButtonRelease(BufferView *, int, int, int); + bool insetButtonRelease(BufferView *, int, int, mouse_button::state); /// - void insetButtonPress(BufferView *, int, int, int); + void insetButtonPress(BufferView *, int, int, mouse_button::state); /// - void insetMotionNotify(BufferView *, int, int, int); - /// - void insetKeyPress(XKeyEvent *); + void insetMotionNotify(BufferView *, int, int, mouse_button::state); /// UpdatableInset::RESULT localDispatch(BufferView *, kb_action, string const &); diff --git a/src/insets/inseterror.C b/src/insets/inseterror.C index 41928d99c5..dd1a12acd6 100644 --- a/src/insets/inseterror.C +++ b/src/insets/inseterror.C @@ -86,7 +86,7 @@ string const InsetError::editMessage() const } -void InsetError::edit(BufferView * bv, int, int, unsigned int) +void InsetError::edit(BufferView * bv, int, int, mouse_button::state) { bv->owner()->getDialogs()->showError(this); } @@ -94,5 +94,5 @@ void InsetError::edit(BufferView * bv, int, int, unsigned int) void InsetError::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } diff --git a/src/insets/inseterror.h b/src/insets/inseterror.h index fb9d00459e..34b1428f80 100644 --- a/src/insets/inseterror.h +++ b/src/insets/inseterror.h @@ -57,7 +57,7 @@ public: /// what appears in the minibuffer when opening string const editMessage() const; /// - void edit(BufferView *, int, int, unsigned int); + void edit(BufferView *, int, int, mouse_button::state); /// void edit(BufferView * bv, bool front = true); /// diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 67fa7d8c19..a7f743cf34 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -263,10 +263,9 @@ void InsetERT::updateStatus(BufferView * bv, bool swap) const } } - -void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button) +void InsetERT::edit(BufferView * bv, int x, int y, mouse_button::state button) { - if (button == 3) + if (button == mouse_button::button3) return; if (status_ == Inlined) { @@ -300,7 +299,7 @@ void InsetERT::edit(BufferView * bv, bool front) void InsetERT::insetButtonPress(BufferView * bv, - int x, int y, int button) + int x, int y, mouse_button::state button) { if (status_ == Inlined) { inset.insetButtonPress(bv, x, y, button); @@ -310,9 +309,10 @@ void InsetERT::insetButtonPress(BufferView * bv, } -bool InsetERT::insetButtonRelease(BufferView * bv, int x, int y, int button) +bool InsetERT::insetButtonRelease(BufferView * bv, int x, int y, + mouse_button::state button) { - if (button == 3) { + if (button == mouse_button::button3) { showInsetDialog(bv); return true; } @@ -338,7 +338,7 @@ bool InsetERT::insetButtonRelease(BufferView * bv, int x, int y, int button) void InsetERT::insetMotionNotify(BufferView * bv, - int x, int y, int state) + int x, int y, mouse_button::state state) { if (status_ == Inlined) { inset.insetMotionNotify(bv, x, y, state); diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 8f8c02d282..eee9f18599 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -67,7 +67,7 @@ public: void setFont(BufferView *, LyXFont const &, bool toggleall = false, bool selectall = false); /// - void edit(BufferView *, int, int, unsigned int); + void edit(BufferView *, int, int, mouse_button::state); /// void edit(BufferView * bv, bool front = true); /// @@ -75,11 +75,11 @@ public: /// SigC::Signal0 hideDialog; /// - void insetButtonPress(BufferView *, int x, int y, int button); + void insetButtonPress(BufferView *, int x, int y, mouse_button::state button); /// - bool insetButtonRelease(BufferView * bv, int x, int y, int button); + bool insetButtonRelease(BufferView * bv, int x, int y, mouse_button::state button); /// - void insetMotionNotify(BufferView *, int x, int y, int state); + void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state); /// int latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const; diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 3a43e5069d..6b21708458 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -77,7 +77,7 @@ string const InsetExternal::editMessage() const void InsetExternal::edit(BufferView * bv, - int /*x*/, int /*y*/, unsigned int /*button*/) + int /*x*/, int /*y*/, mouse_button::state) { view_ = bv; view_->owner()->getDialogs()->showExternal(this); @@ -86,7 +86,7 @@ void InsetExternal::edit(BufferView * bv, void InsetExternal::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } diff --git a/src/insets/insetexternal.h b/src/insets/insetexternal.h index 7cce4c5d58..209cfbb703 100644 --- a/src/insets/insetexternal.h +++ b/src/insets/insetexternal.h @@ -44,7 +44,7 @@ public: /// what appears in the minibuffer when opening virtual string const editMessage() const; /// - virtual void edit(BufferView *, int x, int y, unsigned int button); + virtual void edit(BufferView *, int x, int y, mouse_button::state button); /// virtual void edit(BufferView * bv, bool front = true); /// diff --git a/src/insets/insetfloatlist.C b/src/insets/insetfloatlist.C index 579989b378..2bebacd114 100644 --- a/src/insets/insetfloatlist.C +++ b/src/insets/insetfloatlist.C @@ -78,7 +78,7 @@ void InsetFloatList::read(Buffer const *, LyXLex & lex) } -void InsetFloatList::edit(BufferView * bv, int, int, unsigned int) +void InsetFloatList::edit(BufferView * bv, int, int, mouse_button::state) { bv->owner()->getDialogs()->showTOC(this); } @@ -86,7 +86,7 @@ void InsetFloatList::edit(BufferView * bv, int, int, unsigned int) void InsetFloatList::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } diff --git a/src/insets/insetfloatlist.h b/src/insets/insetfloatlist.h index 7452a2448e..19b03e8dbe 100644 --- a/src/insets/insetfloatlist.h +++ b/src/insets/insetfloatlist.h @@ -33,7 +33,7 @@ public: /// string const getScreenLabel(Buffer const *) const; /// - void edit(BufferView * bv, int, int, unsigned int); + void edit(BufferView * bv, int, int, mouse_button::state); /// void edit(BufferView * bv, bool front = true); /// diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 038a223697..108535e607 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -364,7 +364,7 @@ void InsetGraphics::updateInset(string const & filepath) const } -void InsetGraphics::edit(BufferView *bv, int, int, unsigned int) +void InsetGraphics::edit(BufferView *bv, int, int, mouse_button::state) { bv->owner()->getDialogs()->showGraphics(this); } @@ -372,7 +372,7 @@ void InsetGraphics::edit(BufferView *bv, int, int, unsigned int) void InsetGraphics::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index a26bc8dab2..d7920f402e 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -47,7 +47,7 @@ public: /// void draw(BufferView *, LyXFont const &, int, float &, bool) const; /// - void edit(BufferView *, int, int, unsigned int); + void edit(BufferView *, int, int, mouse_button::state); /// void edit(BufferView * bv, bool front = true); /// diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 3bda5bea60..6e1c520cbc 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -123,7 +123,7 @@ Inset * InsetInclude::clone(Buffer const & buffer, bool) const } -void InsetInclude::edit(BufferView * bv, int, int, unsigned int) +void InsetInclude::edit(BufferView * bv, int, int, mouse_button::state) { bv->owner()->getDialogs()->showInclude(this); } @@ -131,7 +131,7 @@ void InsetInclude::edit(BufferView * bv, int, int, unsigned int) void InsetInclude::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index 971e5d50ae..10bfea34a8 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -77,7 +77,7 @@ public: /// This returns the list of bibkeys on the child buffer std::vector< std::pair > const getKeys() const; /// - void edit(BufferView *, int x, int y, unsigned int button); + void edit(BufferView *, int x, int y, mouse_button::state button); /// void edit(BufferView * bv, bool front = true); /// diff --git a/src/insets/insetindex.C b/src/insets/insetindex.C index 85f2d2f395..1e5e2c6de3 100644 --- a/src/insets/insetindex.C +++ b/src/insets/insetindex.C @@ -25,7 +25,7 @@ string const InsetIndex::getScreenLabel(Buffer const *) const } -void InsetIndex::edit(BufferView * bv, int, int, unsigned int) +void InsetIndex::edit(BufferView * bv, int, int, mouse_button::state) { bv->owner()->getDialogs()->showIndex(this); } @@ -33,7 +33,7 @@ void InsetIndex::edit(BufferView * bv, int, int, unsigned int) void InsetIndex::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } diff --git a/src/insets/insetindex.h b/src/insets/insetindex.h index 88c76bab6b..32b0e2a905 100644 --- a/src/insets/insetindex.h +++ b/src/insets/insetindex.h @@ -35,7 +35,7 @@ public: /// EDITABLE editable() const { return IS_EDITABLE; } /// - void edit(BufferView *, int, int, unsigned int); + void edit(BufferView *, int, int, mouse_button::state); /// void edit(BufferView * bv, bool front = true); /// @@ -56,7 +56,7 @@ public: /// Updates needed features for this inset. void validate(LaTeXFeatures & features) const; /// - void edit(BufferView *, int, int, unsigned int) {} + void edit(BufferView *, int, int, mouse_button::state) {} /// void edit(BufferView *, bool = true) {} /// diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 64c77d8a90..f3126eaa38 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -42,7 +42,7 @@ vector const InsetLabel::getLabelList() const } -void InsetLabel::edit(BufferView * bv, int, int, unsigned int) +void InsetLabel::edit(BufferView * bv, int, int, mouse_button::state) { pair result = Alert::askForText(_("Enter label:"), getContents()); if (result.first) { @@ -70,7 +70,7 @@ void InsetLabel::edit(BufferView * bv, int, int, unsigned int) void InsetLabel::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } diff --git a/src/insets/insetlabel.h b/src/insets/insetlabel.h index bdd77f4e9c..823bf73071 100644 --- a/src/insets/insetlabel.h +++ b/src/insets/insetlabel.h @@ -33,7 +33,7 @@ public: /// Inset::Code lyxCode() const { return Inset::LABEL_CODE; } /// - void edit(BufferView *, int, int, unsigned int); + void edit(BufferView *, int, int, mouse_button::state); /// void edit(BufferView * bv, bool front = true); /// diff --git a/src/insets/insetparent.C b/src/insets/insetparent.C index 90f2d98fb4..4afdbab43c 100644 --- a/src/insets/insetparent.C +++ b/src/insets/insetparent.C @@ -44,8 +44,8 @@ string const InsetParent::getScreenLabel(Buffer const *) const } -void InsetParent::edit(BufferView * bv, int, int, unsigned int) -{ +void InsetParent::edit(BufferView * bv, int, int, mouse_button::state) +{ bv->owner()->getLyXFunc()-> dispatch(LFUN_CHILDOPEN, getContents()); } @@ -53,7 +53,7 @@ void InsetParent::edit(BufferView * bv, int, int, unsigned int) void InsetParent::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } diff --git a/src/insets/insetparent.h b/src/insets/insetparent.h index 62f9224945..6bb544b40e 100644 --- a/src/insets/insetparent.h +++ b/src/insets/insetparent.h @@ -39,7 +39,7 @@ public: /// Inset::Code lyxCode() const { return Inset::PARENT_CODE; } /// - void edit(BufferView *, int, int, unsigned int); + void edit(BufferView *, int, int, mouse_button::state); /// void edit(BufferView * bv, bool front = true); /// diff --git a/src/insets/insetref.C b/src/insets/insetref.C index c9ad260e20..0f39f93b84 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -22,13 +22,13 @@ InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf, bool) : InsetCommand(p), isLatex(buf.isLatex()) {} -void InsetRef::edit(BufferView * bv, int, int, unsigned int button) +void InsetRef::edit(BufferView * bv, int, int, mouse_button::state button) { // Eventually trigger dialog with button 3 not 1 - if (button == 3) + if (button == mouse_button::button3) bv->owner()->getLyXFunc()-> dispatch(LFUN_REF_GOTO, getContents()); - else if (button == 1) + else if (button == mouse_button::button1) bv->owner()->getDialogs()->showRef(this); } diff --git a/src/insets/insetref.h b/src/insets/insetref.h index 886c877104..45c09a2270 100644 --- a/src/insets/insetref.h +++ b/src/insets/insetref.h @@ -50,7 +50,7 @@ public: /// Inset::Code lyxCode() const { return Inset::REF_CODE; } /// - void edit(BufferView *, int, int, unsigned int); + void edit(BufferView *, int, int, mouse_button::state); /// void edit(BufferView * bv, bool front = true); /// diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 49eaf05a24..8ac934c79d 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -551,7 +551,7 @@ string const InsetTabular::editMessage() const } -void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button) +void InsetTabular::edit(BufferView * bv, int x, int y, mouse_button::state button) { UpdatableInset::edit(bv, x, y, button); @@ -566,7 +566,7 @@ void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button) setPos(bv, x, y); clearSelection(); finishUndo(); - if (insetHit(bv, x, y) && (button != 3)) { + if (insetHit(bv, x, y) && (button != mouse_button::button3)) { activateCellInsetAbs(bv, x, y, button); } } @@ -766,9 +766,9 @@ bool InsetTabular::insertInset(BufferView * bv, Inset * inset) } -void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button) +void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, mouse_button::state button) { - if (hasSelection() && (button == 3)) + if (hasSelection() && (button == mouse_button::button3)) return; if (hasSelection()) { @@ -815,7 +815,7 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button) updateLocal(bv, CELL, false); the_locking_inset = 0; } - if (button == 2) { + if (button == mouse_button::button2) { localDispatch(bv, LFUN_PASTESELECTION, "paragraph"); return; } @@ -833,13 +833,13 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button) bool InsetTabular::insetButtonRelease(BufferView * bv, - int x, int y, int button) + int x, int y, mouse_button::state button) { bool ret = false; if (the_locking_inset) ret = the_locking_inset->insetButtonRelease(bv, x - inset_x, y - inset_y, button); - if (button == 3 && !ret) { + if (button == mouse_button::button3 && !ret) { bv->owner()->getDialogs()->showTabular(this); return true; } @@ -847,7 +847,7 @@ bool InsetTabular::insetButtonRelease(BufferView * bv, } -void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, int button) +void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::state button) { if (the_locking_inset) { the_locking_inset->insetMotionNotify(bv, @@ -871,15 +871,6 @@ void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, int button) } -void InsetTabular::insetKeyPress(XKeyEvent * xke) -{ - if (the_locking_inset) { - the_locking_inset->insetKeyPress(xke); - return; - } -} - - UpdatableInset::RESULT InsetTabular::localDispatch(BufferView * bv, kb_action action, string const & arg) @@ -1635,7 +1626,7 @@ UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock) if (!moved) return FINISHED; if (lock) { // behind the inset - if (activateCellInset(bv, 0, 0, 0, true)) + if (activateCellInset(bv, 0, 0, mouse_button::none, true)) return DISPATCHED; } resetPos(bv); @@ -1707,7 +1698,7 @@ bool InsetTabular::moveNextCell(BufferView * bv, bool lock) if (lock) { bool rtl = tabular->GetCellInset(actcell)->paragraph()-> isRightToLeftPar(bv->buffer()->params); - activateCellInset(bv, 0, 0, 0, !rtl); + activateCellInset(bv, 0, 0, mouse_button::none, !rtl); } resetPos(bv); return true; @@ -1736,7 +1727,7 @@ bool InsetTabular::movePrevCell(BufferView * bv, bool lock) if (lock) { bool rtl = tabular->GetCellInset(actcell)->paragraph()-> isRightToLeftPar(bv->buffer()->params); - activateCellInset(bv, 0, 0, 0, !rtl); + activateCellInset(bv, 0, 0, mouse_button::none, !rtl); } resetPos(bv); return true; @@ -2170,7 +2161,7 @@ void InsetTabular::tabularFeatures(BufferView * bv, } -bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, int button, +bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, mouse_button::state button, bool behind) { UpdatableInset * inset = @@ -2191,7 +2182,7 @@ bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, int button, bool InsetTabular::activateCellInsetAbs(BufferView * bv, int x, int y, - int button) + mouse_button::state button) { inset_x = cursor_.x() - top_x + tabular->GetBeginningOfTextInCell(actcell); @@ -2695,7 +2686,7 @@ InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const // otherwise we have to lock the next inset and ask for it's selecttion UpdatableInset * inset = static_cast(tabular->GetCellInset(actcell)); - inset->edit(bv, 0, 0, 0); + inset->edit(bv, 0, 0, mouse_button::none); string const str(selectNextWordInt(bv, value)); nodraw(false); if (!str.empty()) diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index cf81f37e1b..7e6fbd2dcc 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -101,7 +101,7 @@ public: /// string const editMessage() const; /// - void edit(BufferView *, int x, int y, unsigned int); + void edit(BufferView *, int x, int y, mouse_button::state); /// void edit(BufferView * bv, bool front = true); /// @@ -132,13 +132,11 @@ public: /// bool display() const { return tabular->IsLongTabular(); } /// - bool insetButtonRelease(BufferView *, int, int, int); + bool insetButtonRelease(BufferView *, int, int, mouse_button::state); /// - void insetButtonPress(BufferView *, int, int, int); + void insetButtonPress(BufferView *, int, int, mouse_button::state); /// - void insetMotionNotify(BufferView *, int, int, int); - /// - void insetKeyPress(XKeyEvent *); + void insetMotionNotify(BufferView *, int, int, mouse_button::state); /// UpdatableInset::RESULT localDispatch(BufferView *, kb_action, string const &); @@ -288,11 +286,11 @@ private: } /// bool activateCellInset(BufferView *, int x = 0, int y = 0, - int button = 0, + mouse_button::state button = mouse_button::none, bool behind = false); /// bool activateCellInsetAbs(BufferView *, int x = 0, int y = 0, - int button = 0); + mouse_button::state button = mouse_button::none); /// bool insetHit(BufferView * bv, int x, int y) const; /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index fa3b94940b..63cf4106b5 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -675,7 +675,7 @@ string const InsetText::editMessage() const } -void InsetText::edit(BufferView * bv, int x, int y, unsigned int button) +void InsetText::edit(BufferView * bv, int x, int y, mouse_button::state button) { UpdatableInset::edit(bv, x, y, button); @@ -698,7 +698,8 @@ void InsetText::edit(BufferView * bv, int x, int y, unsigned int button) // we put here -1 and not button as now the button in the // edit call should not be needed we will fix this in 1.3.x // cycle hopefully (Jug 20020509) - if (!checkAndActivateInset(bv, x, tmp_y, -1)) { + // FIXME: GUII I've changed this to none: probably WRONG + if (!checkAndActivateInset(bv, x, tmp_y, mouse_button::none)) { lt->setCursorFromCoordinates(bv, x - drawTextXOffset, y + insetAscent); lt->cursor.x_fix(lt->cursor.x()); @@ -994,7 +995,8 @@ bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset) } -void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button) +void InsetText::insetButtonPress(BufferView * bv, + int x, int y, mouse_button::state button) { no_selection = true; @@ -1054,9 +1056,9 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button) return; } } - if (!inset) { // && (button == 2)) { + if (!inset) { // && (button == mouse_button::button2)) { bool paste_internally = false; - if ((button == 2) && getLyXText(bv)->selection.set()) { + if ((button == mouse_button::button2) && getLyXText(bv)->selection.set()) { localDispatch(bv, LFUN_COPY, ""); paste_internally = true; } @@ -1092,7 +1094,7 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button) // Insert primary selection with middle mouse // if there is a local selection in the current buffer, // insert this - if (button == 2) { + if (button == mouse_button::button2) { if (paste_internally) localDispatch(bv, LFUN_PASTE, ""); else @@ -1106,7 +1108,8 @@ void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button) } -bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button) +bool InsetText::insetButtonRelease(BufferView * bv, + int x, int y, mouse_button::state button) { no_selection = true; if (the_locking_inset) { @@ -1136,7 +1139,7 @@ bool InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button) } -void InsetText::insetMotionNotify(BufferView * bv, int x, int y, int state) +void InsetText::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::state state) { if (the_locking_inset) { the_locking_inset->insetMotionNotify(bv, x - inset_x, @@ -1173,15 +1176,6 @@ void InsetText::insetMotionNotify(BufferView * bv, int x, int y, int state) } -void InsetText::insetKeyPress(XKeyEvent * xke) -{ - if (the_locking_inset) { - the_locking_inset->insetKeyPress(xke); - return; - } -} - - UpdatableInset::RESULT InsetText::localDispatch(BufferView * bv, kb_action action, string const & arg) @@ -2069,7 +2063,7 @@ bool InsetText::checkAndActivateInset(BufferView * bv, bool front) bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y, - int button) + mouse_button::state button) { x -= drawTextXOffset; int dummyx = x; @@ -2078,7 +2072,9 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y, // we only do the edit() call if the inset was hit by the mouse // or if it is a highly editable inset. So we should call this // function from our own edit with button < 0. - if (button < 0 && !isHighlyEditableInset(inset)) + // FIXME: GUII jbl. I've changed this to ::none for now which is probably + // WRONG + if (button == mouse_button::none && !isHighlyEditableInset(inset)) return false; if (inset) { diff --git a/src/insets/insettext.h b/src/insets/insettext.h index df0ddc702a..de1e96c9fb 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -107,7 +107,7 @@ public: /// string const editMessage() const; /// - void edit(BufferView *, int, int, unsigned int); + void edit(BufferView *, int, int, mouse_button::state); /// void edit(BufferView *, bool front = true); /// @@ -124,13 +124,11 @@ public: /// bool updateInsetInInset(BufferView *, Inset *); /// - bool insetButtonRelease(BufferView *, int, int, int); + bool insetButtonRelease(BufferView *, int, int, mouse_button::state); /// - void insetButtonPress(BufferView *, int, int, int); + void insetButtonPress(BufferView *, int, int, mouse_button::state); /// - void insetMotionNotify(BufferView *, int, int, int); - /// - void insetKeyPress(XKeyEvent *); + void insetMotionNotify(BufferView *, int, int, mouse_button::state); /// UpdatableInset::RESULT localDispatch(BufferView *, kb_action, string const &); @@ -317,7 +315,7 @@ private: bool checkAndActivateInset(BufferView * bv, bool front); /// bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0, - int button = 0); + mouse_button::state button = mouse_button::none); /// void removeNewlines(); /// diff --git a/src/insets/insettoc.C b/src/insets/insettoc.C index 5ba5af0665..b2385abd8b 100644 --- a/src/insets/insettoc.C +++ b/src/insets/insettoc.C @@ -36,7 +36,7 @@ Inset::Code InsetTOC::lyxCode() const } -void InsetTOC::edit(BufferView * bv, int, int, unsigned int) +void InsetTOC::edit(BufferView * bv, int, int, mouse_button::state) { bv->owner()->getDialogs()->showTOC(this); } @@ -44,7 +44,7 @@ void InsetTOC::edit(BufferView * bv, int, int, unsigned int) void InsetTOC::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } diff --git a/src/insets/insettoc.h b/src/insets/insettoc.h index da09775408..26d75935a3 100644 --- a/src/insets/insettoc.h +++ b/src/insets/insettoc.h @@ -32,7 +32,7 @@ public: /// string const getScreenLabel(Buffer const *) const; /// - void edit(BufferView * bv, int, int, unsigned int); + void edit(BufferView * bv, int, int, mouse_button::state); /// void edit(BufferView * bv, bool front = true); /// diff --git a/src/insets/inseturl.C b/src/insets/inseturl.C index 1fbad24d33..4a61ad8593 100644 --- a/src/insets/inseturl.C +++ b/src/insets/inseturl.C @@ -21,7 +21,7 @@ InsetUrl::InsetUrl(InsetCommandParams const & p, bool) {} -void InsetUrl::edit(BufferView * bv, int, int, unsigned int) +void InsetUrl::edit(BufferView * bv, int, int, mouse_button::state) { bv->owner()->getDialogs()->showUrl(this); } @@ -29,7 +29,7 @@ void InsetUrl::edit(BufferView * bv, int, int, unsigned int) void InsetUrl::edit(BufferView * bv, bool) { - edit(bv, 0, 0, 0); + edit(bv, 0, 0, mouse_button::none); } diff --git a/src/insets/inseturl.h b/src/insets/inseturl.h index 4712afd948..f99d63244e 100644 --- a/src/insets/inseturl.h +++ b/src/insets/inseturl.h @@ -39,7 +39,7 @@ public: /// EDITABLE editable() const { return IS_EDITABLE; } /// - void edit(BufferView *, int, int, unsigned int); + void edit(BufferView *, int, int, mouse_button::state); /// void edit(BufferView * bv, bool front = true); /// diff --git a/src/kbmap.C b/src/kbmap.C index 31d4c7b5a7..296a713e92 100644 --- a/src/kbmap.C +++ b/src/kbmap.C @@ -28,16 +28,15 @@ using std::endl; enum { ModsMask = ShiftMask | ControlMask | Mod1Mask }; -string const kb_keymap::printKeysym(unsigned int key, unsigned int mod) +string const kb_keymap::printKeysym(unsigned int key, key_modifier::state mod) { string buf; - mod &= ModsMask; char const * const s = XKeysymToString(key); - if (mod & ShiftMask) buf += "S-"; - if (mod & ControlMask) buf += "C-"; - if (mod & Mod1Mask) buf += "M-"; + if (mod & key_modifier::shift) buf += "S-"; + if (mod & key_modifier::ctrl) buf += "C-"; + if (mod & key_modifier::alt) buf += "M-"; if (s) buf += s; return buf; } @@ -68,7 +67,7 @@ char kb_keymap::getiso(unsigned int c) string const kb_keymap::printKey(kb_key const & key) const { - return printKeysym(key.code, key.mod & 0xffff); + return printKeysym(key.code, key.mod.first); } @@ -96,7 +95,7 @@ string::size_type kb_keymap::bind(string const & seq, int action) int kb_keymap::lookup(unsigned int key, - unsigned int mod, kb_sequence * seq) const + key_modifier::state mod, kb_sequence * seq) const { if (table.empty()) { seq->curmap = seq->stdmap; @@ -104,14 +103,13 @@ int kb_keymap::lookup(unsigned int key, return LFUN_UNKNOWN_ACTION; } - //suppress modifier bits we do not handle - mod &= ModsMask; - for (Table::const_iterator cit = table.begin(); cit != table.end(); ++cit) { - unsigned int const msk1 = cit->mod & 0xffff; - unsigned int const msk0 = (cit->mod >> 16) & 0xffff; - if (cit->code == key && (mod & ~msk0) == msk1) { + key_modifier::state mask(cit->mod.second); + key_modifier::state check = + static_cast(mod & ~mask); + + if (cit->code == key && cit->mod.first == check) { // match found if (cit->table.get()) { // this is a prefix key - set new map @@ -150,11 +148,12 @@ void kb_keymap::defkey(kb_sequence * seq, int action, unsigned int r) unsigned int const code = seq->sequence[r]; if (code == NoSymbol) return; - unsigned int const modmsk = seq->modifiers[r]; + key_modifier::state const mod1 = seq->modifiers[r].first; + key_modifier::state const mod2 = seq->modifiers[r].second; // check if key is already there for (Table::iterator it = table.begin(); it != table.end(); ++it) { - if (code == it->code && modmsk == it->mod) { + if (code == it->code && mod1 == it->mod.first && mod2 == it->mod.second) { // overwrite binding if (r + 1 == seq->length()) { lyxerr[Debug::KBMAP] @@ -181,7 +180,7 @@ void kb_keymap::defkey(kb_sequence * seq, int action, unsigned int r) Table::iterator newone = table.insert(table.end(), kb_key()); newone->code = code; - newone->mod = modmsk; + newone->mod = seq->modifiers[r]; if (r + 1 == seq->length()) { newone->action = action; newone->table.reset(); diff --git a/src/kbmap.h b/src/kbmap.h index 3331a0a037..cfad1f1c4b 100644 --- a/src/kbmap.h +++ b/src/kbmap.h @@ -16,6 +16,7 @@ #endif #include "LString.h" +#include "frontends/key_state.h" #include @@ -44,7 +45,7 @@ public: * @return the action / LFUN_PREFIX / LFUN_UNKNOWN_ACTION */ int lookup(unsigned int key, - unsigned int mod, kb_sequence * seq) const; + key_modifier::state mod, kb_sequence * seq) const; /// Given an action, find all keybindings. string const findbinding(int action, @@ -55,19 +56,21 @@ public: * @param key the key * @param mod the modifiers */ - static string const printKeysym(unsigned int key, unsigned int mod); + static string const printKeysym(unsigned int key, key_modifier::state mod); /// return the ISO value of a keysym static char getiso(unsigned int i); private: + typedef std::pair modifier_pair; + /// struct kb_key { /// Keysym unsigned int code; /// Modifier masks - unsigned int mod; + modifier_pair mod; /// Keymap for prefix keys boost::shared_ptr table; diff --git a/src/kbsequence.C b/src/kbsequence.C index fa93e556b7..4292a9b90b 100644 --- a/src/kbsequence.C +++ b/src/kbsequence.C @@ -18,12 +18,14 @@ #pragma implementation #endif +#include "frontends/mouse_state.h" #include "kbsequence.h" #include "kbmap.h" #include "commandtags.h" #include "debug.h" +using std::make_pair; using std::vector; using std::endl; using std::hex; @@ -35,7 +37,7 @@ using std::dec; enum { ModsMask = ShiftMask | ControlMask | Mod1Mask }; -int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod) +int kb_sequence::addkey(unsigned int key, key_modifier::state mod, key_modifier::state nmod) { // adding a key to a deleted sequence // starts a new sequence @@ -46,7 +48,7 @@ int kb_sequence::addkey(unsigned int key, unsigned int mod, unsigned int nmod) modifiers.clear(); } - modifiers.push_back(mod + (nmod << 16)); + modifiers.push_back(make_pair(mod, nmod)); sequence.push_back(key); ++length_; @@ -63,8 +65,8 @@ string::size_type kb_sequence::parse(string const & s) if (s.empty()) return 1; string::size_type i = 0; - unsigned int mod = 0; - unsigned int nmod = 0; + key_modifier::state mod = key_modifier::none; + key_modifier::state nmod = key_modifier::none; while (i < s.length()) { if (s[i] == ' ') ++i; @@ -74,15 +76,15 @@ string::size_type kb_sequence::parse(string const & s) if (i + 1 < s.length() && s[i + 1] == '-') { switch (s[i]) { case 's': case 'S': - mod |= ShiftMask; + mod |= key_modifier::shift; i += 2; continue; case 'c': case 'C': - mod |= ControlMask; + mod |= key_modifier::ctrl; i += 2; continue; case 'm': case 'M': - mod |= Mod1Mask; + mod |= key_modifier::alt; i += 2; continue; default: @@ -92,15 +94,15 @@ string::size_type kb_sequence::parse(string const & s) && s[i + 2] == '-') { switch (s[i + 1]) { case 's': case 'S': - nmod |= ShiftMask; + nmod |= key_modifier::shift; i += 3; continue; case 'c': case 'C': - nmod |= ControlMask; + nmod |= key_modifier::ctrl; i += 3; continue; case 'm': case 'M': - nmod |= Mod1Mask; + nmod |= key_modifier::alt; i += 3; continue; default: @@ -122,7 +124,7 @@ string::size_type kb_sequence::parse(string const & s) i = j; addkey(key, mod, nmod); - mod = 0; + mod = key_modifier::none; } } @@ -143,7 +145,7 @@ string const kb_sequence::print() const // return buf; for (vector::size_type i = 0; i < length_; ++i) { - buf += kb_keymap::printKeysym(sequence[i], modifiers[i] & 0xffff); + buf += kb_keymap::printKeysym(sequence[i], modifiers[i].first); // append a blank if (i + 1 < length_) { diff --git a/src/kbsequence.h b/src/kbsequence.h index e00382d34e..46cda83795 100644 --- a/src/kbsequence.h +++ b/src/kbsequence.h @@ -12,9 +12,13 @@ #pragma interface #endif -#include +#include + +#include "frontends/key_state.h" #include "LString.h" +#include + class kb_keymap; /// Holds a key sequence and the current and standard keymaps @@ -31,11 +35,13 @@ public: /** * Add a key to the key sequence and look it up in the curmap * if the latter is defined. + * @param text the text from the key event * @param mod modifier mask * @param nmod which modifiers to mask out for equality test * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION */ - int addkey(unsigned int key, unsigned int mod, unsigned int nmod = 0); + int addkey(unsigned int text, key_modifier::state mod, + key_modifier::state nmod = key_modifier::none); /** * Add a sequence of keys from a string to the sequence @@ -96,8 +102,9 @@ private: */ std::vector sequence; + typedef std::pair modifier_pair; /// modifiers for keys in the sequence - std::vector modifiers; + std::vector modifiers; /// Current length of key sequence std::vector::size_type length_; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 0bcf32f667..d1c33e2d14 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -165,7 +165,7 @@ LyXFunc::LyXFunc(LyXView * o) keyseq(toplevel_keymap.get(), toplevel_keymap.get()), cancel_meta_seq(toplevel_keymap.get(), toplevel_keymap.get()) { - meta_fake_bit = 0; + meta_fake_bit = key_modifier::none; lyx_dead_action = LFUN_NOACTION; lyx_calling_dead_action = LFUN_NOACTION; } @@ -222,7 +222,7 @@ void LyXFunc::handleKeyFunc(kb_action action) } -void LyXFunc::processKeySym(KeySym keysym, unsigned int state) +void LyXFunc::processKeySym(KeySym keysym, key_modifier::state state) { string argument; @@ -232,8 +232,7 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state) lyxerr << "KeySym is " << stm << "[" - << keysym << "] State is [" - << state << "]" + << keysym << endl; } // Do nothing if we have nothing (JMarc) @@ -256,33 +255,30 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state) // cancel and meta-fake keys. RVDK_PATCH_5 cancel_meta_seq.reset(); - int action = cancel_meta_seq.addkey(keysym, state - &(ShiftMask|ControlMask - |Mod1Mask)); + int action = cancel_meta_seq.addkey(keysym, state); if (lyxerr.debugging(Debug::KEY)) { lyxerr << "action first set to [" << action << "]" << endl; } // When not cancel or meta-fake, do the normal lookup. // Note how the meta_fake Mod1 bit is OR-ed in and reset afterwards. - // Mostly, meta_fake_bit = 0. RVDK_PATCH_5. + // Mostly, meta_fake_bit = key_modifier::none. RVDK_PATCH_5. if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) { +#if 0 if (lyxerr.debugging(Debug::KEY)) { lyxerr << "meta_fake_bit is [" << meta_fake_bit << "]" << endl; } +#endif // remove Caps Lock and Mod2 as a modifiers - action = keyseq.addkey(keysym, - (state | meta_fake_bit) - &(ShiftMask|ControlMask - |Mod1Mask)); + action = keyseq.addkey(keysym, (state | meta_fake_bit)); if (lyxerr.debugging(Debug::KEY)) { lyxerr << "action now set to [" << action << "]" << endl; } } // Dont remove this unless you know what you are doing. - meta_fake_bit = 0; + meta_fake_bit = key_modifier::none; // can this happen now ? if (action == LFUN_NOACTION) { @@ -307,7 +303,7 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state) if (action == LFUN_UNKNOWN_ACTION) { // It is unknown, but what if we remove all // the modifiers? (Lgb) - action = keyseq.addkey(keysym, 0); + action = keyseq.addkey(keysym, key_modifier::none); if (lyxerr.debugging(Debug::KEY)) { lyxerr << "Removing modifiers...\n" @@ -1075,7 +1071,7 @@ string const LyXFunc::dispatch(kb_action action, string argument) case LFUN_CANCEL: // RVDK_PATCH_5 keyseq.reset(); - meta_fake_bit = 0; + meta_fake_bit = key_modifier::none; if (owner->view()->available()) // cancel any selection dispatch(LFUN_MARK_OFF); @@ -1084,7 +1080,7 @@ string const LyXFunc::dispatch(kb_action action, string argument) case LFUN_META_FAKE: // RVDK_PATCH_5 { - meta_fake_bit = Mod1Mask; + meta_fake_bit = key_modifier::alt; setMessage(keyseq.print()); } break; diff --git a/src/lyxfunc.h b/src/lyxfunc.h index ec8898c242..b394f0de57 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -9,6 +9,8 @@ #include #include +#include "frontends/mouse_state.h" +#include "frontends/key_state.h" #include "commandtags.h" // for kb_action enum #include "FuncStatus.h" #include "kbsequence.h" @@ -52,7 +54,7 @@ public: void initMiniBuffer(); /// - void processKeySym(KeySym k, unsigned int state); + void processKeySym(KeySym key, key_modifier::state state); /// we need one internal which is called from inside LyXAction and /// can contain the string argument. @@ -89,7 +91,7 @@ private: /// kb_sequence cancel_meta_seq; /// - unsigned meta_fake_bit; + key_modifier::state meta_fake_bit; /// void moveCursorUpdate(bool flag = true, bool selecting = false); /// @@ -139,7 +141,7 @@ private: inline bool LyXFunc::wasMetaKey() const { - return (meta_fake_bit != 0); + return (meta_fake_bit != key_modifier::none); } diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 0cd81a4c43..41a703f64b 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,9 @@ +2002-05-26 John Levon + + * formulabase.C: + * formulabase.h: + * math_inset.h: use mouse_state. Kill insetKeyPress + 2002-05-24 John Levon * math_support.C: font loader moved diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index d01d39edc7..abbdd0831c 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -34,8 +34,8 @@ #include "math_support.h" #include "support/lstrings.h" #include "frontends/LyXView.h" -#include "frontends/Painter.h" #include "frontends/font_metrics.h" +#include "frontends/mouse_state.h" #include "Lsstream.h" #include "math_arrayinset.h" #include "math_charinset.h" @@ -73,7 +73,7 @@ bool openNewInset(BufferView * bv, UpdatableInset * new_inset) delete new_inset; return false; } - new_inset->edit(bv, 0, 0, 0); + new_inset->edit(bv, 0, 0, mouse_button::none); return true; } @@ -142,7 +142,7 @@ string const InsetFormulaBase::editMessage() const } -void InsetFormulaBase::edit(BufferView * bv, int x, int y, unsigned int) +void InsetFormulaBase::edit(BufferView * bv, int x, int y, mouse_button::state) { if (!bv->lockInset(this)) lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl; @@ -278,7 +278,7 @@ void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty) bool InsetFormulaBase::insetButtonRelease(BufferView * bv, - int /*x*/, int /*y*/, int button) + int /*x*/, int /*y*/, mouse_button::state button) { //lyxerr << "insetButtonRelease: " << x << " " << y << "\n"; @@ -288,7 +288,7 @@ bool InsetFormulaBase::insetButtonRelease(BufferView * bv, showInsetCursor(bv); bv->updateInset(this, false); - if (button == 3) { + if (button == mouse_button::button3) { // launch math panel for right mouse button bv->owner()->getDialogs()->showMathPanel(); return true; @@ -298,7 +298,7 @@ bool InsetFormulaBase::insetButtonRelease(BufferView * bv, void InsetFormulaBase::insetButtonPress(BufferView * bv, - int x, int y, int button) + int x, int y, mouse_button::state button) { //lyxerr << "insetButtonPress: " // << x << " " << y << " but: " << button << "\n"; @@ -337,7 +337,7 @@ void InsetFormulaBase::insetButtonPress(BufferView * bv, break; } #else - if (button == 1 || !mathcursor) { + if (button == mouse_button::button1 || !mathcursor) { delete mathcursor; mathcursor = new MathCursor(this, x == 0); metrics(bv); @@ -359,7 +359,7 @@ void InsetFormulaBase::insetButtonPress(BufferView * bv, void InsetFormulaBase::insetMotionNotify(BufferView * bv, - int x, int y, int /*button*/) + int x, int y, mouse_button::state) { if (!mathcursor) return; @@ -383,12 +383,6 @@ void InsetFormulaBase::insetMotionNotify(BufferView * bv, } -void InsetFormulaBase::insetKeyPress(XKeyEvent *) -{ - lyxerr[Debug::MATHED] << "Used InsetFormulaBase::InsetKeyPress." << endl; -} - - UpdatableInset::RESULT InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, string const & arg) diff --git a/src/mathed/formulabase.h b/src/mathed/formulabase.h index 306c2d13e3..1f3f215792 100644 --- a/src/mathed/formulabase.h +++ b/src/mathed/formulabase.h @@ -21,6 +21,7 @@ #include #include "insets/inset.h" +#include "frontends/mouse_state.h" #include "lyxfont.h" // only for getType(): @@ -64,7 +65,7 @@ public: /// what appears in the minibuffer when opening virtual string const editMessage() const; /// - virtual void edit(BufferView *, int x, int y, unsigned int button); + virtual void edit(BufferView *, int x, int y, mouse_button::state button); /// virtual void edit(BufferView *, bool front = true); /// @@ -78,13 +79,11 @@ public: /// virtual void toggleInsetSelection(BufferView * bv); /// - virtual void insetButtonPress(BufferView *, int x, int y, int button); + virtual void insetButtonPress(BufferView *, int x, int y, mouse_button::state button); /// - virtual bool insetButtonRelease(BufferView *, int x, int y, int button); + virtual bool insetButtonRelease(BufferView *, int x, int y, mouse_button::state button); /// - virtual void insetKeyPress(XKeyEvent * ev); - /// - virtual void insetMotionNotify(BufferView *, int x, int y, int state); + virtual void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state); /// virtual void insetUnlock(BufferView *); diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index eafdc3e2bb..65f3d15e6c 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -28,6 +28,7 @@ #pragma interface #endif +#include "frontends/mouse_state.h" #include "math_xdata.h" #include "math_defs.h" @@ -224,7 +225,7 @@ public: virtual bool needsBraces() const { return true; } /// - virtual void edit(BufferView *, int, int, unsigned int) {} + virtual void edit(BufferView *, int, int, mouse_button::state) {} /// request "external features" virtual void validate(LaTeXFeatures & features) const; diff --git a/src/text2.C b/src/text2.C index 9873163553..f51d91178d 100644 --- a/src/text2.C +++ b/src/text2.C @@ -2332,7 +2332,7 @@ void LyXText::cursorUp(BufferView * bview, bool selecting) const Inset * inset_hit = bview->checkInsetHit(const_cast(this), x, y1); if (inset_hit && isHighlyEditableInset(inset_hit)) { - inset_hit->edit(bview, x, y - (y2 - y1), 0); + inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none); } } #else @@ -2356,7 +2356,7 @@ void LyXText::cursorDown(BufferView * bview, bool selecting) const Inset * inset_hit = bview->checkInsetHit(const_cast(this), x, y1); if (inset_hit && isHighlyEditableInset(inset_hit)) { - inset_hit->edit(bview, x, y - (y2 - y1), 0); + inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none); } } #else -- 2.39.5