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