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.
9 * Full author contact details are available in file CREDITS.
12 #ifndef MATH_NESTINSET_H
13 #define MATH_NESTINSET_H
15 #include "math_diminset.h"
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
23 class MathNestInset : public MathDimInset {
25 /// nestinsets have a fixed size to start with
26 explicit MathNestInset(idx_type ncells);
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;
44 void edit(LCursor & cur, int, int);
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;
51 /// move one physical cell up
52 bool idxNext(LCursor &) const;
53 /// move one physical cell down
54 bool idxPrev(LCursor &) const;
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;
61 /// where should we go if we press home?
62 bool idxHome(LCursor &) const;
63 /// where should we go if we press end?
64 bool idxEnd(LCursor &) const;
66 /// number of cells currently governed by us
67 idx_type nargs() const;
68 /// access to the lock
70 /// access to the lock
72 /// get notification when the cursor leaves this inset
73 void notifyCursorLeaves(idx_type);
75 /// direct access to the cell
76 MathArray & cell(idx_type);
77 /// direct access to the cell
78 MathArray const & cell(idx_type) const;
80 /// can we move into this cell (see macroarg.h)
81 bool isActive() const;
82 /// request "external features"
83 void validate(LaTeXFeatures & features) const;
85 /// replace in all cells
86 void replace(ReplaceData &);
87 /// do we contain a given pattern?
88 bool contains(MathArray const &) const;
89 /// glue everything to a single cell
90 MathArray glue() const;
95 /// writes \\, name(), and args in braces and '\\lyxlock' if necessary
96 void write(WriteStream & os) const;
97 /// writes [, name(), and args in []
98 void normalize(NormalStream & os) const;
101 DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
103 void handleFont(LCursor & cur,
104 std::string const & arg, std::string const & font);
106 void handleFont2(LCursor & cur, std::string const & arg);
108 /// we store the cells in a vector
109 typedef std::vector<MathArray> cells_type;
112 /// if the inset is locked, it can't be entered with the cursor