]> git.lyx.org Git - lyx.git/blob - src/mathed/math_nestinset.h
CoordBranch merge
[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 usually 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, int x, int y) const;
35         /// identifies NestInsets
36         MathNestInset * asNestInset() { return this; }
37         /// identifies NestInsets
38         MathNestInset const * asNestInset() const { return this; }
39         /// get cursor position
40         void getCursorPos(CursorSlice const & sl, int & x, int & y) const;
41         ///
42         void edit(LCursor & cur, bool left);
43         ///
44         InsetBase * editXY(LCursor & cur, int x, int y) const;
45
46         /// order of movement through the cells when pressing the left key
47         bool idxLeft(LCursor &) const;
48         /// order of movement through the cells when pressing the right key
49         bool idxRight(LCursor &) const;
50
51         /// move one physical cell up
52         bool idxNext(LCursor &) const;
53         /// move one physical cell down
54         bool idxPrev(LCursor &) const;
55
56         /// target pos when we enter the inset from the left by pressing "Right"
57         bool idxFirst(LCursor &) const;
58         /// target pos when we enter the inset from the right by pressing "Left"
59         bool idxLast(LCursor &) const;
60
61         /// number of cells currently governed by us
62         idx_type nargs() const;
63         /// access to the lock
64         bool lock() const;
65         /// access to the lock
66         void lock(bool);
67         /// get notification when the cursor leaves this inset
68         void notifyCursorLeaves(LCursor & cur);
69
70         /// direct access to the cell
71         MathArray & cell(idx_type);
72         /// direct access to the cell
73         MathArray const & cell(idx_type) const;
74
75         /// can we move into this cell (see macroarg.h)
76         bool isActive() const;
77         /// request "external features"
78         void validate(LaTeXFeatures & features) const;
79
80         /// replace in all cells
81         void replace(ReplaceData &);
82         /// do we contain a given pattern?
83         bool contains(MathArray const &) const;
84         /// glue everything to a single cell
85         MathArray glue() const;
86
87         /// debug helper
88         void dump() const;
89
90         /// writes \\, name(), and args in braces and '\\lyxlock' if necessary
91         void write(WriteStream & os) const;
92         /// writes [, name(), and args in []
93         void normalize(NormalStream & os) const;
94         ///
95         int latex(Buffer const &, std::ostream & os,
96                         OutputParams const & runparams) const;
97
98 protected:
99         ///
100         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
101         /// do we want to handle this event?
102         bool getStatus(LCursor & cur, FuncRequest const & cmd,
103                 FuncStatus & status) const;
104         ///
105         void handleFont(LCursor & cur,
106                 std::string const & arg, std::string const & font);
107         ///
108         void handleFont2(LCursor & cur, std::string const & arg);
109
110         ///
111         bool interpret(LCursor & cur, char c);
112         ///
113         bool script(LCursor & cur, bool);
114
115
116 private:
117         /// lfun handler
118         void lfunMousePress(LCursor &, FuncRequest &);
119         ///
120         void lfunMouseRelease(LCursor &, FuncRequest &);
121         ///
122         void lfunMouseMotion(LCursor &, FuncRequest &);
123
124 protected:
125         /// we store the cells in a vector
126         typedef std::vector<MathArray> cells_type;
127         /// thusly:
128         cells_type cells_;
129         /// if the inset is locked, it can't be entered with the cursor
130         bool lock_;
131 };
132
133 #endif