mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
use the new mouse LFUNs
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5021 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d897bc79b4
commit
11ffa04773
@ -471,17 +471,15 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state s
|
||||
? cursor.ix() - width : cursor.ix();
|
||||
int start_x = inset_x + bv_->theLockingInset()->scroll();
|
||||
|
||||
bv_->theLockingInset()->
|
||||
insetMotionNotify(bv_,
|
||||
x - start_x,
|
||||
y - cursor.iy() + bv_->text->first_y,
|
||||
state);
|
||||
FuncRequest cmd(bv_, LFUN_MOUSE_MOTION,
|
||||
x - start_x, y - cursor.iy() + bv_->text->first_y, state);
|
||||
bv_->theLockingInset()->localDispatch(cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
/* The test for not selection possible is needed, that only motion
|
||||
events are used, where the bottom press event was on
|
||||
the drawing area too */
|
||||
// The test for not selection possible is needed, that only motion
|
||||
// events are used, where the bottom press event was on
|
||||
// the drawing area too
|
||||
if (!selection_possible)
|
||||
return;
|
||||
|
||||
@ -555,15 +553,14 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
|
||||
if (bv_->theLockingInset()) {
|
||||
// We are in inset locking mode
|
||||
|
||||
/* Check whether the inset was hit. If not reset mode,
|
||||
otherwise give the event to the inset */
|
||||
// Check whether the inset was hit. If not reset mode,
|
||||
// otherwise give the event to the inset
|
||||
if (inset_hit == bv_->theLockingInset()) {
|
||||
bv_->theLockingInset()->
|
||||
insetButtonPress(bv_, xpos, ypos, button);
|
||||
FuncRequest cmd(bv_, LFUN_MOUSE_PRESS, xpos, ypos, button);
|
||||
bv_->theLockingInset()->localDispatch(cmd);
|
||||
return;
|
||||
} else {
|
||||
bv_->unlockInset(bv_->theLockingInset());
|
||||
}
|
||||
bv_->unlockInset(bv_->theLockingInset());
|
||||
}
|
||||
|
||||
if (!inset_hit)
|
||||
@ -590,7 +587,8 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
|
||||
if (!bv_->lockInset(inset)) {
|
||||
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
|
||||
}
|
||||
inset->insetButtonPress(bv_, xpos, ypos, button);
|
||||
FuncRequest cmd(bv_, LFUN_MOUSE_PRESS, xpos, ypos, button);
|
||||
inset->localDispatch(cmd);
|
||||
return;
|
||||
}
|
||||
// I'm not sure we should continue here if we hit an inset (Jug20020403)
|
||||
@ -736,11 +734,11 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
|
||||
if (bv_->theLockingInset()) {
|
||||
// We are in inset locking mode.
|
||||
|
||||
/* LyX does a kind of work-area grabbing for insets.
|
||||
Only a ButtonPress FuncRequest outside the inset will
|
||||
force a insetUnlock. */
|
||||
bv_->theLockingInset()->
|
||||
insetButtonRelease(bv_, x, y, button);
|
||||
// LyX does a kind of work-area grabbing for insets.
|
||||
// Only a ButtonPress FuncRequest outside the inset will
|
||||
// force a insetUnlock.
|
||||
FuncRequest cmd(bv_, LFUN_MOUSE_RELEASE, x, y, button);
|
||||
bv_->theLockingInset()->localDispatch(cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -801,9 +799,11 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
|
||||
if (isHighlyEditableInset(inset_hit)) {
|
||||
// Highly editable inset, like math
|
||||
UpdatableInset *inset = (UpdatableInset *)inset_hit;
|
||||
inset->insetButtonRelease(bv_, x, y, button);
|
||||
FuncRequest cmd(bv_, LFUN_MOUSE_RELEASE, x, y, button);
|
||||
inset->localDispatch(cmd);
|
||||
} else {
|
||||
inset_hit->insetButtonRelease(bv_, x, y, button);
|
||||
FuncRequest cmd(bv_, LFUN_MOUSE_RELEASE, x, y, button);
|
||||
inset_hit->localDispatch(cmd);
|
||||
// IMO this is a grosshack! Inset's should be changed so that
|
||||
// they call the actions they have to do with the insetButtonRel.
|
||||
// function and not in the edit(). This should be changed
|
||||
|
@ -291,6 +291,7 @@ enum kb_action {
|
||||
LFUN_MOUSE_PRESS, // André 9 Aug 2002
|
||||
LFUN_MOUSE_MOTION, // André 9 Aug 2002
|
||||
LFUN_MOUSE_RELEASE, // André 9 Aug 2002
|
||||
LFUN_EDIT, // André 16 Aug 2002
|
||||
LFUN_LASTACTION /* this marks the end of the table */
|
||||
};
|
||||
|
||||
|
@ -34,8 +34,8 @@ FuncRequest::FuncRequest(BufferView * view, kb_action act, string const & arg)
|
||||
|
||||
|
||||
FuncRequest::FuncRequest
|
||||
(BufferView * view, kb_action act, int ax, int ay, int aextra)
|
||||
: view_(view), action(act), argument(), x(ax), y(ay), extra(aextra)
|
||||
(BufferView * view, kb_action act, int ax, int ay, mouse_button::state but)
|
||||
: view_(view), action(act), argument(), x(ax), y(ay), button_(but)
|
||||
{}
|
||||
|
||||
|
||||
@ -49,3 +49,10 @@ void FuncRequest::setView(BufferView * view)
|
||||
{
|
||||
view_ = view;
|
||||
}
|
||||
|
||||
|
||||
mouse_button::state FuncRequest::button() const
|
||||
{
|
||||
return button_;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#define FUNCREQUEST_H
|
||||
|
||||
#include "commandtags.h"
|
||||
#include "frontends/mouse_state.h"
|
||||
#include "LString.h"
|
||||
|
||||
class BufferView;
|
||||
@ -31,11 +32,14 @@ public:
|
||||
/// actions with extra argument
|
||||
FuncRequest(BufferView * view, kb_action act, string const & arg);
|
||||
/// for mouse events
|
||||
FuncRequest(BufferView * view, kb_action act, int ax, int ay, int aextra);
|
||||
FuncRequest(BufferView * view, kb_action act,
|
||||
int x, int y, mouse_button::state button);
|
||||
/// access to the view
|
||||
BufferView * view() const;
|
||||
/// access to the view
|
||||
void setView(BufferView * view);
|
||||
/// access to button
|
||||
mouse_button::state button() const;
|
||||
|
||||
private:
|
||||
/// the BufferView we are talking to
|
||||
@ -50,7 +54,7 @@ public: // should be private, too...
|
||||
/// the y coordinate of a mouse press
|
||||
int y;
|
||||
/// some extra information (like button number)
|
||||
int extra;
|
||||
mouse_button::state button_;
|
||||
};
|
||||
|
||||
#endif // FUNCREQUEST_H
|
||||
|
@ -74,6 +74,10 @@ Inset::EDITABLE Inset::editable() const
|
||||
}
|
||||
|
||||
|
||||
void Inset::edit(BufferView *, int, int, mouse_button::state)
|
||||
{}
|
||||
|
||||
|
||||
void Inset::validate(LaTeXFeatures &) const
|
||||
{}
|
||||
|
||||
@ -84,14 +88,16 @@ bool Inset::autoDelete() const
|
||||
}
|
||||
|
||||
|
||||
void Inset::edit(BufferView *, int, int, mouse_button::state)
|
||||
{}
|
||||
|
||||
|
||||
void Inset::edit(BufferView *, bool)
|
||||
{}
|
||||
|
||||
|
||||
Inset::RESULT Inset::localDispatch(FuncRequest const &)
|
||||
{
|
||||
return UNDISPATCHED;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
LyXFont const Inset::convertFont(LyXFont const & font) const
|
||||
{
|
||||
@ -177,28 +183,6 @@ UpdatableInset::UpdatableInset(UpdatableInset const & in, bool same_id)
|
||||
{}
|
||||
|
||||
|
||||
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, mouse_button::state button)
|
||||
{
|
||||
lyxerr[Debug::INFO] << "Inset Button Release x=" << x
|
||||
<< ", y=" << y << ", button=" << button << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
void UpdatableInset::insetUnlock(BufferView *)
|
||||
{
|
||||
lyxerr[Debug::INFO] << "Inset Unlock" << endl;
|
||||
@ -304,9 +288,11 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const
|
||||
|
||||
|
||||
/// An updatable inset could handle lyx editing commands
|
||||
UpdatableInset::RESULT
|
||||
UpdatableInset::localDispatch(FuncRequest const & ev)
|
||||
Inset::RESULT UpdatableInset::localDispatch(FuncRequest const & ev)
|
||||
{
|
||||
if (ev.action == LFUN_MOUSE_RELEASE)
|
||||
return (editable() == IS_EDITABLE) ? DISPATCHED : UNDISPATCHED;
|
||||
|
||||
if (!ev.argument.empty() && ev.action == LFUN_SCROLL_INSET) {
|
||||
if (ev.argument.find('.') != ev.argument.npos) {
|
||||
float const xx = static_cast<float>(strToDbl(ev.argument));
|
||||
|
@ -134,6 +134,40 @@ public:
|
||||
HIGHLY_EDITABLE
|
||||
};
|
||||
|
||||
/** Dispatch result codes
|
||||
Now that nested updatable insets are allowed, the local dispatch
|
||||
becomes a bit complex, just two possible results (boolean)
|
||||
are not enough.
|
||||
|
||||
DISPATCHED = the inset catched the action
|
||||
DISPATCHED_NOUPDATE = the inset catched the action and no update
|
||||
is needed here to redraw the inset
|
||||
FINISHED = the inset must be unlocked as a result
|
||||
of the action
|
||||
FINISHED_RIGHT = FINISHED, but put the cursor to the RIGHT of
|
||||
the inset.
|
||||
FINISHED_UP = FINISHED, but put the cursor UP of
|
||||
the inset.
|
||||
FINISHED_DOWN = FINISHED, but put the cursor DOWN of
|
||||
the inset.
|
||||
UNDISPATCHED = the action was not catched, it should be
|
||||
dispatched by lower level insets
|
||||
*/
|
||||
enum RESULT {
|
||||
UNDISPATCHED = 0,
|
||||
DISPATCHED,
|
||||
DISPATCHED_NOUPDATE,
|
||||
FINISHED,
|
||||
FINISHED_RIGHT,
|
||||
FINISHED_UP,
|
||||
FINISHED_DOWN
|
||||
};
|
||||
|
||||
/// To convert old binary dispatch results
|
||||
RESULT DISPATCH_RESULT(bool b) {
|
||||
return b ? DISPATCHED : FINISHED;
|
||||
}
|
||||
|
||||
///
|
||||
Inset();
|
||||
///
|
||||
@ -160,16 +194,8 @@ public:
|
||||
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, 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, 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, mouse_button::state) {}
|
||||
///
|
||||
virtual RESULT localDispatch(FuncRequest const & cmd);
|
||||
///
|
||||
virtual bool isTextInset() const { return false; }
|
||||
///
|
||||
@ -415,40 +441,6 @@ bool Inset::checkInsertChar(LyXFont &)
|
||||
*/
|
||||
class UpdatableInset : public Inset {
|
||||
public:
|
||||
/** Dispatch result codes
|
||||
Now that nested updatable insets are allowed, the local dispatch
|
||||
becomes a bit complex, just two possible results (boolean)
|
||||
are not enough.
|
||||
|
||||
DISPATCHED = the inset catched the action
|
||||
DISPATCHED_NOUPDATE = the inset catched the action and no update
|
||||
is needed here to redraw the inset
|
||||
FINISHED = the inset must be unlocked as a result
|
||||
of the action
|
||||
FINISHED_RIGHT = FINISHED, but put the cursor to the RIGHT of
|
||||
the inset.
|
||||
FINISHED_UP = FINISHED, but put the cursor UP of
|
||||
the inset.
|
||||
FINISHED_DOWN = FINISHED, but put the cursor DOWN of
|
||||
the inset.
|
||||
UNDISPATCHED = the action was not catched, it should be
|
||||
dispatched by lower level insets
|
||||
*/
|
||||
enum RESULT {
|
||||
UNDISPATCHED = 0,
|
||||
DISPATCHED,
|
||||
DISPATCHED_NOUPDATE,
|
||||
FINISHED,
|
||||
FINISHED_RIGHT,
|
||||
FINISHED_UP,
|
||||
FINISHED_DOWN
|
||||
};
|
||||
|
||||
/// To convert old binary dispatch results
|
||||
RESULT DISPATCH_RESULT(bool b) {
|
||||
return b ? DISPATCHED : FINISHED;
|
||||
}
|
||||
|
||||
///
|
||||
UpdatableInset();
|
||||
///
|
||||
@ -471,17 +463,6 @@ public:
|
||||
///
|
||||
virtual void getCursorPos(BufferView *, int &, int &) const {}
|
||||
///
|
||||
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, mouse_button::state button);
|
||||
///
|
||||
virtual void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
|
||||
///
|
||||
virtual void insetUnlock(BufferView *);
|
||||
///
|
||||
virtual void edit(BufferView *, int x, int y, mouse_button::state button);
|
||||
@ -512,7 +493,7 @@ public:
|
||||
bool /*lr*/ = false)
|
||||
{ return false; }
|
||||
/// An updatable inset could handle lyx editing commands
|
||||
virtual RESULT localDispatch(FuncRequest const & ev);
|
||||
virtual RESULT localDispatch(FuncRequest const & cmd);
|
||||
///
|
||||
bool isCursorVisible() const { return cursor_visible_; }
|
||||
///
|
||||
|
@ -138,7 +138,7 @@ int InsetCollapsable::width_collapsed() const
|
||||
int ascent;
|
||||
int descent;
|
||||
font_metrics::buttonText(label, labelfont, width, ascent, descent);
|
||||
return width + (2*TEXT_TO_INSET_OFFSET);
|
||||
return width + 2 * TEXT_TO_INSET_OFFSET;
|
||||
}
|
||||
|
||||
|
||||
@ -321,26 +321,26 @@ void InsetCollapsable::insetUnlock(BufferView * bv)
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::insetButtonPress(BufferView * bv,
|
||||
int x, int y, mouse_button::state button)
|
||||
void InsetCollapsable::lfunMousePress(FuncRequest const & cmd)
|
||||
{
|
||||
if (!collapsed_ && (y > button_bottom_y)) {
|
||||
if (!collapsed_ && (cmd.y > button_bottom_y)) {
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
int yy = ascent(bv, font) + y -
|
||||
FuncRequest cmd1 = cmd;
|
||||
cmd1.y = ascent(cmd.view(), font) + cmd.y -
|
||||
(ascent_collapsed() +
|
||||
descent_collapsed() +
|
||||
inset.ascent(bv, font));
|
||||
inset.insetButtonPress(bv, x, yy, button);
|
||||
inset.ascent(cmd.view(), font));
|
||||
inset.localDispatch(cmd1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool InsetCollapsable::insetButtonRelease(BufferView * bv,
|
||||
int x, int y, mouse_button::state button)
|
||||
bool InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
|
||||
{
|
||||
bool ret = false;
|
||||
if ((button != mouse_button::button3) && (x < button_length) &&
|
||||
(y >= button_top_y) && (y <= button_bottom_y))
|
||||
BufferView * bv = cmd.view();
|
||||
if ((cmd.button() != mouse_button::button3) && (cmd.x < button_length) &&
|
||||
(cmd.y >= button_top_y) && (cmd.y <= button_bottom_y))
|
||||
{
|
||||
if (collapsed_) {
|
||||
collapsed_ = false;
|
||||
@ -353,31 +353,31 @@ bool InsetCollapsable::insetButtonRelease(BufferView * bv,
|
||||
bv->unlockInset(this);
|
||||
bv->updateInset(this, false);
|
||||
}
|
||||
} else if (!collapsed_ && (y > button_bottom_y)) {
|
||||
} else if (!collapsed_ && (cmd.y > button_bottom_y)) {
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
int yy = ascent(bv, font) + y -
|
||||
FuncRequest cmd1 = cmd;
|
||||
cmd1.y = ascent(cmd.view(), font) + cmd.y -
|
||||
(ascent_collapsed() +
|
||||
descent_collapsed() +
|
||||
inset.ascent(bv, font));
|
||||
ret = inset.insetButtonRelease(bv, x, yy, button);
|
||||
inset.ascent(cmd.view(), font));
|
||||
ret = (inset.localDispatch(cmd1) == DISPATCHED);
|
||||
}
|
||||
if ((button == mouse_button::button3) && !ret) {
|
||||
if (cmd.button() == mouse_button::button3 && !ret)
|
||||
return showInsetDialog(bv);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::insetMotionNotify(BufferView * bv,
|
||||
int x, int y, mouse_button::state state)
|
||||
void InsetCollapsable::lfunMouseMotion(FuncRequest const & cmd)
|
||||
{
|
||||
if (y > button_bottom_y) {
|
||||
if (cmd.y > button_bottom_y) {
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
int yy = ascent(bv, font) + y -
|
||||
FuncRequest cmd1 = cmd;
|
||||
cmd1.y = ascent(cmd.view(), font) + cmd.y -
|
||||
(ascent_collapsed() +
|
||||
descent_collapsed() +
|
||||
inset.ascent(bv, font));
|
||||
inset.insetMotionNotify(bv, x, yy, state);
|
||||
inset.ascent(cmd.view(), font));
|
||||
inset.localDispatch(cmd1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -445,14 +445,30 @@ void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT
|
||||
InsetCollapsable::localDispatch(FuncRequest const & ev)
|
||||
Inset::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd)
|
||||
{
|
||||
UpdatableInset::RESULT result = inset.localDispatch(ev);
|
||||
if (result >= FINISHED)
|
||||
ev.view()->unlockInset(this);
|
||||
first_after_edit = false;
|
||||
return result;
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
lfunMousePress(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
case LFUN_MOUSE_MOTION:
|
||||
lfunMouseMotion(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
lfunMouseRelease(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
default:
|
||||
UpdatableInset::RESULT result = inset.localDispatch(cmd);
|
||||
if (result >= FINISHED)
|
||||
cmd.view()->unlockInset(this);
|
||||
first_after_edit = false;
|
||||
return result;
|
||||
}
|
||||
return UNDISPATCHED;
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,12 +89,6 @@ public:
|
||||
///
|
||||
int insetInInsetY() const;
|
||||
///
|
||||
bool insetButtonRelease(BufferView *, int, int, mouse_button::state);
|
||||
///
|
||||
void insetButtonPress(BufferView *, int, int, mouse_button::state);
|
||||
///
|
||||
void insetMotionNotify(BufferView *, int, int, mouse_button::state);
|
||||
///
|
||||
RESULT localDispatch(FuncRequest const &);
|
||||
///
|
||||
int latex(Buffer const *, std::ostream &,
|
||||
@ -229,6 +223,13 @@ protected:
|
||||
mutable UpdateCodes need_update;
|
||||
|
||||
private:
|
||||
///
|
||||
void lfunMousePress(FuncRequest const &);
|
||||
///
|
||||
bool lfunMouseRelease(FuncRequest const &);
|
||||
///
|
||||
void lfunMouseMotion(FuncRequest const &);
|
||||
|
||||
///
|
||||
mutable string label;
|
||||
#if 0
|
||||
|
@ -298,55 +298,51 @@ void InsetERT::edit(BufferView * bv, bool front)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void InsetERT::insetButtonPress(BufferView * bv,
|
||||
int x, int y, mouse_button::state button)
|
||||
void InsetERT::lfunMousePress(FuncRequest const & cmd)
|
||||
{
|
||||
if (status_ == Inlined) {
|
||||
inset.insetButtonPress(bv, x, y, button);
|
||||
} else {
|
||||
InsetCollapsable::insetButtonPress(bv, x, y, button);
|
||||
}
|
||||
if (status_ == Inlined)
|
||||
inset.localDispatch(cmd);
|
||||
else
|
||||
InsetCollapsable::localDispatch(cmd);
|
||||
}
|
||||
|
||||
|
||||
bool InsetERT::insetButtonRelease(BufferView * bv, int x, int y,
|
||||
mouse_button::state button)
|
||||
bool InsetERT::lfunMouseRelease(FuncRequest const & cmd)
|
||||
{
|
||||
if (button == mouse_button::button3) {
|
||||
BufferView * bv = cmd.view();
|
||||
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
showInsetDialog(bv);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (status_ != Inlined && (x >= 0) && (x < button_length) &&
|
||||
(y >= button_top_y) && (y <= button_bottom_y)) {
|
||||
if (status_ != Inlined && (cmd.x >= 0) && (cmd.x < button_length) &&
|
||||
(cmd.y >= button_top_y) && (cmd.y <= button_bottom_y)) {
|
||||
updateStatus(bv, true);
|
||||
} else {
|
||||
LyXFont font(LyXFont::ALL_SANE);
|
||||
int yy = ascent(bv, font) + y - inset.ascent(bv, font);
|
||||
FuncRequest cmd1 = cmd;
|
||||
cmd1.y = ascent(bv, font) + cmd.y - inset.ascent(bv, font);
|
||||
|
||||
// inlined is special - the text appears above
|
||||
// button_bottom_y
|
||||
if (status_ == Inlined) {
|
||||
inset.insetButtonRelease(bv, x, yy, button);
|
||||
} else if (!collapsed_ && (y > button_bottom_y)) {
|
||||
yy -= (ascent_collapsed() + descent_collapsed());
|
||||
inset.insetButtonRelease(bv, x, yy, button);
|
||||
if (status_ == Inlined)
|
||||
inset.localDispatch(cmd1);
|
||||
else if (!collapsed_ && (cmd.y > button_bottom_y)) {
|
||||
cmd1.y -= ascent_collapsed() + descent_collapsed();
|
||||
inset.localDispatch(cmd1);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void InsetERT::insetMotionNotify(BufferView * bv,
|
||||
int x, int y, mouse_button::state state)
|
||||
void InsetERT::lfunMouseMotion(FuncRequest const & cmd)
|
||||
{
|
||||
if (status_ == Inlined) {
|
||||
inset.insetMotionNotify(bv, x, y, state);
|
||||
} else {
|
||||
InsetCollapsable::insetMotionNotify(bv, x, y, state);
|
||||
}
|
||||
if (status_ == Inlined)
|
||||
inset.localDispatch(cmd);
|
||||
else
|
||||
InsetCollapsable::localDispatch(cmd);
|
||||
}
|
||||
|
||||
|
||||
@ -380,8 +376,7 @@ int InsetERT::latex(Buffer const *, ostream & os, bool /*fragile*/,
|
||||
}
|
||||
|
||||
|
||||
int InsetERT::ascii(Buffer const *,
|
||||
ostream &, int /*linelen*/) const
|
||||
int InsetERT::ascii(Buffer const *, ostream &, int /*linelen*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -445,23 +440,37 @@ int InsetERT::docbook(Buffer const *, ostream & os, bool) const
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT InsetERT::localDispatch(FuncRequest const & ev)
|
||||
Inset::RESULT InsetERT::localDispatch(FuncRequest const & cmd)
|
||||
{
|
||||
UpdatableInset::RESULT result = DISPATCHED_NOUPDATE;
|
||||
BufferView * bv = ev.view();
|
||||
Inset::RESULT result = DISPATCHED_NOUPDATE;
|
||||
BufferView * bv = cmd.view();
|
||||
|
||||
if (inset.paragraph()->empty()) {
|
||||
set_latex_font(bv);
|
||||
}
|
||||
|
||||
switch (ev.action) {
|
||||
case LFUN_LAYOUT:
|
||||
bv->owner()->setLayout(inset.paragraph()->layout()->name());
|
||||
break;
|
||||
default:
|
||||
result = InsetCollapsable::localDispatch(ev);
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
lfunMousePress(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
case LFUN_MOUSE_MOTION:
|
||||
lfunMouseMotion(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
lfunMouseRelease(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
case LFUN_LAYOUT:
|
||||
bv->owner()->setLayout(inset.paragraph()->layout()->name());
|
||||
break;
|
||||
|
||||
default:
|
||||
result = InsetCollapsable::localDispatch(cmd);
|
||||
}
|
||||
switch (ev.action) {
|
||||
|
||||
switch (cmd.action) {
|
||||
case LFUN_BREAKPARAGRAPH:
|
||||
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
|
||||
case LFUN_BACKSPACE:
|
||||
|
@ -76,12 +76,6 @@ public:
|
||||
///
|
||||
boost::signal0<void> hideDialog;
|
||||
///
|
||||
void insetButtonPress(BufferView *, int x, int y, mouse_button::state button);
|
||||
///
|
||||
bool insetButtonRelease(BufferView * bv, int x, int y, mouse_button::state button);
|
||||
///
|
||||
void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
|
||||
///
|
||||
int latex(Buffer const *, std::ostream &, bool fragile,
|
||||
bool free_spc) const;
|
||||
///
|
||||
@ -140,6 +134,16 @@ public:
|
||||
void update(BufferView *, LyXFont const &, bool =false);
|
||||
|
||||
private:
|
||||
///
|
||||
void lfunMousePress(FuncRequest const &);
|
||||
///
|
||||
// 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!
|
||||
///
|
||||
bool lfunMouseRelease(FuncRequest const &);
|
||||
///
|
||||
void lfunMouseMotion(FuncRequest const &);
|
||||
///
|
||||
void init();
|
||||
///
|
||||
|
@ -771,18 +771,19 @@ bool InsetTabular::insertInset(BufferView * bv, Inset * inset)
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, mouse_button::state button)
|
||||
void InsetTabular::lfunMousePress(FuncRequest const & cmd)
|
||||
{
|
||||
if (hasSelection() && (button == mouse_button::button3))
|
||||
if (hasSelection() && cmd.button() == mouse_button::button3)
|
||||
return;
|
||||
|
||||
if (hasSelection()) {
|
||||
clearSelection();
|
||||
updateLocal(bv, SELECTION, false);
|
||||
updateLocal(cmd.view(), SELECTION, false);
|
||||
}
|
||||
|
||||
int const ocell = actcell;
|
||||
int const orow = actrow;
|
||||
BufferView * bv = cmd.view();
|
||||
|
||||
hideInsetCursor(bv);
|
||||
if (!locked) {
|
||||
@ -791,12 +792,12 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, mouse_button:
|
||||
inset_x = 0;
|
||||
inset_y = 0;
|
||||
}
|
||||
setPos(bv, x, y);
|
||||
setPos(bv, cmd.x, cmd.y);
|
||||
if (actrow != orow)
|
||||
updateLocal(bv, NONE, false);
|
||||
clearSelection();
|
||||
#if 0
|
||||
if (button == 3) {
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
if ((ocell != actcell) && the_locking_inset) {
|
||||
the_locking_inset->insetUnlock(bv);
|
||||
updateLocal(bv, CELL, false);
|
||||
@ -807,65 +808,75 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, mouse_button:
|
||||
}
|
||||
#endif
|
||||
|
||||
bool const inset_hit = insetHit(bv, x, y);
|
||||
bool const inset_hit = insetHit(bv, cmd.x, cmd.y);
|
||||
|
||||
FuncRequest cmd1 = cmd;
|
||||
cmd1.x -= inset_x;
|
||||
cmd1.y -= inset_y;
|
||||
|
||||
if ((ocell == actcell) && the_locking_inset && inset_hit) {
|
||||
resetPos(bv);
|
||||
the_locking_inset->insetButtonPress(bv,
|
||||
x - inset_x, y - inset_y,
|
||||
button);
|
||||
the_locking_inset->localDispatch(cmd1);
|
||||
return;
|
||||
} else if (the_locking_inset) {
|
||||
}
|
||||
|
||||
if (the_locking_inset) {
|
||||
the_locking_inset->insetUnlock(bv);
|
||||
updateLocal(bv, CELL, false);
|
||||
the_locking_inset = 0;
|
||||
}
|
||||
if (button == mouse_button::button2) {
|
||||
|
||||
if (cmd.button() == mouse_button::button2) {
|
||||
localDispatch(FuncRequest(bv, LFUN_PASTESELECTION, "paragraph"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (inset_hit && bv->theLockingInset()) {
|
||||
if (!bv->lockInset(static_cast<UpdatableInset*>(tabular->GetCellInset(actcell)))) {
|
||||
if (!bv->lockInset(static_cast<UpdatableInset*>
|
||||
(tabular->GetCellInset(actcell))))
|
||||
{
|
||||
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
|
||||
return;
|
||||
}
|
||||
the_locking_inset->insetButtonPress(
|
||||
bv, x - inset_x, y - inset_y, button);
|
||||
the_locking_inset->localDispatch(cmd1);
|
||||
return;
|
||||
}
|
||||
showInsetCursor(bv);
|
||||
}
|
||||
|
||||
|
||||
bool InsetTabular::insetButtonRelease(BufferView * bv,
|
||||
int x, int y, mouse_button::state button)
|
||||
bool InsetTabular::lfunMouseRelease(FuncRequest const & cmd)
|
||||
{
|
||||
bool ret = false;
|
||||
if (the_locking_inset)
|
||||
ret = the_locking_inset->insetButtonRelease(bv, x - inset_x,
|
||||
y - inset_y, button);
|
||||
if (button == mouse_button::button3 && !ret) {
|
||||
bv->owner()->getDialogs().showTabular(this);
|
||||
if (the_locking_inset) {
|
||||
FuncRequest cmd1 = cmd;
|
||||
cmd1.x -= inset_x;
|
||||
cmd1.y -= inset_y;
|
||||
ret = the_locking_inset->localDispatch(cmd1);
|
||||
}
|
||||
if (cmd.button() == mouse_button::button3 && !ret) {
|
||||
cmd.view()->owner()->getDialogs().showTabular(this);
|
||||
return true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::state button)
|
||||
void InsetTabular::lfunMouseMotion(FuncRequest const & cmd)
|
||||
{
|
||||
if (the_locking_inset) {
|
||||
the_locking_inset->insetMotionNotify(bv,
|
||||
x - inset_x,
|
||||
y - inset_y,
|
||||
button);
|
||||
FuncRequest cmd1 = cmd;
|
||||
cmd1.x -= inset_x;
|
||||
cmd1.y -= inset_y;
|
||||
the_locking_inset->localDispatch(cmd1);
|
||||
return;
|
||||
}
|
||||
|
||||
BufferView * bv = cmd.view();
|
||||
hideInsetCursor(bv);
|
||||
int const old_cell = actcell;
|
||||
|
||||
setPos(bv, x, y);
|
||||
setPos(bv, cmd.x, cmd.y);
|
||||
if (!hasSelection()) {
|
||||
setSelection(actcell, actcell);
|
||||
updateLocal(bv, SELECTION, false);
|
||||
@ -877,20 +888,20 @@ void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, mouse_button
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT InsetTabular::localDispatch(FuncRequest const & ev)
|
||||
Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd)
|
||||
{
|
||||
// We need to save the value of the_locking_inset as the call to
|
||||
// the_locking_inset->LocalDispatch might unlock it.
|
||||
// the_locking_inset->localDispatch might unlock it.
|
||||
old_locking_inset = the_locking_inset;
|
||||
RESULT result = UpdatableInset::localDispatch(ev);
|
||||
RESULT result = UpdatableInset::localDispatch(cmd);
|
||||
|
||||
BufferView * bv = ev.view();
|
||||
BufferView * bv = cmd.view();
|
||||
if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) {
|
||||
resetPos(bv);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (ev.action < 0 && ev.argument.empty())
|
||||
if (cmd.action < 0 && cmd.argument.empty())
|
||||
return FINISHED;
|
||||
|
||||
bool hs = hasSelection();
|
||||
@ -899,12 +910,24 @@ UpdatableInset::RESULT InsetTabular::localDispatch(FuncRequest const & ev)
|
||||
// this one have priority over the locked InsetText, if we're not already
|
||||
// inside another tabular then that one get's priority!
|
||||
if (getFirstLockingInsetOfType(Inset::TABULAR_CODE) == this) {
|
||||
switch (ev.action) {
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
lfunMousePress(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
case LFUN_MOUSE_MOTION:
|
||||
lfunMouseMotion(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
lfunMouseRelease(cmd);
|
||||
return lfunMouseRelease(cmd) ? DISPATCHED : UNDISPATCHED;
|
||||
|
||||
case LFUN_SHIFT_TAB:
|
||||
case LFUN_TAB:
|
||||
hideInsetCursor(bv);
|
||||
unlockInsetInInset(bv, the_locking_inset);
|
||||
if (ev.action == LFUN_TAB)
|
||||
if (cmd.action == LFUN_TAB)
|
||||
moveNextCell(bv, old_locking_inset != 0);
|
||||
else
|
||||
movePrevCell(bv, old_locking_inset != 0);
|
||||
@ -922,10 +945,10 @@ UpdatableInset::RESULT InsetTabular::localDispatch(FuncRequest const & ev)
|
||||
}
|
||||
}
|
||||
|
||||
kb_action action = ev.action;
|
||||
string arg = ev.argument;
|
||||
kb_action action = cmd.action;
|
||||
string arg = cmd.argument;
|
||||
if (the_locking_inset) {
|
||||
result = the_locking_inset->localDispatch(ev);
|
||||
result = the_locking_inset->localDispatch(cmd);
|
||||
if (result == DISPATCHED_NOUPDATE) {
|
||||
int sc = scroll();
|
||||
resetPos(bv);
|
||||
@ -1614,7 +1637,7 @@ void InsetTabular::resetPos(BufferView * bv) const
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
|
||||
Inset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
|
||||
{
|
||||
if (lock && !old_locking_inset) {
|
||||
if (activateCellInset(bv))
|
||||
@ -1632,7 +1655,7 @@ UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
|
||||
Inset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
|
||||
{
|
||||
bool moved = isRightToLeft(bv) ? moveNextCell(bv) : movePrevCell(bv);
|
||||
if (!moved)
|
||||
@ -1646,7 +1669,7 @@ UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv, bool lock)
|
||||
Inset::RESULT InsetTabular::moveUp(BufferView * bv, bool lock)
|
||||
{
|
||||
int const ocell = actcell;
|
||||
actcell = tabular->GetCellAbove(actcell);
|
||||
@ -1667,7 +1690,7 @@ UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv, bool lock)
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT InsetTabular::moveDown(BufferView * bv, bool lock)
|
||||
Inset::RESULT InsetTabular::moveDown(BufferView * bv, bool lock)
|
||||
{
|
||||
int const ocell = actcell;
|
||||
actcell = tabular->GetCellBelow(actcell);
|
||||
|
@ -136,12 +136,6 @@ public:
|
||||
///
|
||||
bool display() const { return tabular->IsLongTabular(); }
|
||||
///
|
||||
bool insetButtonRelease(BufferView *, int, int, mouse_button::state);
|
||||
///
|
||||
void insetButtonPress(BufferView *, int, int, mouse_button::state);
|
||||
///
|
||||
void insetMotionNotify(BufferView *, int, int, mouse_button::state);
|
||||
///
|
||||
RESULT localDispatch(FuncRequest const &);
|
||||
///
|
||||
int latex(Buffer const *, std::ostream &, bool, bool) const;
|
||||
@ -243,6 +237,16 @@ public:
|
||||
boost::signal0<void> hideDialog;
|
||||
|
||||
private:
|
||||
///
|
||||
void lfunMousePress(FuncRequest const &);
|
||||
///
|
||||
// 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!
|
||||
///
|
||||
bool lfunMouseRelease(FuncRequest const &);
|
||||
///
|
||||
void lfunMouseMotion(FuncRequest const &);
|
||||
///
|
||||
bool calculate_dimensions_of_cells(BufferView *, LyXFont const &,
|
||||
bool = false) const;
|
||||
@ -261,13 +265,13 @@ private:
|
||||
///
|
||||
void setPos(BufferView *, int x, int y) const;
|
||||
///
|
||||
UpdatableInset::RESULT moveRight(BufferView *, bool lock = true);
|
||||
RESULT moveRight(BufferView *, bool lock = true);
|
||||
///
|
||||
UpdatableInset::RESULT moveLeft(BufferView *, bool lock = true);
|
||||
RESULT moveLeft(BufferView *, bool lock = true);
|
||||
///
|
||||
UpdatableInset::RESULT moveUp(BufferView *, bool lock = true);
|
||||
RESULT moveUp(BufferView *, bool lock = true);
|
||||
///
|
||||
UpdatableInset::RESULT moveDown(BufferView *, bool lock = true);
|
||||
RESULT moveDown(BufferView *, bool lock = true);
|
||||
///
|
||||
bool moveNextCell(BufferView *, bool lock = false);
|
||||
///
|
||||
|
@ -984,29 +984,29 @@ bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
|
||||
}
|
||||
|
||||
|
||||
void InsetText::insetButtonPress(BufferView * bv,
|
||||
int x, int y, mouse_button::state button)
|
||||
void InsetText::lfunMousePress(FuncRequest const & cmd)
|
||||
{
|
||||
no_selection = true;
|
||||
|
||||
// use this to check mouse motion for selection!
|
||||
mouse_x = x;
|
||||
mouse_y = y;
|
||||
mouse_x = cmd.x;
|
||||
mouse_y = cmd.y;
|
||||
|
||||
BufferView * bv = cmd.view();
|
||||
FuncRequest cmd1 = cmd;
|
||||
cmd1.x -= inset_x;
|
||||
cmd1.y -= inset_y;
|
||||
if (!locked)
|
||||
lockInset(bv);
|
||||
|
||||
int tmp_x = x - drawTextXOffset;
|
||||
int tmp_y = y + insetAscent - getLyXText(bv)->first_y;
|
||||
int tmp_x = cmd.x - drawTextXOffset;
|
||||
int tmp_y = cmd.y + insetAscent - getLyXText(bv)->first_y;
|
||||
Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y);
|
||||
|
||||
hideInsetCursor(bv);
|
||||
if (the_locking_inset) {
|
||||
if (the_locking_inset == inset) {
|
||||
the_locking_inset->insetButtonPress(bv,
|
||||
x - inset_x,
|
||||
y - inset_y,
|
||||
button);
|
||||
the_locking_inset->localDispatch(cmd1);
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
@ -1016,8 +1016,7 @@ void InsetText::insetButtonPress(BufferView * bv,
|
||||
inset_x = cix(bv) - top_x + drawTextXOffset;
|
||||
inset_y = ciy(bv) + drawTextYOffset;
|
||||
the_locking_inset = 0;
|
||||
inset->insetButtonPress(bv, x - inset_x,
|
||||
y - inset_y, button);
|
||||
inset->localDispatch(cmd1);
|
||||
// inset->edit(bv, x - inset_x, y - inset_y, button);
|
||||
if (the_locking_inset)
|
||||
updateLocal(bv, CURSOR, false);
|
||||
@ -1039,7 +1038,7 @@ void InsetText::insetButtonPress(BufferView * bv,
|
||||
if (!bv->lockInset(uinset)) {
|
||||
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
|
||||
}
|
||||
inset->insetButtonPress(bv, x - inset_x, y - inset_y, button);
|
||||
inset->localDispatch(cmd1);
|
||||
if (the_locking_inset)
|
||||
updateLocal(bv, CURSOR, false);
|
||||
return;
|
||||
@ -1047,7 +1046,7 @@ void InsetText::insetButtonPress(BufferView * bv,
|
||||
}
|
||||
if (!inset) { // && (button == mouse_button::button2)) {
|
||||
bool paste_internally = false;
|
||||
if ((button == mouse_button::button2) && getLyXText(bv)->selection.set()) {
|
||||
if (cmd.button() == mouse_button::button2 && getLyXText(bv)->selection.set()) {
|
||||
localDispatch(FuncRequest(bv, LFUN_COPY));
|
||||
paste_internally = true;
|
||||
}
|
||||
@ -1058,8 +1057,8 @@ void InsetText::insetButtonPress(BufferView * bv,
|
||||
}
|
||||
int old_first_y = lt->first_y;
|
||||
|
||||
lt->setCursorFromCoordinates(bv, x - drawTextXOffset,
|
||||
y + insetAscent);
|
||||
lt->setCursorFromCoordinates(bv, cmd.x - drawTextXOffset,
|
||||
cmd.y + insetAscent);
|
||||
// set the selection cursor!
|
||||
lt->selection.cursor = lt->cursor;
|
||||
lt->cursor.x_fix(lt->cursor.x());
|
||||
@ -1085,7 +1084,7 @@ void InsetText::insetButtonPress(BufferView * bv,
|
||||
// Insert primary selection with middle mouse
|
||||
// if there is a local selection in the current buffer,
|
||||
// insert this
|
||||
if (button == mouse_button::button2) {
|
||||
if (cmd.button() == mouse_button::button2) {
|
||||
if (paste_internally)
|
||||
localDispatch(FuncRequest(bv, LFUN_PASTE));
|
||||
else
|
||||
@ -1098,30 +1097,31 @@ void InsetText::insetButtonPress(BufferView * bv,
|
||||
}
|
||||
|
||||
|
||||
bool InsetText::insetButtonRelease(BufferView * bv,
|
||||
int x, int y, mouse_button::state button)
|
||||
bool InsetText::lfunMouseRelease(FuncRequest const & cmd)
|
||||
{
|
||||
BufferView * bv = cmd.view();
|
||||
FuncRequest cmd1 = cmd;
|
||||
cmd1.x -= inset_x;
|
||||
cmd1.y -= inset_y;
|
||||
|
||||
no_selection = true;
|
||||
if (the_locking_inset) {
|
||||
return the_locking_inset->insetButtonRelease(bv,
|
||||
x - inset_x, y - inset_y,
|
||||
button);
|
||||
}
|
||||
int tmp_x = x - drawTextXOffset;
|
||||
int tmp_y = y + insetAscent - getLyXText(bv)->first_y;
|
||||
if (the_locking_inset)
|
||||
return the_locking_inset->localDispatch(cmd1);
|
||||
|
||||
int tmp_x = cmd.x - drawTextXOffset;
|
||||
int tmp_y = cmd.y + insetAscent - getLyXText(bv)->first_y;
|
||||
Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y);
|
||||
bool ret = false;
|
||||
if (inset) {
|
||||
if (isHighlyEditableInset(inset)) {
|
||||
ret = inset->insetButtonRelease(bv, x - inset_x,
|
||||
y - inset_y, button);
|
||||
} else {
|
||||
if (isHighlyEditableInset(inset))
|
||||
ret = inset->localDispatch(cmd1);
|
||||
else {
|
||||
inset_x = cix(bv) - top_x + drawTextXOffset;
|
||||
inset_y = ciy(bv) + drawTextYOffset;
|
||||
ret = inset->insetButtonRelease(bv, x - inset_x,
|
||||
y - inset_y, button);
|
||||
inset->edit(bv, x - inset_x,
|
||||
y - inset_y, button);
|
||||
cmd1.x = cmd.x - inset_x;
|
||||
cmd1.y = cmd.x - inset_y;
|
||||
ret = inset->localDispatch(cmd1);
|
||||
inset->edit(bv, cmd1.x, cmd1.y, cmd.button());
|
||||
}
|
||||
updateLocal(bv, CURSOR_PAR, false);
|
||||
}
|
||||
@ -1129,17 +1129,21 @@ bool InsetText::insetButtonRelease(BufferView * bv,
|
||||
}
|
||||
|
||||
|
||||
void InsetText::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::state state)
|
||||
void InsetText::lfunMouseMotion(FuncRequest const & cmd)
|
||||
{
|
||||
FuncRequest cmd1 = cmd;
|
||||
cmd1.x -= inset_x;
|
||||
cmd1.y -= inset_y;
|
||||
|
||||
if (the_locking_inset) {
|
||||
the_locking_inset->insetMotionNotify(bv, x - inset_x,
|
||||
y - inset_y,state);
|
||||
the_locking_inset->localDispatch(cmd1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (no_selection || ((mouse_x == x) && (mouse_y == y)))
|
||||
if (no_selection || (mouse_x == cmd.x && mouse_y == cmd.y))
|
||||
return;
|
||||
|
||||
BufferView * bv = cmd.view();
|
||||
bool clear = false;
|
||||
if (!lt) {
|
||||
lt = getLyXText(bv);
|
||||
@ -1147,7 +1151,8 @@ void InsetText::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::s
|
||||
}
|
||||
hideInsetCursor(bv);
|
||||
LyXCursor cur = lt->cursor;
|
||||
lt->setCursorFromCoordinates(bv, x - drawTextXOffset, y + insetAscent);
|
||||
lt->setCursorFromCoordinates
|
||||
(bv, cmd.x - drawTextXOffset, cmd.y + insetAscent);
|
||||
lt->cursor.x_fix(lt->cursor.x());
|
||||
if (cur == lt->cursor) {
|
||||
if (clear)
|
||||
@ -1166,13 +1171,12 @@ void InsetText::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::s
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT
|
||||
InsetText::localDispatch(FuncRequest const & ev)
|
||||
Inset::RESULT InsetText::localDispatch(FuncRequest const & ev)
|
||||
{
|
||||
BufferView * bv = ev.view();
|
||||
bool was_empty = (paragraphs.begin()->empty() && !paragraphs.begin()->next());
|
||||
no_selection = false;
|
||||
RESULT result= UpdatableInset::localDispatch(ev);
|
||||
RESULT result = UpdatableInset::localDispatch(ev);
|
||||
if (result != UNDISPATCHED)
|
||||
return DISPATCHED;
|
||||
|
||||
@ -1825,7 +1829,7 @@ void InsetText::fitInsetCursor(BufferView * bv) const
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT
|
||||
Inset::RESULT
|
||||
InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
|
||||
{
|
||||
if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
|
||||
@ -1835,7 +1839,7 @@ InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT
|
||||
Inset::RESULT
|
||||
InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting)
|
||||
{
|
||||
if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
|
||||
@ -1845,7 +1849,7 @@ InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting)
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT
|
||||
Inset::RESULT
|
||||
InsetText::moveRightIntern(BufferView * bv, bool front,
|
||||
bool activate_inset, bool selecting)
|
||||
{
|
||||
@ -1860,7 +1864,7 @@ InsetText::moveRightIntern(BufferView * bv, bool front,
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT
|
||||
Inset::RESULT
|
||||
InsetText::moveLeftIntern(BufferView * bv, bool front,
|
||||
bool activate_inset, bool selecting)
|
||||
{
|
||||
@ -1875,7 +1879,7 @@ InsetText::moveLeftIntern(BufferView * bv, bool front,
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT
|
||||
Inset::RESULT
|
||||
InsetText::moveUp(BufferView * bv)
|
||||
{
|
||||
if (!crow(bv)->previous())
|
||||
@ -1885,7 +1889,7 @@ InsetText::moveUp(BufferView * bv)
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT
|
||||
Inset::RESULT
|
||||
InsetText::moveDown(BufferView * bv)
|
||||
{
|
||||
if (!crow(bv)->next())
|
||||
|
@ -125,12 +125,6 @@ public:
|
||||
///
|
||||
bool updateInsetInInset(BufferView *, Inset *);
|
||||
///
|
||||
bool insetButtonRelease(BufferView *, int, int, mouse_button::state);
|
||||
///
|
||||
void insetButtonPress(BufferView *, int, int, mouse_button::state);
|
||||
///
|
||||
void insetMotionNotify(BufferView *, int, int, mouse_button::state);
|
||||
///
|
||||
RESULT localDispatch(FuncRequest const &);
|
||||
///
|
||||
int latex(Buffer const *, std::ostream &,
|
||||
@ -276,6 +270,13 @@ protected:
|
||||
LColor::color frame_color;
|
||||
|
||||
private:
|
||||
///
|
||||
void lfunMousePress(FuncRequest const &);
|
||||
///
|
||||
bool lfunMouseRelease(FuncRequest const &);
|
||||
///
|
||||
void lfunMouseMotion(FuncRequest const &);
|
||||
|
||||
///
|
||||
struct InnerCache {
|
||||
///
|
||||
@ -292,26 +293,26 @@ private:
|
||||
///
|
||||
int beginningOfMainBody(Paragraph * par) const;
|
||||
///
|
||||
UpdatableInset::RESULT moveRight(BufferView *,
|
||||
RESULT moveRight(BufferView *,
|
||||
bool activate_inset = true,
|
||||
bool selecting = false);
|
||||
///
|
||||
UpdatableInset::RESULT moveLeft(BufferView *,
|
||||
RESULT moveLeft(BufferView *,
|
||||
bool activate_inset = true,
|
||||
bool selecting = false);
|
||||
///
|
||||
UpdatableInset::RESULT moveRightIntern(BufferView *, bool front,
|
||||
RESULT moveRightIntern(BufferView *, bool front,
|
||||
bool activate_inset = true,
|
||||
bool selecting = false);
|
||||
///
|
||||
UpdatableInset::RESULT moveLeftIntern(BufferView *, bool front,
|
||||
RESULT moveLeftIntern(BufferView *, bool front,
|
||||
bool activate_inset = true,
|
||||
bool selecting = false);
|
||||
|
||||
///
|
||||
UpdatableInset::RESULT moveUp(BufferView *);
|
||||
RESULT moveUp(BufferView *);
|
||||
///
|
||||
UpdatableInset::RESULT moveDown(BufferView *);
|
||||
RESULT moveDown(BufferView *);
|
||||
///
|
||||
void setCharFont(Buffer const *, int pos, LyXFont const & font);
|
||||
///
|
||||
|
@ -736,7 +736,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
|
||||
}
|
||||
|
||||
if (view()->available() && view()->theLockingInset()) {
|
||||
UpdatableInset::RESULT result;
|
||||
Inset::RESULT result;
|
||||
if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
|
||||
(!keyseq.deleted())))
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
#include "command_inset.h"
|
||||
#include "math_mathmlstream.h"
|
||||
#include "funcrequest.h"
|
||||
|
||||
|
||||
CommandInset::CommandInset(string const & data)
|
||||
@ -26,6 +27,17 @@ MathInset * CommandInset::clone() const
|
||||
}
|
||||
|
||||
|
||||
MathInset::result_type
|
||||
CommandInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
default:
|
||||
return ButtonInset::dispatch(cmd, idx, pos);
|
||||
}
|
||||
return UNDISPATCHED;
|
||||
}
|
||||
|
||||
|
||||
void CommandInset::write(WriteStream & os) const
|
||||
{
|
||||
os << "\\" << name_.c_str();
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
///
|
||||
//void infoize(std::ostream & os) const;
|
||||
///
|
||||
//int dispatch(string const & cmd, idx_type idx, pos_type pos);
|
||||
result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
|
||||
///
|
||||
string screenLabel() const;
|
||||
public:
|
||||
|
@ -213,6 +213,11 @@ void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
|
||||
// calling metrics here destroys the cached xo,yo positions e.g. in
|
||||
// MathParboxinset. And it would be too expensive anyway...
|
||||
//metrics(bv);
|
||||
if (!mathcursor) {
|
||||
lyxerr << "getCursorPos - should not happen";
|
||||
x = y = 0;
|
||||
return;
|
||||
}
|
||||
mathcursor->getPos(x, y);
|
||||
//x -= xo_;
|
||||
y -= yo_;
|
||||
@ -286,124 +291,117 @@ void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
|
||||
}
|
||||
|
||||
|
||||
bool InsetFormulaBase::insetButtonRelease(BufferView * bv,
|
||||
int x, int y, mouse_button::state button)
|
||||
Inset::RESULT InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
|
||||
{
|
||||
if (!mathcursor)
|
||||
return false;
|
||||
return UNDISPATCHED;
|
||||
|
||||
//lyxerr << "insetButtonRelease: " << x << " " << y << "\n";
|
||||
BufferView * bv = cmd.view();
|
||||
hideInsetCursor(bv);
|
||||
showInsetCursor(bv);
|
||||
bv->updateInset(this, false);
|
||||
|
||||
if (button == mouse_button::button3) {
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
// try to dispatch to enclosed insets first
|
||||
if (mathcursor->dispatch(FuncRequest(bv, LFUN_MOUSE_RELEASE, x, y, 3)))
|
||||
return true;
|
||||
|
||||
// launch math panel for right mouse button
|
||||
bv->owner()->getDialogs().showMathPanel();
|
||||
return true;
|
||||
if (mathcursor->dispatch(cmd) == MathInset::UNDISPATCHED) {
|
||||
// launch math panel for right mouse button
|
||||
bv->owner()->getDialogs().showMathPanel();
|
||||
}
|
||||
return DISPATCHED;
|
||||
}
|
||||
|
||||
if (button == mouse_button::button1) {
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
// try to dispatch to enclosed insets first
|
||||
if (mathcursor->dispatch(FuncRequest(bv, LFUN_MOUSE_RELEASE, x, y, 1)))
|
||||
return true;
|
||||
|
||||
mathcursor->dispatch(cmd);
|
||||
// try to set the cursor
|
||||
//delete mathcursor;
|
||||
//mathcursor = new MathCursor(this, x == 0);
|
||||
//metrics(bv);
|
||||
//mathcursor->setPos(x + xo_, y + yo_);
|
||||
return true;
|
||||
return DISPATCHED;
|
||||
}
|
||||
return false;
|
||||
return UNDISPATCHED;
|
||||
}
|
||||
|
||||
|
||||
void InsetFormulaBase::insetButtonPress(BufferView * bv,
|
||||
int x, int y, mouse_button::state button)
|
||||
Inset::RESULT InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "insetButtonPress: "
|
||||
// << x << " " << y << " but: " << button << "\n";
|
||||
//lyxerr << "formula: ";
|
||||
//par()->dump();
|
||||
|
||||
BufferView * bv = cmd.view();
|
||||
releaseMathCursor(bv);
|
||||
mathcursor = new MathCursor(this, x == 0);
|
||||
mathcursor = new MathCursor(this, cmd.x == 0);
|
||||
|
||||
if (button == mouse_button::button1) {
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
// just set the cursor here
|
||||
//lyxerr << "setting cursor\n";
|
||||
metrics(bv);
|
||||
first_x = x;
|
||||
first_y = y;
|
||||
first_x = cmd.x;
|
||||
first_y = cmd.y;
|
||||
mathcursor->selClear();
|
||||
mathcursor->setPos(x + xo_, y + yo_);
|
||||
|
||||
if (mathcursor->dispatch(FuncRequest(bv, LFUN_MOUSE_PRESS, x, y, 1))) {
|
||||
//delete mathcursor;
|
||||
return;
|
||||
}
|
||||
|
||||
mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
|
||||
mathcursor->dispatch(cmd);
|
||||
return DISPATCHED;
|
||||
}
|
||||
if (button == mouse_button::button3) {
|
||||
if (mathcursor->dispatch(FuncRequest(bv, LFUN_MOUSE_PRESS, x, y, 3))) {
|
||||
//delete mathcursor;
|
||||
return;
|
||||
}
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
mathcursor->dispatch(cmd);
|
||||
//delete mathcursor;
|
||||
return DISPATCHED;
|
||||
}
|
||||
bv->updateInset(this, false);
|
||||
return DISPATCHED;
|
||||
}
|
||||
|
||||
|
||||
void InsetFormulaBase::insetMotionNotify(BufferView * bv,
|
||||
int x, int y, mouse_button::state button)
|
||||
Inset::RESULT InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
|
||||
{
|
||||
if (!mathcursor)
|
||||
return;
|
||||
return DISPATCHED;
|
||||
|
||||
if (button == mouse_button::button1)
|
||||
if (mathcursor->dispatch(FuncRequest(bv, LFUN_MOUSE_MOTION, x, y, 1)))
|
||||
return;
|
||||
if (mathcursor->dispatch(FuncRequest(cmd)) != MathInset::UNDISPATCHED)
|
||||
return DISPATCHED;
|
||||
|
||||
if (button == mouse_button::button3)
|
||||
if (mathcursor->dispatch(FuncRequest(bv, LFUN_MOUSE_MOTION, x, y, 3)))
|
||||
return;
|
||||
|
||||
if (abs(x - first_x) < 2 && abs(y - first_y) < 2) {
|
||||
if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2) {
|
||||
//lyxerr << "insetMotionNotify: ignored\n";
|
||||
return;
|
||||
return DISPATCHED;
|
||||
}
|
||||
first_x = x;
|
||||
first_y = y;
|
||||
first_x = cmd.x;
|
||||
first_y = cmd.y;
|
||||
|
||||
if (!mathcursor->selection())
|
||||
mathcursor->selStart();
|
||||
|
||||
//lyxerr << "insetMotionNotify: " << x + xo_ << ' ' << y + yo_
|
||||
// << ' ' << button << "\n";
|
||||
BufferView * bv = cmd.view();
|
||||
hideInsetCursor(bv);
|
||||
mathcursor->setPos(x + xo_, y + yo_);
|
||||
mathcursor->setPos(cmd.x + xo_, cmd.y + yo_);
|
||||
showInsetCursor(bv);
|
||||
bv->updateInset(this, false);
|
||||
return DISPATCHED;
|
||||
}
|
||||
|
||||
|
||||
UpdatableInset::RESULT
|
||||
InsetFormulaBase::localDispatch(FuncRequest const & ev)
|
||||
Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
|
||||
{
|
||||
//lyxerr << "InsetFormulaBase::localDispatch: act: " << action
|
||||
// << " arg: '" << arg
|
||||
// << "' cursor: " << mathcursor << "\n";
|
||||
//lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action
|
||||
// << " arg: '" << cmd.argument
|
||||
// << " x: '" << cmd.x
|
||||
// << " y: '" << cmd.y
|
||||
// << "' button: " << cmd.button() << "\n";
|
||||
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
return lfunMousePress(cmd);
|
||||
case LFUN_MOUSE_MOTION:
|
||||
return lfunMouseMotion(cmd);
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
return lfunMouseRelease(cmd);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!mathcursor)
|
||||
return UNDISPATCHED;
|
||||
|
||||
BufferView * bv = ev.view();
|
||||
string argument = ev.argument;
|
||||
BufferView * bv = cmd.view();
|
||||
string argument = cmd.argument;
|
||||
RESULT result = DISPATCHED;
|
||||
bool sel = false;
|
||||
bool was_macro = mathcursor->inMacroMode();
|
||||
@ -414,7 +412,7 @@ InsetFormulaBase::localDispatch(FuncRequest const & ev)
|
||||
mathcursor->normalize();
|
||||
mathcursor->touch();
|
||||
|
||||
switch (ev.action) {
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_MATH_MUTATE:
|
||||
case LFUN_MATH_DISPLAY:
|
||||
@ -432,7 +430,7 @@ InsetFormulaBase::localDispatch(FuncRequest const & ev)
|
||||
case LFUN_INSERT_LABEL:
|
||||
case LFUN_MATH_EXTERN:
|
||||
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||
mathcursor->dispatch(ev);
|
||||
mathcursor->dispatch(cmd);
|
||||
updateLocal(bv, true);
|
||||
break;
|
||||
|
||||
@ -528,7 +526,7 @@ InsetFormulaBase::localDispatch(FuncRequest const & ev)
|
||||
lyxerr << "LFUN_SETXY broken!\n";
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
istringstream is(ev.argument.c_str());
|
||||
istringstream is(cmd.argument.c_str());
|
||||
is >> x >> y;
|
||||
mathcursor->setPos(x, y);
|
||||
updateLocal(bv, false);
|
||||
@ -566,7 +564,7 @@ InsetFormulaBase::localDispatch(FuncRequest const & ev)
|
||||
// Special casing for superscript in case of LyX handling
|
||||
// dead-keys:
|
||||
case LFUN_CIRCUMFLEX:
|
||||
if (ev.argument.empty()) {
|
||||
if (cmd.argument.empty()) {
|
||||
// do superscript if LyX handles
|
||||
// deadkeys
|
||||
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||
@ -592,28 +590,28 @@ InsetFormulaBase::localDispatch(FuncRequest const & ev)
|
||||
break;
|
||||
|
||||
// Math fonts
|
||||
case LFUN_GREEK_TOGGLE: handleFont(bv, ev.argument, "lyxgreek"); break;
|
||||
case LFUN_BOLD: handleFont(bv, ev.argument, "textbf"); break;
|
||||
case LFUN_SANS: handleFont(bv, ev.argument, "textsf"); break;
|
||||
case LFUN_EMPH: handleFont(bv, ev.argument, "mathcal"); break;
|
||||
case LFUN_ROMAN: handleFont(bv, ev.argument, "mathrm"); break;
|
||||
case LFUN_CODE: handleFont(bv, ev.argument, "texttt"); break;
|
||||
case LFUN_FRAK: handleFont(bv, ev.argument, "mathfrak"); break;
|
||||
case LFUN_ITAL: handleFont(bv, ev.argument, "mathit"); break;
|
||||
case LFUN_NOUN: handleFont(bv, ev.argument, "mathbb"); break;
|
||||
case LFUN_DEFAULT: handleFont(bv, ev.argument, "textnormal"); break;
|
||||
case LFUN_FREE: handleFont(bv, ev.argument, "textrm"); break;
|
||||
case LFUN_GREEK_TOGGLE: handleFont(bv, cmd.argument, "lyxgreek"); break;
|
||||
case LFUN_BOLD: handleFont(bv, cmd.argument, "textbf"); break;
|
||||
case LFUN_SANS: handleFont(bv, cmd.argument, "textsf"); break;
|
||||
case LFUN_EMPH: handleFont(bv, cmd.argument, "mathcal"); break;
|
||||
case LFUN_ROMAN: handleFont(bv, cmd.argument, "mathrm"); break;
|
||||
case LFUN_CODE: handleFont(bv, cmd.argument, "texttt"); break;
|
||||
case LFUN_FRAK: handleFont(bv, cmd.argument, "mathfrak"); break;
|
||||
case LFUN_ITAL: handleFont(bv, cmd.argument, "mathit"); break;
|
||||
case LFUN_NOUN: handleFont(bv, cmd.argument, "mathbb"); break;
|
||||
case LFUN_DEFAULT: handleFont(bv, cmd.argument, "textnormal"); break;
|
||||
case LFUN_FREE: handleFont(bv, cmd.argument, "textrm"); break;
|
||||
|
||||
case LFUN_GREEK:
|
||||
handleFont(bv, ev.argument, "lyxgreek1");
|
||||
if (ev.argument.size())
|
||||
mathcursor->interpret(ev.argument);
|
||||
handleFont(bv, cmd.argument, "lyxgreek1");
|
||||
if (cmd.argument.size())
|
||||
mathcursor->interpret(cmd.argument);
|
||||
break;
|
||||
|
||||
case LFUN_MATH_MODE:
|
||||
if (mathcursor->currentMode()) {
|
||||
handleFont(bv, ev.argument, "textrm");
|
||||
} else {
|
||||
if (mathcursor->currentMode())
|
||||
handleFont(bv, cmd.argument, "textrm");
|
||||
else {
|
||||
mathcursor->niceInsert(MathAtom(new MathHullInset("simple")));
|
||||
updateLocal(bv, true);
|
||||
}
|
||||
@ -637,9 +635,9 @@ InsetFormulaBase::localDispatch(FuncRequest const & ev)
|
||||
break;
|
||||
|
||||
case LFUN_INSERT_MATRIX:
|
||||
if (!ev.argument.empty()) {
|
||||
if (!cmd.argument.empty()) {
|
||||
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||
mathcursor->interpret("matrix " + ev.argument);
|
||||
mathcursor->interpret("matrix " + cmd.argument);
|
||||
updateLocal(bv, true);
|
||||
}
|
||||
break;
|
||||
@ -648,7 +646,7 @@ InsetFormulaBase::localDispatch(FuncRequest const & ev)
|
||||
case LFUN_SUBSCRIPT:
|
||||
{
|
||||
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||
mathcursor->script(ev.action == LFUN_SUPERSCRIPT);
|
||||
mathcursor->script(cmd.action == LFUN_SUPERSCRIPT);
|
||||
updateLocal(bv, true);
|
||||
break;
|
||||
}
|
||||
@ -657,7 +655,7 @@ InsetFormulaBase::localDispatch(FuncRequest const & ev)
|
||||
{
|
||||
//lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
|
||||
string ls;
|
||||
string rs = split(ev.argument, ls, ' ');
|
||||
string rs = split(cmd.argument, ls, ' ');
|
||||
// Reasonable default values
|
||||
if (ls.empty())
|
||||
ls = '(';
|
||||
@ -743,13 +741,13 @@ InsetFormulaBase::localDispatch(FuncRequest const & ev)
|
||||
// updateInset(inset, true);
|
||||
//}
|
||||
//
|
||||
if (ev.argument.empty()) {
|
||||
if (cmd.argument.empty()) {
|
||||
InsetCommandParams p("ref");
|
||||
bv->owner()->getDialogs().createRef(p.getAsString());
|
||||
} else {
|
||||
//mathcursor->handleNest(new InsetRef2);
|
||||
//mathcursor->insert(arg);
|
||||
mathcursor->insert(MathAtom(new RefInset(ev.argument)));
|
||||
mathcursor->insert(MathAtom(new RefInset(cmd.argument)));
|
||||
}
|
||||
updateLocal(bv, true);
|
||||
break;
|
||||
|
@ -78,12 +78,6 @@ public:
|
||||
///
|
||||
virtual void toggleInsetSelection(BufferView * bv);
|
||||
///
|
||||
virtual void insetButtonPress(BufferView *, int x, int y, mouse_button::state button);
|
||||
///
|
||||
virtual bool insetButtonRelease(BufferView *, int x, int y, mouse_button::state button);
|
||||
///
|
||||
virtual void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
|
||||
///
|
||||
virtual void insetUnlock(BufferView *);
|
||||
|
||||
/// To allow transparent use of math editing functions
|
||||
@ -115,7 +109,7 @@ public:
|
||||
///
|
||||
virtual void revealCodes(BufferView *) const;
|
||||
///
|
||||
virtual Inset::EDITABLE editable() const { return HIGHLY_EDITABLE; }
|
||||
virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
|
||||
///
|
||||
bool display() const;
|
||||
|
||||
@ -124,6 +118,12 @@ private:
|
||||
void operator=(const InsetFormulaBase &);
|
||||
/// common base for handling accents
|
||||
void handleAccent(BufferView * bv, string const & arg, string const & name);
|
||||
/// lfun handler
|
||||
RESULT lfunMousePress(FuncRequest const &);
|
||||
///
|
||||
RESULT lfunMouseRelease(FuncRequest const &);
|
||||
///
|
||||
RESULT lfunMouseMotion(FuncRequest const &);
|
||||
|
||||
protected:
|
||||
///
|
||||
|
@ -410,6 +410,8 @@ void MathHullInset::addRow(row_type row)
|
||||
|
||||
void MathHullInset::delRow(row_type row)
|
||||
{
|
||||
if (nrows() <= 1)
|
||||
return;
|
||||
MathGridInset::delRow(row);
|
||||
nonum_.erase(nonum_.begin() + row);
|
||||
label_.erase(label_.begin() + row);
|
||||
|
@ -318,9 +318,11 @@ MathInset::result_type MathNestInset::dispatch
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_PASTE: {
|
||||
//lyxerr << "pasting '" << cmd.argument << "'\n";
|
||||
lyxerr << "pasting '" << cmd.argument << "'\n";
|
||||
MathArray ar;
|
||||
mathed_parse_cell(ar, cmd.argument);
|
||||
lyxerr << "pasting '" << ar << "'\n";
|
||||
lyxerr << "cell(idx) '" << cell(idx) << "'\n";
|
||||
cell(idx).insert(pos, ar);
|
||||
pos += ar.size();
|
||||
return DISPATCHED;
|
||||
|
@ -36,16 +36,16 @@ void RefInset::infoize(std::ostream & os) const
|
||||
|
||||
|
||||
MathInset::result_type
|
||||
RefInset::dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
|
||||
RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
if (cmd.extra == 3) {
|
||||
if (cmd.button() == mouse_button::button3) {
|
||||
lyxerr << "trying to goto ref" << cell(0) << "\n";
|
||||
cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
|
||||
return DISPATCHED;
|
||||
}
|
||||
if (cmd.extra == 1) {
|
||||
if (cmd.button() == mouse_button::button1) {
|
||||
lyxerr << "trying to open ref" << cell(0) << "\n";
|
||||
// Eventually trigger dialog with button 3 not 1
|
||||
// cmd.view()->owner()->getDialogs()->showRef(this);
|
||||
@ -57,7 +57,7 @@ RefInset::dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
|
||||
// eat other mouse commands
|
||||
return DISPATCHED;
|
||||
default:
|
||||
break;
|
||||
return CommandInset::dispatch(cmd, idx, pos);
|
||||
}
|
||||
// not our business
|
||||
return UNDISPATCHED;
|
||||
|
Loading…
Reference in New Issue
Block a user