]> git.lyx.org Git - lyx.git/blob - src/mathed/math_nestinset.h
bug + spped fixes + small stuff
[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         /// appends itself with macro arguments substituted
36         void substitute(MathMacro const & macro);
37         /// identifies NestInsets
38         MathNestInset * asNestInset() { return this; }
39         /// identifies NestInsets
40         MathNestInset const * asNestInset() const { return this; }
41         /// get cursor position
42         void getCursorPos(CursorSlice const & cur, int & x, int & y) const;
43         ///
44         void edit(LCursor & cur, bool left);
45         ///
46         void edit(LCursor & cur, int x, int y);
47
48         /// order of movement through the cells when pressing the left key
49         bool idxLeft(LCursor &) const;
50         /// order of movement through the cells when pressing the right key
51         bool idxRight(LCursor &) const;
52
53         /// move one physical cell up
54         bool idxNext(LCursor &) const;
55         /// move one physical cell down
56         bool idxPrev(LCursor &) const;
57
58         /// target pos when we enter the inset from the left by pressing "Right"
59         bool idxFirst(LCursor &) const;
60         /// target pos when we enter the inset from the right by pressing "Left"
61         bool idxLast(LCursor &) const;
62
63         /// where should we go if we press home?
64         bool idxHome(LCursor &) const;
65         /// where should we go if we press end?
66         bool idxEnd(LCursor &) const;
67
68         /// number of cells currently governed by us
69         idx_type nargs() const;
70         /// access to the lock
71         bool lock() const;
72         /// access to the lock
73         void lock(bool);
74         /// get notification when the cursor leaves this inset
75         void notifyCursorLeaves(idx_type);
76
77         /// direct access to the cell
78         MathArray & cell(idx_type);
79         /// direct access to the cell
80         MathArray const & cell(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         /// replace in all cells
88         void replace(ReplaceData &);
89         /// do we contain a given pattern?
90         bool contains(MathArray const &) const;
91         /// glue everything to a single cell
92         MathArray glue() const;
93
94         /// debug helper
95         void dump() const;
96
97         /// writes \\, name(), and args in braces and '\\lyxlock' if necessary
98         void write(WriteStream & os) const;
99         /// writes [, name(), and args in []
100         void normalize(NormalStream & os) const;
101
102 protected:
103         ///
104         DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
105         ///
106         void handleFont(LCursor & cur,
107                 std::string const & arg, std::string const & font);
108         ///
109         void handleFont2(LCursor & cur, std::string const & arg);
110
111
112 private:
113         /// lfun handler
114         DispatchResult lfunMousePress(LCursor &, FuncRequest const &);
115         ///
116         DispatchResult lfunMouseRelease(LCursor &, FuncRequest const &);
117         ///
118         DispatchResult lfunMouseMotion(LCursor &, FuncRequest const &);
119
120 protected:
121         /// we store the cells in a vector
122         typedef std::vector<MathArray> cells_type;
123         /// thusly:
124         cells_type cells_;
125         /// if the inset is locked, it can't be entered with the cursor
126         bool lock_;
127 };
128
129 #endif