]> git.lyx.org Git - features.git/commitdiff
static_cast-based key/mouse-state. Kill insetKeyPress.
authorJohn Levon <levon@movementarian.org>
Sun, 26 May 2002 17:33:14 +0000 (17:33 +0000)
committerJohn Levon <levon@movementarian.org>
Sun, 26 May 2002 17:33:14 +0000 (17:33 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4210 a592a061-630c-0410-9148-cb99ea01b6c8

57 files changed:
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/ChangeLog
src/frontends/ChangeLog
src/frontends/Makefile.am
src/frontends/WorkArea.C
src/frontends/WorkArea.h
src/frontends/key_state.h [new file with mode: 0644]
src/frontends/mouse_state.h [new file with mode: 0644]
src/insets/ChangeLog
src/insets/inset.C
src/insets/inset.h
src/insets/insetbib.C
src/insets/insetbib.h
src/insets/insetcite.C
src/insets/insetcite.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetexternal.C
src/insets/insetexternal.h
src/insets/insetfloatlist.C
src/insets/insetfloatlist.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetindex.C
src/insets/insetindex.h
src/insets/insetlabel.C
src/insets/insetlabel.h
src/insets/insetparent.C
src/insets/insetparent.h
src/insets/insetref.C
src/insets/insetref.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/insettoc.C
src/insets/insettoc.h
src/insets/inseturl.C
src/insets/inseturl.h
src/kbmap.C
src/kbmap.h
src/kbsequence.C
src/kbsequence.h
src/lyxfunc.C
src/lyxfunc.h
src/mathed/ChangeLog
src/mathed/formulabase.C
src/mathed/formulabase.h
src/mathed/math_inset.h
src/text2.C

index 0b52a1754e0418fb2aee1be86e1fda8a542151ed..3980058af262bf03467135c255b0722ee330ee0d 100644 (file)
@@ -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;
index 37024053850d8ef7ccb469675c23c012f934317d..313e6c459b5d18622f2460c1cbea79f80c3cb138 100644 (file)
@@ -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();
        ///
index 19fcc5d1bb509841b577690dea83813372be6e6e..c3ae80cceb52f207d3da24f39ca74d1cd4f93d20 100644 (file)
@@ -1,3 +1,15 @@
+2002-05-26  John Levon  <moz@compsoc.man.ac.uk>
+
+       * 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  <larsbj@birdstep.com>
 
        * vc-backend.C (scanMaster): use boost regex and get rid of LRegex
index 33aaccab30d63930cf2fe326b84542a0d1d085b4..73abcb5239d6f8cdb2f9892c5ff78706d2ec3d01 100644 (file)
@@ -1,3 +1,12 @@
+2002-05-26  John Levon  <moz@compsoc.man.ac.uk>
+
+       * key_state.h:
+       * mouse_state.h: add
+
+       * Makefile.am:
+       * WorkArea.h:
+       * WorkArea.C: use above
 2002-05-24  John Levon  <moz@compsoc.man.ac.uk>
 
        * Makefile.am:
index 77ed4fba86e994556af69757cfc4dcb3f8ee98e7..bf3402a5927c850adbff16f71fda0539c68377f2 100644 (file)
@@ -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
index 49ee9d69d645c8b72071c800797df24cb269301a..dc5479d69f86bdf57ee2675e0a2707125569524c 100644 (file)
@@ -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;
index 90fc8f690e9d6019a124020535efa8c04ca8e1a6..cef93f34adf50826a6108730ca78169b95f25531 100644 (file)
@@ -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<void, double> scrollCB;
        ///
-       SigC::Signal2<void, KeySym, unsigned int> workAreaKeyPress;
+       SigC::Signal2<void, KeySym, key_modifier::state> workAreaKeyPress;
        ///
-       SigC::Signal3<void, int, int, unsigned int> workAreaButtonPress;
+       SigC::Signal3<void, int, int, mouse_button::state> workAreaButtonPress;
        ///
-       SigC::Signal3<void, int, int, unsigned int> workAreaButtonRelease;
+       SigC::Signal3<void, int, int, mouse_button::state> workAreaButtonRelease;
        ///
-       SigC::Signal3<void, int, int, unsigned int> workAreaMotionNotify;
+       SigC::Signal3<void, int, int, mouse_button::state> workAreaMotionNotify;
        ///
        SigC::Signal0<void> workAreaFocus;
        ///
@@ -123,9 +125,9 @@ public:
        ///
        SigC::Signal0<void> workAreaLeave;
        ///
-       SigC::Signal3<void, int, int, unsigned int> workAreaDoubleClick;
+       SigC::Signal3<void, int, int, mouse_button::state> workAreaDoubleClick;
        ///
-       SigC::Signal3<void, int, int, unsigned int> workAreaTripleClick;
+       SigC::Signal3<void, int, int, mouse_button::state> workAreaTripleClick;
        /// emitted when an X client has requested our selection
        SigC::Signal0<void> 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 (file)
index 0000000..c879720
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+ * \file key_state.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * Keyboard modifier state representation.
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#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<int>(s1));
+       int const i2(static_cast<int>(s2));
+       return static_cast<state>(i1 | i2);
+}
+
+inline void operator|=(state & s1, state s2)
+{
+        s1 = static_cast<state>(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 (file)
index 0000000..84072e1
--- /dev/null
@@ -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 <moz@compsoc.man.ac.uk>
+ */
+
+#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<state>(s1 | s2);
+}
+} // namespace mouse_button
+
+#endif // MOUSE_STATE_H
index edfa2e5dfa94baac2a523a3b3e64c9bb2cead258..529e21d512276ecb5d051587a8b0aa704f19f7bd 100644 (file)
@@ -1,3 +1,42 @@
+2002-05-26  John Levon  <moz@compsoc.man.ac.uk>
+
+       * 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  <moz@compsoc.man.ac.uk>
 
        * insetbib.C:
index cfc35e603b2629c051b659d5ac46db80a44895c8..f20d5e3583014ca37b1b6d2c6af073b232f0c190 100644 (file)
@@ -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)
 {}
 
 
index 77c03f19881bebf4e2b62ba32bdcb406c90a5ab2..3a54462dcfb8a7a22089b3628956f73534a60972 100644 (file)
@@ -17,8 +17,8 @@
 
 #include <vector>
 #include "LString.h"
-#include <X11/Xlib.h>
 #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);
        ///
index 4e8c99fc596d7d56aa6efcf3ce793bdfd33a306e..53b7a89d5ba936de8df3d01f3edef4a021efe35a 100644 (file)
@@ -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<pair<string, string> > 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);
 }
 
 
index e1de692e35a98fd826d427cfdabd1e0d47e1fcef..2606948f598bba7895d7bbcd99d31afba7e1bf79 100644 (file)
@@ -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);
        ///
index a0b7ccf03bf29a35d6d03f395d6990bd4b75459d..c5cc7f21ff6b3532e5b430c534bf76d072cbe030 100644 (file)
@@ -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);
 }
 
 
index 43269b797b6bc422e148f28ed557a26a3b03221e..c4390a2e3473a1632bcf94800df7c05926fd61be 100644 (file)
@@ -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);
        ///
index 39719b90515b8a23d8a4bcfd0caa2a99c11c7012..00b3e869ec6c3ce989ecb5b63d41ecf05bcfa110 100644 (file)
@@ -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
 {
index e7f496e5f8bd83e4af0dce736c9edc1ad8133e39..d3dc3945ef5ca0ac356855ac53c3d1690d1c5748 100644 (file)
@@ -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 &);
index 41928d99c566f2c46f26cbdabf5f03853859db09..dd1a12acd632aef5ae99f405465fd88ae78d2c9a 100644 (file)
@@ -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);
 }
index fb9d00459ea672aa958bdc4dbb22cd3a18253e7a..34b1428f803cef6bab0d1c632546de0fa63b512d 100644 (file)
@@ -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);
        ///
index 67fa7d8c198ae98a347c23f3549437f972d72e29..a7f743cf344f9662660c67d60ebdc9068486baf3 100644 (file)
@@ -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);
index 8f8c02d2824cfa3075b2e6d65138cf36ab7b182d..eee9f18599d47870458601403a5e18bb3571f6ec 100644 (file)
@@ -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<void> 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;
index 3a43e5069d6028c6cfa68dfaf3856cd4904fb6b8..6b21708458b10af937e387ffe1861eefccbf47ae 100644 (file)
@@ -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);
 }
 
 
index 7cce4c5d58e0b91bd52d985651b0c18655ac2ca8..209cfbb70341a83fef5cd1e26196657b95a87a15 100644 (file)
@@ -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);
        ///
index 579989b37822258ac8333289e388ed1df17c1e63..2bebacd11490036ede5cdc8dbf5eccedc8160321 100644 (file)
@@ -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);
 }
 
 
index 7452a2448e711f37d5f483f3d079c2840b3bd0eb..19b03e8dbefff46f674f66453670a66460a497c9 100644 (file)
@@ -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);
        ///
index 038a2236971628451eb05c900215542395fd7664..108535e6075fe210e80df2afa6f4ae8c7d96bda1 100644 (file)
@@ -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);
 }
 
 
index a26bc8dab2df809ffa54e2c9ee12f4195009f3b4..d7920f402ec91564f50c130b123f053b7bc305f4 100644 (file)
@@ -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);
        ///
index 3bda5bea60c1a4c1919bb674868452afa4cc399c..6e1c520cbc7cad985550a40ad245ec7a4a5196fa 100644 (file)
@@ -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);
 }
 
 
index 971e5d50ae3d3f56ecfb045d85b2ea540ae013e2..10bfea34a84ea572084365c4fc1303f3ab9f1323 100644 (file)
@@ -77,7 +77,7 @@ public:
        /// This returns the list of bibkeys on the child buffer
        std::vector< std::pair<string,string> > 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);
        ///
index 85f2d2f395d0cffffab9db4033a5390c766b4e30..1e5e2c6de32d8f2183ed240ba90bb989dc00eb19 100644 (file)
@@ -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);
 }
 
 
index 88c76bab6b3538e196082236615450a688f9e4c1..32b0e2a905028e0e1b658ec2853ce52e473de826 100644 (file)
@@ -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) {}
        ///
index 64c77d8a90fb48ad7434a012ab60050ea002a63d..f3126eaa38ba92c3ac12b0431ef356cacff5573e 100644 (file)
@@ -42,7 +42,7 @@ vector<string> const InsetLabel::getLabelList() const
 }
 
 
-void InsetLabel::edit(BufferView * bv, int, int, unsigned int)
+void InsetLabel::edit(BufferView * bv, int, int, mouse_button::state)
 {
        pair<bool, string> 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);
 }
 
 
index bdd77f4e9c433f605a7c935bc4e4651b92aa6d44..823bf73071cd106be0a825a547bc011797d05c3f 100644 (file)
@@ -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);
        ///
index 90f2d98fb40f6ee8735e000e2f049bfd97f81da6..4afdbab43c51414dee5593e708ec2971738d1079 100644 (file)
@@ -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);
 }
 
 
index 62f9224945350b828b316397582ad7f0d36517ba..6bb544b40ec4680738184f13a55eb3b97159b9f9 100644 (file)
@@ -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);
        ///
index c9ad260e20d09be1f4a52f54f3084e4e4190787f..0f39f93b8456df8eec6b0184e75daf64412148b2 100644 (file)
@@ -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);
 }
 
index 886c87710462b220ed44a98420e6fa4aad039eb7..45c09a22701a6a3e4e0253dea1f2b1aa363e2070 100644 (file)
@@ -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);
        ///
index 49eaf05a246ffb682731a1b23f33458526d8cc5b..8ac934c79d4ecf2232f02bff00e36f2cd8f31e6d 100644 (file)
@@ -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<UpdatableInset*>(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())
index cf81f37e1b444696e6fa728f203ae3b6e55e2aa9..7e6fbd2dccb059e09e136a156db1080a4bbd3d05 100644 (file)
@@ -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;
        ///
index fa3b94940b57e31110f34e792c11248098d01be4..63cf4106b52f9b935a5ef49f679dfd4b3884bfef 100644 (file)
@@ -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) {
index df0ddc702a616a392fb7a164a315e0d34365b963..de1e96c9fb73d047c3bee15fa64104c6514799e5 100644 (file)
@@ -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();
        ///
index 5ba5af06657c93bf468b41561e85834fff4944c4..b2385abd8b316a02bf44da18e8c2b3e47f6b9392 100644 (file)
@@ -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);
 }
 
 
index da097754081752f8a1fe35668b7277e325334736..26d75935a3554c55d95c7be6a5b5f2dc8cd76557 100644 (file)
@@ -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);
        ///
index 1fbad24d33c909fddfb51fcf5adf298ef75433d0..4a61ad859380745ed08188f93af02a4550fb7fd8 100644 (file)
@@ -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);
 }
 
 
index 4712afd948e8982e5e8ca1b221589a4033144cb8..f99d63244e9ff3bae295531e29efe30432fe51f4 100644 (file)
@@ -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);
        ///
index 31d4c7b5a76a249ada696867f8bb27baff3a2464..296a713e92734800039aae51e14716ffd50341ca 100644 (file)
@@ -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<key_modifier::state>(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();
index 3331a0a0371f78dd1c0b268c1a8db59308d54c83..cfad1f1c4bc6cb35e2dd267d21bae687b3ef56b5 100644 (file)
@@ -16,6 +16,7 @@
 #endif
 
 #include "LString.h"
+#include "frontends/key_state.h"
 
 #include <boost/shared_ptr.hpp>
 
@@ -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<key_modifier::state, key_modifier::state> modifier_pair;
        ///
        struct kb_key {
                /// Keysym
                unsigned int code;
 
                /// Modifier masks
-               unsigned int mod;
+               modifier_pair mod;
 
                /// Keymap for prefix keys
                boost::shared_ptr<kb_keymap> table;
index fa93e556b7789fd748adfe51819bc1ec2e762d7e..4292a9b90b0e5b13dd64dc1bf09cc51c396a302a 100644 (file)
 #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<unsigned int>::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_) {
index e00382d34edb58e13938541f940c2fe2eef5e22c..46cda83795b31b1da3f2a5998998d147781b2ef4 100644 (file)
 #pragma interface
 #endif
 
-#include <vector>
+#include <config.h>
+
+#include "frontends/key_state.h"
 #include "LString.h"
 
+#include <vector>
+
 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<unsigned int> sequence;
 
+       typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
        /// modifiers for keys in the sequence
-       std::vector<unsigned int> modifiers;
+       std::vector<modifier_pair> modifiers;
 
        /// Current length of key sequence
        std::vector<unsigned int>::size_type length_;
index 0bcf32f66711ab94d7b7bf50d93ce82a5376013a..d1c33e2d14a49c4a21bd12c67b6da5a760810157 100644 (file)
@@ -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;
index ec8898c242102c5607fd1a27bf6d83bb6475184f..b394f0de57598639ff2c9d1872bcf002d44f7e1b 100644 (file)
@@ -9,6 +9,8 @@
 #include <X11/Xlib.h>
 #include <sigc++/signal_system.h>
 
+#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);
 }
 
 
index 0cd81a4c43142dc856541c4eb89c075e30e19de2..41a703f64b952a80f3f7efd57a14b376cf33e9ee 100644 (file)
@@ -1,3 +1,9 @@
+2002-05-26  John Levon  <moz@compsoc.man.ac.uk>
+
+       * formulabase.C:
+       * formulabase.h: 
+       * math_inset.h: use mouse_state. Kill insetKeyPress
+
 2002-05-24  John Levon  <moz@compsoc.man.ac.uk>
 
        * math_support.C: font loader moved
index d01d39edc7f96e4da21f322be7fbd29d1f43df6a..abbdd0831c50886fbc80bec0efcbb6f0061885c6 100644 (file)
@@ -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)
index 306c2d13e30eee6e659f69eb832e7da00f09268c..1f3f2157923d846e76b2a4de418b9045f4806d20 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <iosfwd>
 #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 *);
 
index eafdc3e2bb4281c4a7ef73d476835abe9aa2ba80..65f3d15e6cb3b89b3c0f5a7b6fc2511d6e242b5e 100644 (file)
@@ -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;
index 98731635531f5cb8cc9f082558913b82249c20d4..f51d91178dbb0561bb29a5aeb20eed521fec40e6 100644 (file)
@@ -2332,7 +2332,7 @@ void LyXText::cursorUp(BufferView * bview, bool selecting) const
                Inset * inset_hit =
                        bview->checkInsetHit(const_cast<LyXText *>(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<LyXText *>(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