1 #ifndef MATH_NESTINSET_H
2 #define MATH_NESTINSET_H
5 #include "math_diminset.h"
7 /** Abstract base class for all math objects that contain nested items.
8 This is basically everything that is not a single character or a
15 class MathNestInset : public MathDimInset {
17 /// nestinsets have a fixed size to start with
18 explicit MathNestInset(idx_type ncells);
20 /// the size is usuall some sort of convex hull of the cells
21 void metrics(MathMetricsInfo const & mi) const;
22 /// add space for markers
23 void metricsMarkers(int frame = 1) const;
24 /// add space for markers
25 void metricsMarkers2(int frame = 1) const;
26 /// draw background if locked
27 void draw(MathPainterInfo & pi, int x, int y) const;
28 /// draw selection background
29 void drawSelection(MathPainterInfo & pi,
30 idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
31 void drawMarkers(MathPainterInfo & pi, int x, int y) const;
32 /// draw four angular markers
33 void drawMarkers2(MathPainterInfo & pi, int x, int y) const;
34 /// appends itself with macro arguments substituted
35 void substitute(MathMacro const & macro);
36 /// identifies NestInsets
37 MathNestInset * asNestInset() { return this; }
38 /// identifies NestInsets
39 MathNestInset const * asNestInset() const { return this; }
40 /// get cursor position
41 void getPos(idx_type idx, pos_type pos, int & x, int & y) const;
43 /// order of movement through the cells when pressing the left key
44 bool idxLeft(idx_type & idx, pos_type & pos) const;
45 /// order of movement through the cells when pressing the right key
46 bool idxRight(idx_type & idx, pos_type & pos) const;
48 /// move one physical cell up
49 bool idxNext(idx_type & idx, pos_type & pos) const;
50 /// move one physical cell down
51 bool idxPrev(idx_type & idx, pos_type & pos) const;
53 /// target pos when we enter the inset from the left by pressing "Right"
54 bool idxFirst(idx_type & idx, pos_type & pos) const;
55 /// target pos when we enter the inset from the right by pressing "Left"
56 bool idxLast(idx_type & idx, pos_type & pos) const;
58 /// where should we go if we press home?
59 bool idxHome(idx_type & idx, pos_type & pos) const;
60 /// where should we go if we press end?
61 bool idxEnd(idx_type & idx, pos_type & pos) const;
63 /// number of cells currently governed by us
64 idx_type nargs() const;
65 /// access to the lock
67 /// access to the lock
69 /// get notification when the cursor leaves this inset
70 void notifyCursorLeaves(idx_type);
72 /// direct access to the cell
73 MathArray & cell(idx_type);
74 /// direct access to the cell
75 MathArray const & cell(idx_type) const;
77 /// can we move into this cell (see macroarg.h)
78 bool isActive() const;
79 /// request "external features"
80 void validate(LaTeXFeatures & features) const;
82 /// match in all cells
83 bool match(MathAtom const &) const;
84 /// replace in all cells
85 void replace(ReplaceData &);
86 /// do we contain a given pattern?
87 bool contains(MathArray const &) const;
88 /// glue everything to a single cell
89 MathArray glue() const;
93 /// is the cursor currently somewhere within this inset?
94 virtual bool editing() const;
96 /// writes \\, name(), and args in braces and '\\lyxlock' if necessary
97 void write(WriteStream & os) const;
98 /// writes [, name(), and args in []
99 void normalize(NormalStream & os) const;
103 dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
106 /// we store the cells in a vector
107 typedef std::vector<MathArray> cells_type;
110 /// if the inset is locked, it can't be entered with the cursor