]> git.lyx.org Git - lyx.git/blob - src/mathed/math_nestinset.h
most of the so far unapplied stuff from porto including proper support for
[lyx.git] / src / mathed / math_nestinset.h
1 #ifndef MATH_NESTINSET_H
2 #define MATH_NESTINSET_H
3
4 #ifdef __GNUG__
5 #pragma interface
6 #endif
7
8 #include "math_diminset.h"
9
10 /** Abstract base class for all math objects that contain nested items.
11     This is basically everything that is not a single character or a
12     single symbol.
13 */
14
15
16 class LaTeXFeatures;
17
18 class MathNestInset : public MathDimInset {
19 public:
20         /// nestinsets have a fixed size to start with
21         explicit MathNestInset(idx_type ncells);
22
23         /// the size is usuall some sort of convex hull of the cells
24         void metrics(MathMetricsInfo const & mi) const;
25         /// draw background if locked
26         void draw(MathPainterInfo & pi, int x, int y) const;
27         /// draw angular markers
28         void drawMarkers(MathPainterInfo & pi, int x, int y) const;
29         /// appends itself with macro arguments substituted
30         void substitute(MathMacro const & macro);
31         /// identifies NestInsets
32         MathNestInset * asNestInset() { return this; }
33
34         /// order of movement through the cells when pressing the left key
35         bool idxLeft(idx_type & idx, pos_type & pos) const;
36         /// order of movement through the cells when pressing the right key
37         bool idxRight(idx_type & idx, pos_type & pos) const;
38
39         /// move one physical cell up
40         bool idxNext(idx_type & idx, pos_type & pos) const;
41         /// move one physical cell down
42         bool idxPrev(idx_type & idx, pos_type & pos) const;
43
44         /// target pos when we enter the inset from the left by pressing "Right"
45         bool idxFirst(idx_type & idx, pos_type & pos) const;
46         /// target pos when we enter the inset from the right by pressing "Left"
47         bool idxLast(idx_type & idx, pos_type & pos) const;
48
49         /// where should we go if we press home?
50         bool idxHome(idx_type & idx, pos_type & pos) const;
51         /// where should we go if we press end?
52         bool idxEnd(idx_type & idx, pos_type & pos) const;
53
54         /// number of cells currently governed by us
55         idx_type nargs() const;
56         /// access to the lock
57         bool lock() const;
58         /// access to the lock
59         void lock(bool);
60
61         /// direct access to the cell
62         MathArray & cell(idx_type);
63         /// direct access to the cell
64         MathArray const & cell(idx_type) const;
65         /// direct access to the cell including the drawing cache
66         MathXArray & xcell(idx_type);
67         /// direct access to the cell including the drawing cache
68         MathXArray const & xcell(idx_type) const;
69
70         /// can we move into this cell (see macroarg.h)
71         bool isActive() const;
72         /// request "external features"
73         void validate(LaTeXFeatures & features) const;
74
75         /// match in all cells
76         bool match(MathInset *) const;
77         /// replace in all cells
78         void replace(ReplaceData &);
79         /// do we contain a given pattern?
80         bool contains(MathArray const &);
81         /// glue everything to a single cell
82         MathArray glue() const;
83
84         /// debug helper
85         void dump() const;
86         /// is the cursor currently somewhere within this inset?
87         virtual bool editing() const;
88
89 protected:
90         /// we store the cells in a vector
91         typedef std::vector<MathXArray> cells_type;
92         /// thusly:
93         cells_type cells_;
94         /// if the inset is locked, it can't be entered with the cursor
95         bool lock_;
96 };
97
98 #endif