]> git.lyx.org Git - lyx.git/blob - src/mathed/math_nestinset.h
oh well
[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 & st) const;
25         /// appends itself with macro arguments substituted
26         void substitute(MathMacro const & macro);
27         /// identifies NestInsets
28         MathNestInset * asNestInset() { return this; }
29
30         /// order of movement through the cells when pressing the left key
31         bool idxLeft(idx_type & idx, pos_type & pos) const;
32         /// order of movement through the cells when pressing the right key
33         bool idxRight(idx_type & idx, pos_type & pos) const;
34
35         /// move one physical cell up
36         bool idxNext(idx_type & idx, pos_type & pos) const;
37         /// move one physical cell down
38         bool idxPrev(idx_type & idx, pos_type & pos) const;
39
40         /// target pos when we enter the inset from the left by pressing "Right"
41         bool idxFirst(idx_type & idx, pos_type & pos) const;
42         /// target pos when we enter the inset from the right by pressing "Left"
43         bool idxLast(idx_type & idx, pos_type & pos) const;
44
45         /// where should we go if we press home?
46         bool idxHome(idx_type & idx, pos_type & pos) const;
47         /// where should we go if we press end?
48         bool idxEnd(idx_type & idx, pos_type & pos) const;
49
50         /// number of cells currently governed by us
51         idx_type nargs() const;
52
53         /// direct access to the cell
54         MathArray & cell(idx_type);
55         /// direct access to the cell
56         MathArray const & cell(idx_type) const;
57         /// direct access to the cell including the drawing cache
58         MathXArray & xcell(idx_type);
59         /// direct access to the cell including the drawing cache
60         MathXArray const & xcell(idx_type) const;
61
62         /// can we move into this cell (see macroarg.h)
63         bool isActive() const { return nargs() > 0; }
64         /// request "external features"
65         void validate(LaTeXFeatures & features) const;
66
67         /// match in all cells
68         bool match(MathInset *) const;
69         /// replace in all cells
70         void replace(ReplaceData &);
71         /// do we contain a given pattern?
72         bool contains(MathArray const &);
73
74         /// debug helper
75         void dump() const;
76         ///
77         virtual bool editing() const;
78
79 protected:
80         /// we store the cells in a vector
81         typedef std::vector<MathXArray> cells_type;
82         /// thusly:
83         cells_type cells_;
84 };
85
86 #endif