? 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;
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)
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)
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;
}
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
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 */
};
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)
{}
{
view_ = view;
}
+
+
+mouse_button::state FuncRequest::button() const
+{
+ return button_;
+}
+
#define FUNCREQUEST_H
#include "commandtags.h"
+#include "frontends/mouse_state.h"
#include "LString.h"
class BufferView;
/// 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
/// the y coordinate of a mouse press
int y;
/// some extra information (like button number)
- int extra;
+ mouse_button::state button_;
};
#endif // FUNCREQUEST_H
}
+void Inset::edit(BufferView *, int, int, mouse_button::state)
+{}
+
+
void Inset::validate(LaTeXFeatures &) const
{}
}
-void Inset::edit(BufferView *, int, int, mouse_button::state)
+void Inset::edit(BufferView *, bool)
{}
-void Inset::edit(BufferView *, bool)
-{}
+Inset::RESULT Inset::localDispatch(FuncRequest const &)
+{
+ return UNDISPATCHED;
+}
#if 0
{}
-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;
/// 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));
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();
///
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; }
///
*/
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();
///
///
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);
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_; }
///
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;
}
}
-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;
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);
}
}
}
-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;
}
///
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 &,
mutable UpdateCodes need_update;
private:
+ ///
+ void lfunMousePress(FuncRequest const &);
+ ///
+ bool lfunMouseRelease(FuncRequest const &);
+ ///
+ void lfunMouseMotion(FuncRequest const &);
+
///
mutable string label;
#if 0
}
-
-
-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);
}
}
-int InsetERT::ascii(Buffer const *,
- ostream &, int /*linelen*/) const
+int InsetERT::ascii(Buffer const *, ostream &, int /*linelen*/) const
{
return 0;
}
}
-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:
///
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;
///
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();
///
}
-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) {
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);
}
#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);
}
-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();
// 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);
}
}
- 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);
}
-UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
+Inset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
{
if (lock && !old_locking_inset) {
if (activateCellInset(bv))
}
-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)
}
-UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv, bool lock)
+Inset::RESULT InsetTabular::moveUp(BufferView * bv, bool lock)
{
int const ocell = actcell;
actcell = tabular->GetCellAbove(actcell);
}
-UpdatableInset::RESULT InsetTabular::moveDown(BufferView * bv, bool lock)
+Inset::RESULT InsetTabular::moveDown(BufferView * bv, bool lock)
{
int const ocell = actcell;
actcell = tabular->GetCellBelow(actcell);
///
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;
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;
///
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);
///
}
-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
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);
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;
}
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;
}
}
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());
// 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
}
-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);
}
}
-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);
}
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)
}
-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;
}
-UpdatableInset::RESULT
+Inset::RESULT
InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
{
if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
}
-UpdatableInset::RESULT
+Inset::RESULT
InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting)
{
if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
}
-UpdatableInset::RESULT
+Inset::RESULT
InsetText::moveRightIntern(BufferView * bv, bool front,
bool activate_inset, bool selecting)
{
}
-UpdatableInset::RESULT
+Inset::RESULT
InsetText::moveLeftIntern(BufferView * bv, bool front,
bool activate_inset, bool selecting)
{
}
-UpdatableInset::RESULT
+Inset::RESULT
InsetText::moveUp(BufferView * bv)
{
if (!crow(bv)->previous())
}
-UpdatableInset::RESULT
+Inset::RESULT
InsetText::moveDown(BufferView * bv)
{
if (!crow(bv)->next())
///
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 &,
LColor::color frame_color;
private:
+ ///
+ void lfunMousePress(FuncRequest const &);
+ ///
+ bool lfunMouseRelease(FuncRequest const &);
+ ///
+ void lfunMouseMotion(FuncRequest const &);
+
///
struct InnerCache {
///
///
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);
///
}
if (view()->available() && view()->theLockingInset()) {
- UpdatableInset::RESULT result;
+ Inset::RESULT result;
if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) &&
(!keyseq.deleted())))
{
#include "command_inset.h"
#include "math_mathmlstream.h"
+#include "funcrequest.h"
CommandInset::CommandInset(string const & data)
}
+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();
///
//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:
// 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_;
}
-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();
mathcursor->normalize();
mathcursor->touch();
- switch (ev.action) {
+ switch (cmd.action) {
case LFUN_MATH_MUTATE:
case LFUN_MATH_DISPLAY:
case LFUN_INSERT_LABEL:
case LFUN_MATH_EXTERN:
bv->lockedInsetStoreUndo(Undo::EDIT);
- mathcursor->dispatch(ev);
+ mathcursor->dispatch(cmd);
updateLocal(bv, true);
break;
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);
// 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);
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);
}
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;
case LFUN_SUBSCRIPT:
{
bv->lockedInsetStoreUndo(Undo::EDIT);
- mathcursor->script(ev.action == LFUN_SUPERSCRIPT);
+ mathcursor->script(cmd.action == LFUN_SUPERSCRIPT);
updateLocal(bv, true);
break;
}
{
//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 = '(';
// 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;
///
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
///
virtual void revealCodes(BufferView *) const;
///
- virtual Inset::EDITABLE editable() const { return HIGHLY_EDITABLE; }
+ virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
///
bool display() const;
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:
///
void MathHullInset::delRow(row_type row)
{
+ if (nrows() <= 1)
+ return;
MathGridInset::delRow(row);
nonum_.erase(nonum_.begin() + row);
label_.erase(label_.begin() + row);
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;
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);
// eat other mouse commands
return DISPATCHED;
default:
- break;
+ return CommandInset::dispatch(cmd, idx, pos);
}
// not our business
return UNDISPATCHED;