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
This commit is contained in:
John Levon 2002-05-26 17:33:14 +00:00
parent 6352b88f9f
commit 97ef9131ba
57 changed files with 446 additions and 277 deletions

View 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;

View 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();
///

View 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

View 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:

View 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

View 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;

View 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

39
src/frontends/key_state.h Normal file
View File

@ -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

View File

@ -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

View 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:

View 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)
{}

View 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);
///

View 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);
}

View 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);
///

View 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);
}

View 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);
///

View 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
{

View 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 &);

View 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);
}

View 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);
///

View 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);

View 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;

View 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);
}

View 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);
///

View 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);
}

View 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);
///

View 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);
}

View 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);
///

View 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);
}

View 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);
///

View 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);
}

View 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) {}
///

View 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);
}

View 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);
///

View 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);
}

View 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);
///

View 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);
}

View 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);
///

View 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())

View 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;
///

View 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) {

View 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();
///

View 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);
}

View 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);
///

View 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);
}

View 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);
///

View 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();

View 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;

View File

@ -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<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_) {

View File

@ -12,9 +12,13 @@
#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_;

View 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;

View 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);
}

View 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

View 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)

View 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 *);

View 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;

View 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