inset.C \
inset.h \
insetbase.h \
+ insetbase.C \
insetbib.C \
insetbib.h \
insetbutton.C \
{}
-Inset::RESULT Inset::localDispatch(FuncRequest const &)
-{
- return UNDISPATCHED;
-}
-
-
#if 0
LyXFont const Inset::convertFont(LyXFont const & font) const
{
};
///
- typedef InsetBase::dispatch_result RESULT;
+ typedef dispatch_result RESULT;
///
Inset();
///
Inset(Inset const & in, bool same_id = false);
///
- virtual ~Inset() {}
- ///
virtual int ascent(BufferView *, LyXFont const &) const = 0;
///
virtual int descent(BufferView *, LyXFont const &) const = 0;
///
virtual EDITABLE editable() const;
///
- virtual RESULT localDispatch(FuncRequest const & cmd);
- ///
virtual bool isTextInset() const { return false; }
///
virtual bool doClearArea() const { return true; }
+
+#include "insetbase.h"
+
+
+dispatch_result InsetBase::dispatch(FuncRequest const &, idx_type &, pos_type &)
+{
+ return UNDISPATCHED;
+}
+
+
+dispatch_result InsetBase::localDispatch(FuncRequest const & cmd)
+{
+ idx_type idx = 0;
+ pos_type pos = 0;
+ return dispatch(cmd, idx, pos);
+}
+
#ifndef INSETBASE_H
#define INSETBASE_H
+#include <vector>
+
+class FuncRequest;
+
+/** Dispatch result codes
+ 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 dispatch_result {
+ UNDISPATCHED = 0,
+ DISPATCHED,
+ DISPATCHED_NOUPDATE,
+ FINISHED,
+ FINISHED_RIGHT,
+ FINISHED_UP,
+ FINISHED_DOWN,
+ DISPATCHED_POP
+};
+
/// Common base class to all insets
class InsetBase {
public:
- /** Dispatch result codes
- 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 dispatch_result {
- UNDISPATCHED = 0,
- DISPATCHED,
- DISPATCHED_NOUPDATE,
- FINISHED,
- FINISHED_RIGHT,
- FINISHED_UP,
- FINISHED_DOWN,
- DISPATCHED_POP
- };
+ /// type for cell indices
+ typedef size_t idx_type;
+ /// type for cursor positions
+ typedef size_t pos_type;
+ /// type for row numbers
+ typedef size_t row_type;
+ /// type for column numbers
+ typedef size_t col_type;
+
+ // the real dispatcher
+ virtual dispatch_result dispatch
+ (FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+
+ /// small wrapper for the time being
+ virtual dispatch_result localDispatch(FuncRequest const & cmd);
///
virtual ~InsetBase() {}
} else if (((result=inset->
// Hand-over to inset's own dispatch:
localDispatch(FuncRequest(view(), action, argument))) ==
- UpdatableInset::DISPATCHED) ||
- (result == UpdatableInset::DISPATCHED_NOUPDATE))
+ DISPATCHED) ||
+ (result == DISPATCHED_NOUPDATE))
goto exit_with_message;
// If UNDISPATCHED, just soldier on
- else if (result == UpdatableInset::FINISHED) {
+ else if (result == FINISHED) {
goto exit_with_message;
// We do not need special RTL handling here:
// FINISHED means that the cursor should be
// one position after the inset.
- } else if (result == UpdatableInset::FINISHED_RIGHT) {
+ } else if (result == FINISHED_RIGHT) {
TEXT()->cursorRight(view());
moveCursorUpdate(true, false);
owner->view_state_changed();
goto exit_with_message;
- } else if (result == UpdatableInset::FINISHED_UP) {
+ } else if (result == FINISHED_UP) {
if (TEXT()->cursor.irow()->previous()) {
#if 1
TEXT()->setCursorFromCoordinates(
view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR);
}
goto exit_with_message;
- } else if (result == UpdatableInset::FINISHED_DOWN) {
+ } else if (result == FINISHED_DOWN) {
if (TEXT()->cursor.irow()->next()) {
#if 1
TEXT()->setCursorFromCoordinates(
}
-MathInset::result_type
+dispatch_result
CommandInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
switch (cmd.action) {
///
//void infoize(std::ostream & os) const;
///
- result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
///
string screenLabel() const;
public:
}
-Inset::RESULT InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
+dispatch_result InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
{
if (!mathcursor)
return UNDISPATCHED;
if (cmd.button() == mouse_button::button3) {
// try to dispatch to enclosed insets first
- if (mathcursor->dispatch(cmd) == MathInset::UNDISPATCHED) {
+ if (mathcursor->dispatch(cmd) == UNDISPATCHED) {
// launch math panel for right mouse button
bv->owner()->getDialogs().showMathPanel();
}
}
-Inset::RESULT InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
+dispatch_result InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
{
BufferView * bv = cmd.view();
//lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
}
-Inset::RESULT InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
+dispatch_result InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
{
if (!mathcursor)
return DISPATCHED;
- if (mathcursor->dispatch(FuncRequest(cmd)) != MathInset::UNDISPATCHED)
+ if (mathcursor->dispatch(FuncRequest(cmd)) != UNDISPATCHED)
return DISPATCHED;
// only select with button 1
}
-Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
+dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
{
//lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action
// << " arg: '" << cmd.argument
virtual void insetUnlock(BufferView *);
/// To allow transparent use of math editing functions
- virtual RESULT localDispatch(FuncRequest const &);
+ virtual dispatch_result localDispatch(FuncRequest const &);
/// To allow transparent use of math editing functions
//virtual void status(FuncRequest const &);
/// common base for handling accents
void handleAccent(BufferView * bv, string const & arg, string const & name);
/// lfun handler
- RESULT lfunMousePress(FuncRequest const &);
+ dispatch_result lfunMousePress(FuncRequest const &);
///
- RESULT lfunMouseRelease(FuncRequest const &);
+ dispatch_result lfunMouseRelease(FuncRequest const &);
///
- RESULT lfunMouseMotion(FuncRequest const &);
+ dispatch_result lfunMouseMotion(FuncRequest const &);
protected:
///
}
-MathInset::result_type MathCursor::dispatch(FuncRequest const & cmd)
+dispatch_result MathCursor::dispatch(FuncRequest const & cmd)
{
for (int i = Cursor_.size() - 1; i >= 0; --i) {
MathCursorPos & pos = Cursor_[i];
- MathInset::result_type
- res = pos.par_->dispatch(cmd, pos.idx_, pos.pos_);
- if (res != MathInset::UNDISPATCHED) {
- if (res == MathInset::DISPATCHED_POP) {
+ dispatch_result res = pos.par_->dispatch(cmd, pos.idx_, pos.pos_);
+ if (res != UNDISPATCHED) {
+ if (res == DISPATCHED_POP) {
Cursor_.shrink(i + 1);
selClear();
}
return res;
}
}
- return MathInset::UNDISPATCHED;
+ return UNDISPATCHED;
}
unsigned depth() const;
/// local dispatcher
- MathInset::result_type dispatch(FuncRequest const & cmd);
+ dispatch_result dispatch(FuncRequest const & cmd);
/// describe the situation
string info() const;
/// dump selection information for debugging
}
-MathInset::result_type MathGridInset::dispatch
+dispatch_result MathGridInset::dispatch
(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
switch (cmd.action) {
/// identifies GridInset
MathGridInset const * asGridInset() const { return this; }
/// local dispatcher
- result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
///
col_type ncols() const;
}
-MathInset::result_type MathHullInset::dispatch
+dispatch_result MathHullInset::dispatch
(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
switch (cmd.action) {
///
bool ams() const;
/// local dispatcher
- result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
///
void getLabelList(std::vector<string> &) const;
///
}
-MathInset::result_type
- MathInset::dispatch(FuncRequest const &, idx_type &, pos_type &)
-{
- return UNDISPATCHED;
-}
-
-
string const & MathInset::getType() const
{
static string t("none");
typedef size_type row_type;
/// type for column numbers
typedef size_type col_type;
- ///
- typedef InsetBase::dispatch_result result_type;
/// our members behave nicely...
MathInset() {}
- /// the virtual base destructor
- virtual ~MathInset() {}
/// reproduce itself
virtual MathInset * clone() const = 0;
/// dump content to stderr for debugging
virtual void dump() const;
- /// local dispatcher
- virtual result_type dispatch
- (FuncRequest const & cmd, idx_type & idx, pos_type & pos);
/// LyXInset stuff
/// write labels into a list
}
-MathInset::result_type MathNestInset::dispatch
+dispatch_result MathNestInset::dispatch
(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
BufferView * bv = cmd.view();
void normalize(NormalStream & os) const;
/// local dispatcher
- result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ dispatch_result
+ dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
protected:
/// we store the cells in a vector
}
-MathInset::result_type MathScriptInset::dispatch
+dispatch_result MathScriptInset::dispatch
(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
if (cmd.action == LFUN_MATH_LIMITS) {
/// say whether we have displayed limits
void infoize2(std::ostream & os) const;
/// local dispatcher
- result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
private:
/// returns x offset for main part
}
-MathInset::result_type
+dispatch_result
RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
{
switch (cmd.action) {
///
void infoize(std::ostream & os) const;
///
- result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+ dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
///
string screenLabel() const;
///
bv->updateInset(new_inset, true);
}
+
void doInsertInset(LyXText * lt, FuncRequest const & cmd,
bool edit, bool pastesel)
{
else
delete inset;
}
-
}
}
case LFUN_BEGINNINGBUFSEL:
if (inset_owner)
- return Inset::UNDISPATCHED;
+ return UNDISPATCHED;
update(bv, false);
cursorTop(bv);
finishChange(bv, true);
case LFUN_ENDBUFSEL:
if (inset_owner)
- return Inset::UNDISPATCHED;
+ return UNDISPATCHED;
update(bv, false);
cursorBottom(bv);
finishChange(bv, true);
break;
default:
- return Inset::UNDISPATCHED;
+ return UNDISPATCHED;
}
- return Inset::DISPATCHED;
+ return DISPATCHED;
}