1 #ifndef MATH_NESTINSET_H
2 #define MATH_NESTINSET_H
4 #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
13 class MathNestInset : public MathDimInset {
15 /// nestinsets have a fixed size to start with
16 explicit MathNestInset(idx_type ncells);
18 /// the size is usuall some sort of convex hull of the cells
19 /// hides inset::metrics() intentionally!
20 void metrics(MetricsInfo const & mi) const;
21 /// draw background if locked
22 void draw(PainterInfo & pi, int x, int y) const;
23 /// draw selection background
24 void drawSelection(PainterInfo & pi,
25 idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
26 /// appends itself with macro arguments substituted
27 void substitute(MathMacro const & macro);
28 /// identifies NestInsets
29 MathNestInset * asNestInset() { return this; }
30 /// identifies NestInsets
31 MathNestInset const * asNestInset() const { return this; }
32 /// get cursor position
33 void getPos(idx_type idx, pos_type pos, int & x, int & y) const;
35 /// order of movement through the cells when pressing the left key
36 bool idxLeft(idx_type & idx, pos_type & pos) const;
37 /// order of movement through the cells when pressing the right key
38 bool idxRight(idx_type & idx, pos_type & pos) const;
40 /// move one physical cell up
41 bool idxNext(idx_type & idx, pos_type & pos) const;
42 /// move one physical cell down
43 bool idxPrev(idx_type & idx, pos_type & pos) const;
45 /// target pos when we enter the inset from the left by pressing "Right"
46 bool idxFirst(idx_type & idx, pos_type & pos) const;
47 /// target pos when we enter the inset from the right by pressing "Left"
48 bool idxLast(idx_type & idx, pos_type & pos) const;
50 /// where should we go if we press home?
51 bool idxHome(idx_type & idx, pos_type & pos) const;
52 /// where should we go if we press end?
53 bool idxEnd(idx_type & idx, pos_type & pos) const;
55 /// number of cells currently governed by us
56 idx_type nargs() const;
57 /// access to the lock
59 /// access to the lock
61 /// get notification when the cursor leaves this inset
62 void notifyCursorLeaves(idx_type);
64 /// direct access to the cell
65 MathArray & cell(idx_type);
66 /// direct access to the cell
67 MathArray const & cell(idx_type) const;
69 /// can we move into this cell (see macroarg.h)
70 bool isActive() const;
71 /// request "external features"
72 void validate(LaTeXFeatures & features) const;
74 /// match in all cells
75 bool match(MathAtom const &) const;
76 /// replace in all cells
77 void replace(ReplaceData &);
78 /// do we contain a given pattern?
79 bool contains(MathArray const &) const;
80 /// glue everything to a single cell
81 MathArray glue() const;
85 /// is the cursor currently somewhere within this inset?
86 virtual bool editing() const;
88 /// writes \\, name(), and args in braces and '\\lyxlock' if necessary
89 void write(WriteStream & os) const;
90 /// writes [, name(), and args in []
91 void normalize(NormalStream & os) const;
95 dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
98 /// we store the cells in a vector
99 typedef std::vector<MathArray> cells_type;
102 /// if the inset is locked, it can't be entered with the cursor
105 /// draw four angular markers
106 void drawMarkers(PainterInfo & pi, int x, int y) const;
107 /// draw two angular markers
108 void drawMarkers2(PainterInfo & pi, int x, int y) const;
110 /// add space for markers
111 void metricsMarkers(int frame = 1) const;
112 /// add space for markers
113 void metricsMarkers2(int frame = 1) const;