]> git.lyx.org Git - lyx.git/blob - src/insets/Inset.h
5a7b32e8d65ea6b919c71abd1408e4f24ebc0923
[lyx.git] / src / insets / Inset.h
1 // -*- C++ -*-
2 /**
3  * \file Inset.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alejandro Aguilar Sierra
8  * \author Jürgen Vigna
9  * \author Lars Gullik Bjønnes
10  * \author Matthias Ettrich
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef INSETBASE_H
16 #define INSETBASE_H
17
18 #include "ColorCode.h"
19 #include "InsetCode.h"
20 #include "InsetLayout.h"
21 #include "LayoutEnums.h"
22 #include "OutputEnums.h"
23
24 #include "support/strfwd.h"
25 #include "support/types.h"
26 #include "support/FileNameList.h"
27
28 #include <climits>
29
30
31 namespace lyx {
32
33 class BiblioInfo;
34 class Buffer;
35 class BufferView;
36 class Change;
37 class CompletionList;
38 class Cursor;
39 class CursorSlice;
40 class Dimension;
41 class DocIterator;
42 class FuncRequest;
43 class FuncStatus;
44 class InsetArgument;
45 class InsetCollapsible;
46 class InsetCommand;
47 class InsetIterator;
48 class InsetLayout;
49 class InsetList;
50 class InsetMath;
51 class InsetTabular;
52 class InsetText;
53 class LaTeXFeatures;
54 class Lexer;
55 class MathAtom;
56 class MetricsInfo;
57 class OutputParams;
58 class PainterInfo;
59 class ParConstIterator;
60 class ParIterator;
61 class Text;
62 class TocBackend;
63 class TocList;
64 class XHTMLStream;
65 class otexstream;
66
67 namespace graphics { class PreviewLoader; }
68
69
70 /// returns the InsetCode corresponding to the \c name.
71 /// Eg, insetCode("branch") == BRANCH_CODE
72 InsetCode insetCode(std::string const & name);
73 /// returns the Inset name corresponding to the \c InsetCode.
74 /// Eg, insetName(BRANCH_CODE) == "branch"
75 std::string insetName(InsetCode);
76 /// returns the Inset name corresponding to the \c InsetCode.
77 /// Eg, insetDisplayName(BRANCH_CODE) == _("Branch")
78 docstring insetDisplayName(InsetCode);
79 ///
80 static int const TOC_ENTRY_LENGTH = 120;
81
82 /// Common base class to all insets
83
84 // Do not add _any_ (non-static) data members as this would inflate
85 // everything storing large quantities of insets. Mathed e.g. would
86 // suffer.
87
88 class Inset {
89 public:
90         ///
91         enum EntryDirection {
92                 ENTRY_DIRECTION_IGNORE,
93                 ENTRY_DIRECTION_RIGHT,
94                 ENTRY_DIRECTION_LEFT
95         };
96         ///
97         typedef ptrdiff_t  difference_type;
98         /// short of anything else reasonable
99         typedef size_t     size_type;
100         /// type for cell indices
101         typedef size_t     idx_type;
102         /// type for cursor positions
103         typedef ptrdiff_t  pos_type;
104         /// type for row numbers
105         typedef size_t     row_type;
106         /// type for column numbers
107         typedef size_t     col_type;
108
109         /// virtual base class destructor
110         virtual ~Inset() {}
111
112         /// change associated Buffer
113         virtual void setBuffer(Buffer & buffer);
114         /// reset associated Buffer to null value
115         virtual void resetBuffer();
116         /// retrieve associated Buffer
117         Buffer & buffer();
118         Buffer const & buffer() const;
119         /// Returns true if buffer_ actually points to a Buffer that has
120         /// been loaded into LyX and is still open. Note that this will
121         /// always return false for cloned Buffers. If you want to allow
122         /// for the case of cloned Buffers, use isBufferValid().
123         bool isBufferLoaded() const;
124         /// Returns true if this is a loaded buffer or a cloned buffer.
125         bool isBufferValid() const;
126
127         /// initialize view for this inset.
128         /**
129           * This is typically used after this inset is created interactively.
130           * Intented purpose is to sanitize internal state with regard to current
131           * Buffer.
132           **/
133         virtual void initView() {}
134         /// \return true if this inset is labeled.
135         virtual bool isLabeled() const { return false; }
136
137         /// identification as math inset
138         virtual InsetMath * asInsetMath() { return 0; }
139         /// identification as math inset
140         virtual InsetMath const * asInsetMath() const { return 0; }
141         /// true for 'math' math inset, but not for e.g. mbox
142         virtual bool inMathed() const { return false; }
143         /// is this inset based on the InsetText class?
144         virtual InsetText * asInsetText() { return 0; }
145         /// is this inset based on the InsetText class?
146         virtual InsetText const * asInsetText() const { return 0; }
147         /// is this inset based on the InsetCollapsible class?
148         virtual InsetCollapsible * asInsetCollapsible() { return 0; }
149         /// is this inset based on the InsetCollapsible class?
150         virtual InsetCollapsible const * asInsetCollapsible() const { return 0; }
151         /// is this inset based on the InsetTabular class?
152         virtual InsetTabular * asInsetTabular() { return 0; }
153         /// is this inset based on the InsetTabular class?
154         virtual InsetTabular const * asInsetTabular() const { return 0; }
155         /// is this inset based on the InsetCommand class?
156         virtual InsetCommand * asInsetCommand() { return 0; }
157         /// is this inset based on the InsetCommand class?
158         virtual InsetCommand const * asInsetCommand() const { return 0; }
159         /// is this inset based on the InsetArgument class?
160         virtual InsetArgument const * asInsetArgument() const { return nullptr; }
161
162         /// the real dispatcher
163         void dispatch(Cursor & cur, FuncRequest & cmd);
164         /**
165          * \returns true if this function made a definitive decision on
166          * whether the inset wants to handle the request \p cmd or not.
167          * The result of this decision is put into \p status.
168          *
169          * Every request that is enabled in this method needs to be handled
170          * in doDispatch(). Normally we have a 1:1 relationship between the
171          * requests handled in getStatus() and doDispatch(), but there are
172          * some exceptions:
173          * - A request that is disabled in getStatus() does not need to
174          *   appear in doDispatch(). It is guaranteed that doDispatch()
175          *   is never called with this request.
176          * - A few requests are en- or disabled in Inset::getStatus().
177          *   These need to be handled in the doDispatch() methods of the
178          *   derived insets, since Inset::doDispatch() has not enough
179          *   information to handle them.
180          * - LFUN_MOUSE_* need not to be handled in getStatus(), because these
181          *   are dispatched directly
182          */
183         virtual bool getStatus(Cursor & cur, FuncRequest const & cmd,
184                 FuncStatus & status) const;
185
186         /// cursor enters
187         virtual void edit(Cursor & cur, bool front,
188                 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
189         /// sets cursor recursively descending into nested editable insets
190         /**
191         \return the inset pointer if x,y is covering that inset
192         \param x,y are absolute screen coordinates.
193         */
194         /// Note: this method must preserve the selection status. See:
195         /// https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg199001.html
196         virtual Inset * editXY(Cursor & cur, int x, int y);
197
198         /// compute the size of the object returned in dim
199         virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
200         /// draw inset and update (xo, yo)-cache
201         virtual void draw(PainterInfo & pi, int x, int y) const = 0;
202         /// draw inset selection if necessary
203         virtual void drawSelection(PainterInfo &, int, int) const {}
204         /// draw inset background if the inset has an own background and a
205         /// selection is drawn by drawSelection.
206         virtual void drawBackground(PainterInfo &, int, int) const;
207         ///
208         virtual bool editing(BufferView const * bv) const;
209         ///
210         virtual bool showInsetDialog(BufferView *) const;
211
212         /// draw two angular markers
213         virtual void drawMarkers(PainterInfo & pi, int x, int y) const;
214         /// add space for markers
215         void metricsMarkers(Dimension & dim, int framesize = 1) const;
216         /// add space for markers
217         void metricsMarkers2(Dimension & dim, int framesize = 1) const;
218         /// draw inset decoration if necessary.
219         /// This can use \c drawMarkers() for example.
220         virtual void drawDecoration(PainterInfo &, int, int) const {}
221
222         /// last metrics computed for the inset
223         Dimension const dimension(BufferView const &) const;
224         /// last drawn position for 'important' insets
225         int xo(BufferView const & bv) const;
226         /// last drawn position for 'important' insets
227         int yo(BufferView const & bv) const;
228         /// do we cover screen position x/y?
229         bool covers(BufferView const & bv, int x, int y) const;
230         /// get the screen positions of the cursor (see note in Cursor.cpp)
231         virtual void cursorPos(BufferView const & bv,
232                 CursorSlice const & sl, bool boundary, int & x, int & y) const;
233
234         /// Allow multiple blanks
235         virtual bool isFreeSpacing() const;
236         /// Don't eliminate empty paragraphs
237         virtual bool allowEmpty() const;
238         /// Force inset into LTR environment if surroundings are RTL
239         virtual bool forceLTR() const;
240         /// whether to include this inset in the strings generated for the TOC
241         virtual bool isInToc() const;
242
243         /// Where should we go when we press the up or down cursor key?
244         virtual bool idxUpDown(Cursor & cur, bool up) const;
245         /// Move one cell backwards
246         virtual bool idxBackward(Cursor &) const { return false; }
247         /// Move one cell forward
248         virtual bool idxForward(Cursor &) const { return false; }
249
250         /// Move to the next cell
251         virtual bool idxNext(Cursor &) const { return false; }
252         /// Move to the previous cell
253         virtual bool idxPrev(Cursor &) const { return false; }
254
255         /// Target pos when we enter the inset while moving forward
256         virtual bool idxFirst(Cursor &) const { return false; }
257         /// Target pos when we enter the inset while moving backwards
258         virtual bool idxLast(Cursor &) const { return false; }
259
260         /// Delete a cell and move cursor
261         virtual bool idxDelete(idx_type &) { return false; }
262         /// pulls cell after pressing erase
263         virtual void idxGlue(idx_type) {}
264         /// returns list of cell indices that are "between" from and to for
265         /// selection purposes
266         virtual bool idxBetween(idx_type idx, idx_type from, idx_type to) const;
267
268         /// to which column belongs a cell with a given index?
269         virtual col_type col(idx_type) const { return 0; }
270         /// to which row belongs a cell with a given index?
271         virtual row_type row(idx_type) const { return 0; }
272         /// cell index corresponding to row and column;
273         virtual idx_type index(row_type row, col_type col) const;
274         /// number of embedded cells
275         virtual size_t nargs() const { return 0; }
276         /// number of rows in gridlike structures
277         virtual size_t nrows() const { return 0; }
278         /// number of columns in gridlike structures
279         virtual size_t ncols() const { return 0; }
280         /// Is called when the cursor leaves this inset.
281         /// Returns true if cursor is now invalid, e.g. if former
282         /// insets in higher cursor slices of \c old do not exist
283         /// anymore.
284         /// \c old is the old cursor, the last slice points to this.
285         /// \c cur is the new cursor. Use the update flags to cause a redraw.
286         virtual bool notifyCursorLeaves(Cursor const & /*old*/, Cursor & /*cur*/)
287                 { return false; }
288         /// Is called when the cursor enters this inset.
289         /// Returns true if cursor is now invalid, e.g. if former
290         /// insets in higher cursor slices of \c old do not exist
291         /// anymore.
292         /// \c cur is the new cursor, some slice points to this. Use the update
293         /// flags to cause a redraw.
294         virtual bool notifyCursorEnters(Cursor & /*cur*/)
295                 { return false; }
296         /// is called when the mouse enters or leaves this inset
297         /// return true if this inset needs a repaint
298         virtual bool setMouseHover(BufferView const *, bool) const
299                 { return false; }
300         /// return true if this inset is hovered (under mouse)
301         /// This is by now only used by mathed to draw corners
302         /// (Inset::drawMarkers() and Inset::drawMarkers2()).
303         /// Other insets do not have to redefine this function to
304         /// return the correct status of mouseHovered.
305         virtual bool mouseHovered(BufferView const *) const { return false; }
306
307         /// request "external features"
308         virtual void validate(LaTeXFeatures &) const {}
309
310         /// Validate LFUN_INSET_MODIFY argument.
311         virtual bool validateModifyArgument(docstring const &) const { return true; }
312
313         /// describe content if cursor inside
314         virtual void infoize(odocstream &) const {}
315         /// describe content if cursor behind
316         virtual void infoize2(odocstream &) const {}
317
318         enum { PLAINTEXT_NEWLINE = 10000 };
319
320         /// plain text output in ucs4 encoding
321         /// return the number of characters; in case of multiple lines of
322         /// output, add PLAINTEXT_NEWLINE to the number of chars in the last line
323         virtual int plaintext(odocstringstream &, OutputParams const &,
324                               size_t max_length = INT_MAX) const = 0;
325         /// docbook output
326         virtual int docbook(odocstream & os, OutputParams const &) const;
327         /// XHTML output
328         /// the inset is expected to write XHTML to the XHTMLStream
329         /// \return any "deferred" material that should be written outside the
330         /// normal stream, and which will in fact be written after the current
331         /// paragraph closes. this is appropriate e.g. for floats.
332         virtual docstring xhtml(XHTMLStream & xs, OutputParams const &) const;
333
334         /// Writes a string representation of the inset to the odocstream.
335         /// This one should be called when you want the whole contents of
336         /// the inset.
337         virtual void toString(odocstream &) const {}
338         /// Appends a potentially abbreviated version of the inset to
339         /// \param str. Intended for use by the TOC.
340         virtual void forOutliner(docstring & str,
341                                                          size_t const maxlen = TOC_ENTRY_LENGTH,
342                                                          bool const shorten = true) const;
343
344         /// Can a cursor be put in there ?
345         /// Forced to false for insets that have hidden contents, like
346         /// InsetMathCommand and InsetInfo.
347         virtual bool isActive() const { return nargs() > 0; }
348         /// can the contents of the inset be edited on screen ?
349         // equivalent to isActive except for closed InsetCollapsible
350         virtual bool editable() const;
351         /// has the Inset settings that can be modified in a dialog ?
352         virtual bool hasSettings() const;
353         /// can we go further down on mouse click?
354         /// true for InsetCaption, InsetCollapsibles (not ButtonOnly), InsetTabular
355         virtual bool descendable(BufferView const &) const { return false; }
356         /// can we click at the specified position ?
357         virtual bool clickable(BufferView const &, int, int) const { return false; }
358         /// Move one cell backwards
359         virtual bool allowsCaptionVariation(std::string const &) const { return false; }
360         // true for insets that have a table structure (InsetMathGrid, InsetTabular)
361         virtual bool isTable() const { return false; }
362
363         /// does this contain text that can be change track marked in DVI?
364         virtual bool canTrackChanges() const { return false; }
365         /// Will this inset paint its own change tracking status (in the parent
366         /// paragraph) or will it let RowPainter handle it?
367         virtual bool canPaintChange(BufferView const &) const { return false; }
368         /// return true if the inset should be removed automatically
369         virtual bool autoDelete() const;
370
371         /// Returns true if the inset supports completions.
372         virtual bool completionSupported(Cursor const &) const { return false; }
373         /// Returns true if the inset supports inline completions at the
374         /// cursor position. In this case the completion might be stored
375         /// in the BufferView's inlineCompletion property.
376         virtual bool inlineCompletionSupported(Cursor const & /*cur*/) const
377                 { return false; }
378         /// Return true if the inline completion should be automatic.
379         virtual bool automaticInlineCompletion() const { return true; }
380         /// Return true if the popup completion should be automatic.
381         virtual bool automaticPopupCompletion() const { return true; }
382         /// Return true if the cursor should indicate a completion.
383         virtual bool showCompletionCursor() const { return true; }
384         /// Returns completion suggestions at cursor position. Return an
385         /// null pointer if no completion is a available or possible.
386         /// The caller is responsible to free the returned object!
387         virtual CompletionList const * createCompletionList(Cursor const &) const
388                 { return 0; }
389         /// Returns the completion prefix to filter the suggestions for completion.
390         /// This is only called if completionList returned a non-null list.
391         virtual docstring completionPrefix(Cursor const &) const;
392         /// Do a completion at the cursor position. Return true on success.
393         /// The completion does not contain the prefix. If finished is true, the
394         /// completion is final. If finished is false, completion might only be
395         /// a partial completion.
396         virtual bool insertCompletion(Cursor & /*cur*/,
397                 docstring const & /*completion*/, bool /*finished*/)
398                 { return false; }
399         /// Get the completion inset position and size
400         virtual void completionPosAndDim(Cursor const &, int & /*x*/, int & /*y*/,
401                 Dimension & /*dim*/) const {}
402
403         /// returns true if the inset can hold an inset of given type
404         virtual bool insetAllowed(InsetCode) const { return false; }
405         /// should this inset use the empty layout by default rather than
406         /// the standard layout? (default: only if that is forced.)
407         virtual bool usePlainLayout() const { return forcePlainLayout(); }
408         /// if this inset has paragraphs should they be forced to use the
409         /// empty layout?
410         virtual bool forcePlainLayout(idx_type = 0) const { return false; }
411         /// if this inset has paragraphs should the user be allowed to
412         /// customize alignment, etc?
413         virtual bool allowParagraphCustomization(idx_type = 0) const
414                 { return true; }
415         /// Is the width forced to some value?
416         virtual bool hasFixedWidth() const { return false; }
417         /// if this inset has paragraphs should they be forced to use a
418         /// local font language switch?
419         virtual bool forceLocalFontSwitch() const { return false; }
420
421         /// Is the content of this inset part of the output document?
422         virtual bool producesOutput() const { return true; }
423         /// Is the content of this inset part of the immediate (visible) text sequence?
424         virtual bool isPartOfTextSequence() const { return producesOutput(); }
425
426         /// \return Tool tip for this inset.
427         /// This default implementation returns an empty string. This can be
428         /// either plain text or Qt html, and formatToolTip will be called
429         /// on it before display in both cases.
430         virtual docstring toolTip(BufferView const & bv, int x, int y) const;
431
432         /// \return Context menu identifier. This function determines
433         /// whose Inset's menu should be shown for the given position.
434         virtual std::string contextMenu(BufferView const & bv, int x, int y) const;
435
436         /// \return Context menu identifier for this inset.
437         /// This default implementation returns an empty string.
438         virtual std::string contextMenuName() const;
439
440
441         virtual docstring layoutName() const;
442         ///
443         virtual InsetLayout const & getLayout() const;
444         ///
445         virtual bool isPassThru() const { return getLayout().isPassThru(); }
446         /// Is this inset's layout defined in the document's textclass?
447         bool undefined() const;
448         /// should this inset be handled like a normal character?
449         /// (a character can be a letter or punctuation)
450         virtual bool isChar() const { return false; }
451         /// is this equivalent to a letter?
452         /// (a letter is a character that is considered part of a word)
453         virtual bool isLetter() const { return false; }
454         /// is this equivalent to a space (which is BTW different from
455         /// a line separator)?
456         virtual bool isSpace() const { return false; }
457         /// does this inset try to use all available space (like \\hfill does)?
458         virtual bool isHfill() const { return false; }
459
460         enum DisplayType {
461                 Inline = 0,
462                 AlignLeft,
463                 AlignCenter,
464                 AlignRight
465         };
466
467         /// should we have a non-filled line before this inset?
468         virtual DisplayType display() const { return Inline; }
469         /// indentation before this inset (only needed for displayed hull insets with fleqn option)
470         virtual int indent(BufferView const &) const { return 0; }
471         ///
472         virtual LyXAlignment contentAlignment() const { return LYX_ALIGN_NONE; }
473         /// should we break lines after this inset?
474         virtual bool isLineSeparator() const { return false; }
475         /// should paragraph indendation be omitted in any case?
476         virtual bool neverIndent() const { return false; }
477         /// dumps content to lyxerr
478         virtual void dump() const;
479         /// write inset in .lyx format
480         virtual void write(std::ostream &) const {}
481         /// read inset in .lyx format
482         virtual void read(Lexer &) {}
483         /** Export the inset to LaTeX.
484          *  Don't use a temporary stringstream if the final output is
485          *  supposed to go to a file.
486          *  \sa Buffer::writeLaTeXSource for the reason.
487          */
488         virtual void latex(otexstream &, OutputParams const &) const {}
489         /// returns true to override begin and end inset in file
490         virtual bool directWrite() const;
491         ///
492         virtual bool allowSpellCheck() const { return false; }
493
494         /// if this insets owns text cells (e.g. InsetText) return cell num
495         virtual Text * getText(int /*num*/) const { return 0; }
496
497         /** Adds a LaTeX snippet to the Preview Loader for transformation
498          *  into a bitmap image. Does not start the laoding process.
499          *
500          *  Most insets have no interest in this capability, so the method
501          *  defaults to empty.
502          */
503         virtual void addPreview(DocIterator const &,
504                 graphics::PreviewLoader &) const {}
505
506         /** Classifies the unicode characters appearing in a math inset
507          *  depending on whether they are to be translated as latex
508          *  math/text commands or used as math symbols without translation.
509          *
510          *  Only math insets have interest in this classification, so the
511          *  method defaults to empty.
512          */
513         virtual void initUnicodeMath() const {}
514
515         /// Add an entry to the TocList
516         /// Pass a DocIterator that points at the paragraph containing
517         /// the inset
518         ///
519         /// \param output_active : is the inset active or is it in an inactive
520         /// branch or a note?
521         ///
522         /// \param utype : is the toc being generated for use by the output
523         /// routines?
524         ///
525         /// \param tocbackend : where to add the toc information.
526         virtual void addToToc(DocIterator const & /* di */,
527                                                   bool /* output_active */,
528                               UpdateType /* utype*/,
529                               TocBackend & /* tocbackend */) const {}
530         /// Collect BibTeX information
531         virtual void collectBibKeys(InsetIterator const &, support::FileNameList &) const {}
532         /// Update the counters of this inset and of its contents.
533         /// The boolean indicates whether we are preparing for output, e.g.,
534         /// of XHTML.
535         virtual void updateBuffer(ParIterator const &, UpdateType) {}
536
537         /// Updates the inset's dialog
538         virtual Buffer const * updateFrontend() const;
539
540 public:
541         /// returns LyX code associated with the inset. Used for TOC, ...)
542         virtual InsetCode lyxCode() const { return NO_CODE; }
543
544         ///
545         enum mode_type {UNDECIDED_MODE, TEXT_MODE, MATH_MODE};
546         /// return text or mathmode if that is possible to determine
547         virtual mode_type currentMode() const { return UNDECIDED_MODE; }
548         /// returns whether changing mode during latex export is forbidden
549         virtual bool lockedMode() const { return false; }
550         /// returns whether only ascii chars are allowed during latex export
551         virtual bool asciiOnly() const { return false; }
552         /// returns whether this inset is allowed in other insets of given mode
553         virtual bool allowedIn(mode_type) const { return true; }
554         /**
555          * The font is inherited from the parent for LaTeX export if this
556          * method returns true. No open font changes are closed in front of
557          * the inset for LaTeX export, and the font is inherited for all other
558          * exports as well as on screen.
559          * If this method returns false all open font changes are closed in
560          * front of the inset for LaTeX export. The default font is used
561          * inside the inset for all exports and on screen.
562          */
563         virtual bool inheritFont() const { return true; }
564         /**
565          * If this method returns true all explicitly set font attributes
566          * are reset during editing operations.
567          * For copy/paste operations the language is never changed, since
568          * the language of a given text never changes if the text is
569          * formatted differently, while other font attribues like size may
570          * need to change if the text is copied from one environment to
571          * another one.
572          * If this method returns false no font attribute is reset.
573          * The default implementation returns true if the resetFont layout
574          * tag is set and otherwise the negation of inheritFont(),
575          * since inherited inset font attributes do not need to be changed,
576          * and non-inherited ones need to be set explicitly.
577          */
578         virtual bool resetFontEdit() const;
579
580         /// set the change for the entire inset
581         virtual void setChange(Change const &) {}
582         /// accept the changes within the inset
583         virtual void acceptChanges() {}
584         /// reject the changes within the inset
585         virtual void rejectChanges() {}
586
587         ///
588         virtual ColorCode backgroundColor(PainterInfo const &) const;
589         ///
590         virtual ColorCode labelColor() const;
591         //
592         enum { TEXT_TO_INSET_OFFSET = 4 };
593
594         /// Determine the action of backspace and delete: do we select instead of
595         /// deleting if not already selected?
596         virtual bool confirmDeletion() const { return false; }
597
598 protected:
599         /// Constructors
600         Inset(Buffer * buf) : buffer_(buf) {}
601         Inset(Inset const &) : buffer_(0) {}
602
603         /// replicate ourselves
604         friend class InsetList;
605         friend class MathAtom;
606         virtual Inset * clone() const = 0;
607
608         /** The real dispatcher.
609          *  Gets normally called from Cursor::dispatch(). Cursor::dispatch()
610          *  assumes the common case of 'LFUN handled, need update'.
611          *  This has to be overriden by calling Cursor::undispatched() or
612          *  Cursor::noScreenUpdate() if appropriate.
613          *  If you need to call the dispatch method of some inset directly
614          *  you may have to explicitly request an update at that place. Don't
615          *  do it in doDispatch(), since that causes nested updates when
616          *  called from Cursor::dispatch(), and these can lead to crashes.
617          *  \sa getStatus
618          */
619         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
620
621         Buffer * buffer_;
622 };
623
624 } // namespace lyx
625
626 #endif