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