]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetbase.h
use LCursor & in notifyCursorLeave
[lyx.git] / src / insets / insetbase.h
index 23d390db455fd3c1b63c2aaf26e773817521b046..bd1e3054d74f1272032807f5cef14ccceb45c16d 100644 (file)
@@ -21,6 +21,7 @@ class BufferView;
 class CursorSlice;
 class DispatchResult;
 class FuncRequest;
+class FuncStatus;
 class LaTeXFeatures;
 class LCursor;
 class LyXLex;
@@ -66,19 +67,26 @@ public:
        virtual MathInset * asMathInset() { return 0; }
        /// identification as non-math inset
        virtual UpdatableInset * asUpdatableInset() { return 0; }
+       /// true for 'math' math inset, but not for e.g. mbox
+       virtual bool inMathed() const { return false; }
 
        // the real dispatcher
-       DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd);
+       void dispatch(LCursor & cur, FuncRequest & cmd);
+       /// do we want to handle this event?
+       virtual bool getStatus(LCursor & cur, FuncRequest const & cmd,
+               FuncStatus & status) const;
 
        /// cursor enters
        virtual void edit(LCursor & cur, bool left);
        /// cursor enters
-       virtual void edit(LCursor & cur, int x, int y);
+       virtual InsetBase * editXY(LCursor & cur, int x, int y);
 
        /// compute the size of the object returned in dim
        virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
        /// draw inset and update (xo, yo)-cache
        virtual void draw(PainterInfo & pi, int x, int y) const = 0;
+       /// draw inset selection if necessary
+       virtual void drawSelection(PainterInfo &, int, int) const {}
        ///
        virtual bool editing(BufferView * bv) const;
        /// draw four angular markers
@@ -99,7 +107,7 @@ public:
        virtual bool covers(int x, int y) const;
        /// get the screen positions of the cursor (see note in cursor.C)
        virtual void getCursorPos(CursorSlice const & cur, int & x, int & y) const;
+
        /// is this an inset that can be moved into?
        virtual bool isActive() const { return nargs() > 0; }
        /// Where should we go when we press the up or down cursor key?
@@ -121,11 +129,6 @@ public:
        /// Target pos when we enter the inset from the right by pressing "Left"
        virtual bool idxLast(LCursor &) const { return false; }
 
-       /// Where should we go if we press home?
-       virtual bool idxHome(LCursor &) const { return false; }
-       /// Where should we go if we press end?
-       virtual bool idxEnd(LCursor &) const { return false; }
-
        /// Delete a cell and move cursor
        virtual bool idxDelete(idx_type &) { return false; }
        /// pulls cell after pressing erase
@@ -144,16 +147,14 @@ public:
        virtual int cellXOffset(idx_type) const { return 0; }
        /// any additional y-offset when drawing a cell?
        virtual int cellYOffset(idx_type) const { return 0; }
-       /// can we enter this cell?
-       virtual bool validCell(idx_type) const { return true; }
-       /// number of embedded cells
-       virtual size_t nargs() const { return 0; }
-       /// number of rows in gridlike structures
-       virtual size_t nrows() const { return 0; }
-       /// number of columns in gridlike structures
-       virtual size_t ncols() const { return 0; }
+       /// number of embedded cells
+       virtual size_t nargs() const { return 0; }
+       /// number of rows in gridlike structures
+       virtual size_t nrows() const { return 0; }
+       /// number of columns in gridlike structures
+       virtual size_t ncols() const { return 0; }
        /// is called when the cursor leaves this inset
-       virtual void notifyCursorLeaves(idx_type) {}
+       virtual void notifyCursorLeaves(LCursor &) {}
 
        /// request "external features"
        virtual void validate(LaTeXFeatures &) const {}
@@ -297,6 +298,12 @@ public:
                ///
                MATHHULL_CODE
        };
+
+       /** returns the Code corresponding to the \c name.
+        *  Eg, translate("branch") == BRANCH_CODE
+        */
+       static Code translate(std::string const & name);
+
        /// returns true the inset can hold an inset of given type
        virtual bool insetAllowed(Code) const { return false; }
        // if this inset has paragraphs should they be output all as default
@@ -322,6 +329,8 @@ public:
        virtual bool display() const { return false; }
        // should we break lines after this inset?
        virtual bool isLineSeparator() const { return false; }
+       /// dumps content to lyxerr
+       virtual void dump() const;
        ///
        virtual void write(Buffer const &, std::ostream &) const {}
        ///
@@ -336,10 +345,6 @@ public:
 
        /// if this insets owns text cells (e.g. InsetText) return cell num
        virtual LyXText * getText(int /*num*/) const { return 0; }
-       ///
-       virtual int numParagraphs() const { return 0; }
-       /// returns cell covering position (x,y), -1 if none exists
-       virtual int getCell(int x, int y) const;
 
        /** Adds a LaTeX snippet to the Preview Loader for transformation
         *  into a bitmap image. Does not start the laoding process.
@@ -350,8 +355,7 @@ public:
        virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
 protected:
        // the real dispatcher
-       virtual
-       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd);
 public:
        /// returns LyX code associated with the inset. Used for TOC, ...)
        virtual Code lyxCode() const { return NO_CODE; }
@@ -361,11 +365,6 @@ public:
        /// return text or mathmode if that is possible to determine
        virtual mode_type currentMode() const { return UNDECIDED_MODE; }
 
-       /// FIXME: This ought to die.
-       virtual void setOwner(UpdatableInset *) {}
-       ///
-       virtual UpdatableInset * owner() const { return 0; }
-
        /// is this inset allowed within a font change?
        virtual bool noFontChange() const { return false; }