4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
31 /// Common base class to all insets
35 typedef ptrdiff_t difference_type;
36 /// short of anything else reasonable
37 typedef size_t size_type;
38 /// type for cell indices
39 typedef size_t idx_type;
40 /// type for cursor positions
41 typedef ptrdiff_t pos_type;
42 /// type for row numbers
43 typedef size_t row_type;
44 /// type for column numbers
45 typedef size_t col_type;
47 /// virtual base class destructor
48 virtual ~InsetBase() {}
49 /// replicate ourselves
50 virtual std::auto_ptr<InsetBase> clone() const = 0;
52 /// identification as math inset
53 virtual MathInset * asMathInset() { return 0; }
54 /// identification as non-math inset
55 virtual UpdatableInset * asUpdatableInset() { return 0; }
57 // the real dispatcher
58 DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd);
61 virtual void edit(LCursor & cur, bool left);
63 virtual void edit(LCursor & cur, int x, int y);
65 /// compute the size of the object returned in dim
66 virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
67 /// draw inset and update (xo, yo)-cache
68 virtual void draw(PainterInfo & pi, int x, int y) const = 0;
69 /// last drawn position for 'important' insets
70 virtual int x() const { return 0; }
71 /// last drawn position for 'important' insets
72 virtual int y() const { return 0; }
74 /// number of embedded cells
75 virtual size_t nargs() const { return 0; }
76 /// number of rows in gridlike structures
77 virtual size_t nrows() const { return 0; }
78 /// number of columns in gridlike structures
79 virtual size_t ncols() const { return 0; }
81 /// request "external features"
82 virtual void validate(LaTeXFeatures &) const {}
83 /// Appends \c list with all labels found within this inset.
84 virtual void getLabelList(Buffer const &,
85 std::vector<std::string> & /* list */) const {}
86 /// describe content if cursor inside
87 virtual void infoize(std::ostream &) const {}
88 /// describe content if cursor behind
89 virtual void infoize2(std::ostream &) const {}
91 // the real dispatcher
93 DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
95 /** This is not quite the correct place for this enum. I think
96 the correct would be to let each subclass of Inset declare
97 its own enum code. Actually the notion of an InsetOld::Code
98 should be avoided, but I am not sure how this could be done
104 TOC_CODE, // do these insets really need a code? (ale)
164 MATHMACRO_CODE, // 30
196 /// returns LyX code associated with the inset. Used for TOC, ...)
197 virtual InsetBase::Code lyxCode() const { return NO_CODE; }