]> git.lyx.org Git - lyx.git/blob - src/mathed/math_nestinset.h
speed up preview a bit...
[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         /// get notification when the cursor leaves this inset
61         void notifyCursorLeaves();
62
63         /// direct access to the cell
64         MathArray & cell(idx_type);
65         /// direct access to the cell
66         MathArray const & cell(idx_type) const;
67         /// direct access to the cell including the drawing cache
68         MathXArray & xcell(idx_type);
69         /// direct access to the cell including the drawing cache
70         MathXArray const & xcell(idx_type) const;
71
72         /// can we move into this cell (see macroarg.h)
73         bool isActive() const;
74         /// request "external features"
75         void validate(LaTeXFeatures & features) const;
76
77         /// match in all cells
78         bool match(MathInset *) const;
79         /// replace in all cells
80         void replace(ReplaceData &);
81         /// do we contain a given pattern?
82         bool contains(MathArray const &);
83         /// glue everything to a single cell
84         MathArray glue() const;
85
86         /// debug helper
87         void dump() const;
88         /// is the cursor currently somewhere within this inset?
89         virtual bool editing() const;
90
91 protected:
92         /// we store the cells in a vector
93         typedef std::vector<MathXArray> cells_type;
94         /// thusly:
95         cells_type cells_;
96         /// if the inset is locked, it can't be entered with the cursor
97         bool lock_;
98 };
99
100 #endif