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