]> git.lyx.org Git - lyx.git/blob - src/mathed/math_nestinset.h
split LyXText::rowlist_ into individual Paragraph::rows_ chunks
[lyx.git] / src / mathed / math_nestinset.h
1 #ifndef MATH_NESTINSET_H
2 #define MATH_NESTINSET_H
3
4 #include "math_diminset.h"
5 #include "math_data.h"
6
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
9     single symbol.
10 */
11
12
13 class MathNestInset : public MathDimInset {
14 public:
15         /// nestinsets have a fixed size to start with
16         explicit MathNestInset(idx_type ncells);
17
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;
34
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;
39
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;
44
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;
49
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;
54
55         /// number of cells currently governed by us
56         idx_type nargs() const;
57         /// access to the lock
58         bool lock() const;
59         /// access to the lock
60         void lock(bool);
61         /// get notification when the cursor leaves this inset
62         void notifyCursorLeaves(idx_type);
63
64         /// direct access to the cell
65         MathArray & cell(idx_type);
66         /// direct access to the cell
67         MathArray const & cell(idx_type) const;
68
69         /// can we move into this cell (see macroarg.h)
70         bool isActive() const;
71         /// request "external features"
72         void validate(LaTeXFeatures & features) const;
73
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;
82
83         /// debug helper
84         void dump() const;
85         /// is the cursor currently somewhere within this inset?
86         virtual bool editing() const;
87
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;
92
93         /// local dispatcher
94         dispatch_result
95                 dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
96
97 protected:
98         /// we store the cells in a vector
99         typedef std::vector<MathArray> cells_type;
100         /// thusly:
101         cells_type cells_;
102         /// if the inset is locked, it can't be entered with the cursor
103         bool lock_;
104
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;
109
110         /// add space for markers
111         void metricsMarkers(int frame = 1) const;
112         /// add space for markers
113         void metricsMarkers2(int frame = 1) const;
114
115 };
116
117 #endif