]> git.lyx.org Git - lyx.git/blob - src/mathed/math_nestinset.h
more IU
[lyx.git] / src / mathed / math_nestinset.h
1 // -*- C++ -*-
2 /**
3  * \file math_nestinset.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef MATH_NESTINSET_H
13 #define MATH_NESTINSET_H
14
15 #include "math_diminset.h"
16
17
18 /** Abstract base class for all math objects that contain nested items.
19     This is basically everything that is not a single character or a
20     single symbol.
21 */
22
23 class MathNestInset : public MathDimInset {
24 public:
25         /// nestinsets have a fixed size to start with
26         explicit MathNestInset(idx_type ncells);
27
28         /// the size is usuall some sort of convex hull of the cells
29         /// hides inset::metrics() intentionally!
30         void metrics(MetricsInfo const & mi) const;
31         /// draw background if locked
32         void draw(PainterInfo & pi, int x, int y) const;
33         /// draw selection background
34         void drawSelection(PainterInfo & pi,
35                 idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
36         /// appends itself with macro arguments substituted
37         void substitute(MathMacro const & macro);
38         /// identifies NestInsets
39         MathNestInset * asNestInset() { return this; }
40         /// identifies NestInsets
41         MathNestInset const * asNestInset() const { return this; }
42         /// get cursor position
43         void getPos(idx_type idx, pos_type pos, int & x, int & y) const;
44
45         /// order of movement through the cells when pressing the left key
46         bool idxLeft(idx_type & idx, pos_type & pos) const;
47         /// order of movement through the cells when pressing the right key
48         bool idxRight(idx_type & idx, pos_type & pos) const;
49
50         /// move one physical cell up
51         bool idxNext(idx_type & idx, pos_type & pos) const;
52         /// move one physical cell down
53         bool idxPrev(idx_type & idx, pos_type & pos) const;
54
55         /// target pos when we enter the inset from the left by pressing "Right"
56         bool idxFirst(idx_type & idx, pos_type & pos) const;
57         /// target pos when we enter the inset from the right by pressing "Left"
58         bool idxLast(idx_type & idx, pos_type & pos) const;
59
60         /// where should we go if we press home?
61         bool idxHome(idx_type & idx, pos_type & pos) const;
62         /// where should we go if we press end?
63         bool idxEnd(idx_type & idx, pos_type & pos) const;
64
65         /// number of cells currently governed by us
66         idx_type nargs() const;
67         /// access to the lock
68         bool lock() const;
69         /// access to the lock
70         void lock(bool);
71         /// get notification when the cursor leaves this inset
72         void notifyCursorLeaves(idx_type);
73
74         /// direct access to the cell
75         MathArray & cell(idx_type);
76         /// direct access to the cell
77         MathArray const & cell(idx_type) const;
78
79         /// can we move into this cell (see macroarg.h)
80         bool isActive() const;
81         /// request "external features"
82         void validate(LaTeXFeatures & features) const;
83
84         /// replace in all cells
85         void replace(ReplaceData &);
86         /// do we contain a given pattern?
87         bool contains(MathArray const &) const;
88         /// glue everything to a single cell
89         MathArray glue() const;
90
91         /// debug helper
92         void dump() const;
93         /// is the cursor currently somewhere within this inset?
94         virtual bool editing() const;
95
96         /// writes \\, name(), and args in braces and '\\lyxlock' if necessary
97         void write(WriteStream & os) const;
98         /// writes [, name(), and args in []
99         void normalize(NormalStream & os) const;
100 protected:
101         ///
102         virtual
103         DispatchResult
104         priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
105
106         /// we store the cells in a vector
107         typedef std::vector<MathArray> cells_type;
108         /// thusly:
109         cells_type cells_;
110         /// if the inset is locked, it can't be entered with the cursor
111         bool lock_;
112
113         /// draw four angular markers
114         void drawMarkers(PainterInfo & pi, int x, int y) const;
115         /// draw two angular markers
116         void drawMarkers2(PainterInfo & pi, int x, int y) const;
117
118         /// add space for markers
119         void metricsMarkers(int frame = 1) const;
120         /// add space for markers
121         void metricsMarkers2(int frame = 1) const;
122 };
123
124 #endif