3 * \file math_nestinset.h
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.
12 #ifndef MATH_NESTINSET_H
13 #define MATH_NESTINSET_H
15 #include "math_diminset.h"
20 /** Abstract base class for all math objects that contain nested items.
21 This is basically everything that is not a single character or a
25 class MathNestInset : public MathDimInset {
27 /// nestinsets have a fixed size to start with
28 explicit MathNestInset(idx_type ncells);
30 /// the size is usuall some sort of convex hull of the cells
31 /// hides inset::metrics() intentionally!
32 void metrics(MetricsInfo const & mi) const;
33 /// draw background if locked
34 void draw(PainterInfo & pi, int x, int y) const;
35 /// draw selection background
36 void drawSelection(PainterInfo & pi,
37 idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
38 /// appends itself with macro arguments substituted
39 void substitute(MathMacro const & macro);
40 /// identifies NestInsets
41 MathNestInset * asNestInset() { return this; }
42 /// identifies NestInsets
43 MathNestInset const * asNestInset() const { return this; }
44 /// get cursor position
45 void getPos(idx_type idx, pos_type pos, int & x, int & y) const;
47 /// order of movement through the cells when pressing the left key
48 bool idxLeft(idx_type & idx, pos_type & pos) const;
49 /// order of movement through the cells when pressing the right key
50 bool idxRight(idx_type & idx, pos_type & pos) const;
52 /// move one physical cell up
53 bool idxNext(idx_type & idx, pos_type & pos) const;
54 /// move one physical cell down
55 bool idxPrev(idx_type & idx, pos_type & pos) const;
57 /// target pos when we enter the inset from the left by pressing "Right"
58 bool idxFirst(idx_type & idx, pos_type & pos) const;
59 /// target pos when we enter the inset from the right by pressing "Left"
60 bool idxLast(idx_type & idx, pos_type & pos) const;
62 /// where should we go if we press home?
63 bool idxHome(idx_type & idx, pos_type & pos) const;
64 /// where should we go if we press end?
65 bool idxEnd(idx_type & idx, pos_type & pos) const;
67 /// number of cells currently governed by us
68 idx_type nargs() const;
69 /// access to the lock
71 /// access to the lock
73 /// get notification when the cursor leaves this inset
74 void notifyCursorLeaves(idx_type);
76 /// direct access to the cell
77 MathArray & cell(idx_type);
78 /// direct access to the cell
79 MathArray const & cell(idx_type) const;
81 /// can we move into this cell (see macroarg.h)
82 bool isActive() const;
83 /// request "external features"
84 void validate(LaTeXFeatures & features) const;
86 /// match in all cells
87 bool match(MathAtom const &) const;
88 /// replace in all cells
89 void replace(ReplaceData &);
90 /// do we contain a given pattern?
91 bool contains(MathArray const &) const;
92 /// glue everything to a single cell
93 MathArray glue() const;
97 /// is the cursor currently somewhere within this inset?
98 virtual bool editing() const;
100 /// writes \\, name(), and args in braces and '\\lyxlock' if necessary
101 void write(WriteStream & os) const;
102 /// writes [, name(), and args in []
103 void normalize(NormalStream & os) const;
108 priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
110 /// we store the cells in a vector
111 typedef std::vector<MathArray> cells_type;
114 /// if the inset is locked, it can't be entered with the cursor
117 /// draw four angular markers
118 void drawMarkers(PainterInfo & pi, int x, int y) const;
119 /// draw two angular markers
120 void drawMarkers2(PainterInfo & pi, int x, int y) const;
122 /// add space for markers
123 void metricsMarkers(int frame = 1) const;
124 /// add space for markers
125 void metricsMarkers2(int frame = 1) const;