+ /// is this an inset that can be moved into?
+ /// FIXME: merge with editable()
+ virtual bool isActive() const { return nargs() > 0; }
+ /// Where should we go when we press the up or down cursor key?
+ virtual bool idxUpDown(Cursor & cur, bool up) const;
+ /// Move one cell backwards
+ virtual bool idxBackward(Cursor &) const { return false; }
+ /// Move one cell forward
+ virtual bool idxForward(Cursor &) const { return false; }
+
+ /// Move to the next cell
+ virtual bool idxNext(Cursor &) const { return false; }
+ /// Move to the previous cell
+ virtual bool idxPrev(Cursor &) const { return false; }
+
+ /// Target pos when we enter the inset while moving forward
+ virtual bool idxFirst(Cursor &) const { return false; }
+ /// Target pos when we enter the inset while moving backwards
+ virtual bool idxLast(Cursor &) const { return false; }
+
+ /// Delete a cell and move cursor
+ virtual bool idxDelete(idx_type &) { return false; }
+ /// pulls cell after pressing erase
+ virtual void idxGlue(idx_type) {}
+ /// returns list of cell indices that are "between" from and to for
+ /// selection purposes
+ virtual bool idxBetween(idx_type idx, idx_type from, idx_type to) const;
+
+ /// to which column belongs a cell with a given index?
+ virtual col_type col(idx_type) const { return 0; }
+ /// to which row belongs a cell with a given index?
+ virtual row_type row(idx_type) const { return 0; }
+ /// cell idex corresponding to row and column;
+ virtual idx_type index(row_type row, col_type col) const;
+ /// any additional x-offset when drawing a cell?
+ virtual int cellXOffset(idx_type) const { return 0; }
+ /// any additional y-offset when drawing a cell?
+ virtual int cellYOffset(idx_type) 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
+ /// returns true if cursor is now invalid. The cursor parameter
+ /// is _not_ necessarily pointing to the inset.
+ virtual bool notifyCursorLeaves(Cursor &) { return false; }
+ /// is called when the mouse enter or leave this inset
+ /// return true if this inset needs repaint
+ virtual bool setMouseHover(bool) { return false; }
+ /// return true if this inset is hovered (under mouse)
+ /// This is by now only used by mathed to draw corners
+ /// (Inset::drawMarkers() and Inset::drawMarkers2()).
+ /// Other insets do not have to redefine this function to
+ /// return the correct status of mouseHovered.
+ virtual bool mouseHovered() const { return false; }
+
+ /// request "external features"
+ virtual void validate(LaTeXFeatures &) const {}
+ /// Appends \c list with all labels found within this inset.
+ virtual void getLabelList(Buffer const &,
+ std::vector<docstring> & /* list */) const {}
+
+ /// describe content if cursor inside
+ virtual void infoize(odocstream &) const {}
+ /// describe content if cursor behind
+ virtual void infoize2(odocstream &) const {}
+
+ enum {
+ PLAINTEXT_NEWLINE = 10000
+ };
+
+ /// plain text output in ucs4 encoding
+ /// return the number of characters; in case of multiple lines of
+ /// output, add PLAINTEXT_NEWLINE to the number of chars in the last line
+ virtual int plaintext(Buffer const &, odocstream &,
+ OutputParams const &) const = 0;
+ /// docbook output
+ virtual int docbook(Buffer const &, odocstream & os,
+ OutputParams const &) const;
+ /// the string that is passed to the TOC
+ virtual void textString(Buffer const &, odocstream &) const {}
+
+ /** This enum indicates by which means the inset can be modified:
+ - NOT_EDITABLE: the inset's content cannot be modified at all
+ (e.g. printindex, insetspecialchar)
+ - IS_EDITABLE: content can be edited via dialog (e.g. bibtex, index, href)
+ - HIGHLY_EDITABLE: content can be edited on screen (normally means that
+ insettext is contained, e.g. collapsables, tabular) */
+ // FIXME: This has not yet been fully implemented to math insets
+ enum EDITABLE {
+ ///
+ NOT_EDITABLE = 0,
+ ///
+ IS_EDITABLE,
+ ///
+ HIGHLY_EDITABLE
+ };
+ /// what appears in the minibuffer when opening
+ virtual docstring const editMessage() const;
+ ///
+ virtual EDITABLE editable() const;
+ /// can we go further down on mouse click?
+ virtual bool descendable() const { return false; }
+ /// does this contain text that can be change track marked in DVI?
+ virtual bool canTrackChanges() const { return false; }
+ /// return true if the inset should be removed automatically
+ virtual bool autoDelete() const;
+
+ class CompletionList {
+ public:
+ ///
+ virtual ~CompletionList() {}
+ ///
+ virtual size_t size() const =0;
+ /// returns the string shown in the gui.
+ virtual docstring data(size_t idx) const =0;
+ /// returns the resource string used to load an icon.
+ virtual std::string icon(size_t /*idx*/) const { return std::string(); }
+ };
+
+ /// Returns true if the inset supports completions.
+ virtual bool completionSupported(Cursor const &) const { return false; }
+ /// Returns true if the inset supports inline completions at the
+ /// cursor position. In this case the completion might be stored
+ /// in the BufferView's inlineCompletion property.
+ virtual bool inlineCompletionSupported(Cursor const & /*cur*/) const
+ { return false; }
+ /// Return true if the inline completion should be automatic.
+ virtual bool automaticInlineCompletion() const { return true; }
+ /// Return true if the popup completion should be automatic.
+ virtual bool automaticPopupCompletion() const { return true; }
+ /// Returns completion suggestions at cursor position. Return an
+ /// null pointer if no completion is a available or possible.
+ /// The caller is responsible to free the returned object!
+ virtual CompletionList const * completionList(Cursor const &) const
+ { return 0; }
+ /// Returns the completion prefix to filter the suggestions for completion.
+ /// This is only called if completionList returned a non-null list.
+ virtual docstring completionPrefix(Cursor const &) const
+ { return docstring(); }
+ /// Do a completion at the cursor position. Return true on success.
+ /// The completion does not contain the prefix. If finished is true, the
+ /// completion is final. If finished is false, completion might only be
+ /// a partial completion.
+ virtual bool insertCompletion(Cursor & /*cur*/,
+ docstring const & /*completion*/, bool /*finished*/)
+ { return false; }
+ /// Get the completion inset position and size
+ virtual void completionPosAndDim(Cursor const &, int & /*x*/, int & /*y*/,
+ Dimension & /*dim*/) const {}
+
+ /// returns true if the inset can hold an inset of given type
+ virtual bool insetAllowed(InsetCode) const { return false; }
+ /// should this inset use the empty layout by default rather than
+ /// the standard layout? (default: only if that is forced.)
+ virtual bool useEmptyLayout() const { return forceEmptyLayout(); }
+ /// if this inset has paragraphs should they be forced to use the
+ /// empty layout?
+ virtual bool forceEmptyLayout() const { return false; }
+ /// if this inset has paragraphs should the user be allowed to
+ /// customize alignment, etc?
+ virtual bool allowParagraphCustomization(idx_type) const { return true; }
+ /// Is the width forced to some value?
+ virtual bool hasFixedWidth() const { return false; }
+
+ /// \return Tool tip for this inset.
+ /// This default implementation returns an empty string.
+ virtual docstring toolTip(BufferView const & bv, int x, int y) const;
+
+ /// \return Context menu identifier for this inset.
+ /// This default implementation returns an empty string.
+ virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
+
+ // FIXME This should really disappear in favor of
+ // docstring name() const { return from_ascii(insetName(lyxCode()))); }
+ // There's no reason to be using different names in different places.
+ // But to do this we would need to change the file format, since the names
+ // used there don't correspond to what is used here.
+ ///
+ virtual docstring name() const;