3 * \file InsetMathNest.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 "InsetMathDim.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 InsetMathNest : public InsetMathDim {
25 /// nestinsets have a fixed size to start with
26 explicit InsetMathNest(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 /// identifies NestInsets
36 InsetMathNest * asNestInset() { return this; }
37 /// identifies NestInsets
38 InsetMathNest const * asNestInset() const { return this; }
39 /// get cursor position
40 void cursorPos(BufferView const & bv, CursorSlice const & sl,
41 bool boundary, int & x, int & y) const;
43 void edit(LCursor & cur, bool left);
45 InsetBase * editXY(LCursor & cur, int x, int y);
47 /// order of movement through the cells when pressing the left key
48 bool idxLeft(LCursor &) const;
49 /// order of movement through the cells when pressing the right key
50 bool idxRight(LCursor &) const;
52 /// move one physical cell up
53 bool idxNext(LCursor &) const;
54 /// move one physical cell down
55 bool idxPrev(LCursor &) const;
57 /// target pos when we enter the inset from the left by pressing "Right"
58 bool idxFirst(LCursor &) const;
59 /// target pos when we enter the inset from the right by pressing "Left"
60 bool idxLast(LCursor &) const;
62 /// number of cells currently governed by us
63 idx_type nargs() const;
64 /// access to the lock
66 /// access to the lock
68 /// get notification when the cursor leaves this inset
69 bool notifyCursorLeaves(LCursor & cur);
71 /// direct access to the cell
72 MathArray & cell(idx_type);
73 /// direct access to the cell
74 MathArray const & cell(idx_type) const;
76 /// can we move into this cell (see macroarg.h)
77 bool isActive() const;
78 /// request "external features"
79 void validate(LaTeXFeatures & features) const;
81 /// replace in all cells
82 void replace(ReplaceData &);
83 /// do we contain a given pattern?
84 bool contains(MathArray const &) const;
85 /// glue everything to a single cell
86 MathArray glue() const;
91 /// writes \\, name(), and args in braces and '\\lyxlock' if necessary
92 void write(WriteStream & os) const;
93 /// writes [, name(), and args in []
94 void normalize(NormalStream & os) const;
96 int latex(Buffer const &, std::ostream & os,
97 OutputParams const & runparams) const;
101 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
102 /// do we want to handle this event?
103 bool getStatus(LCursor & cur, FuncRequest const & cmd,
104 FuncStatus & status) const;
106 void handleFont(LCursor & cur,
107 std::string const & arg, std::string const & font);
109 void handleFont2(LCursor & cur, std::string const & arg);
111 /// interpret \p c and insert the result at the current position of
112 /// of \p cur. Return whether the cursor should stay in the formula.
113 bool interpret(LCursor & cur, char c);
115 bool script(LCursor & cur, bool,
116 std::string const & save_selection = std::string());
119 /// interpret \p str and insert the result at the current position of
120 /// \p cur if it is something known. Return whether \p cur was
122 bool interpret(LCursor & cur, std::string const & str);
126 void lfunMousePress(LCursor &, FuncRequest &);
128 void lfunMouseRelease(LCursor &, FuncRequest &);
130 void lfunMouseMotion(LCursor &, FuncRequest &);
133 /// we store the cells in a vector
134 typedef std::vector<MathArray> cells_type;
137 /// if the inset is locked, it can't be entered with the cursor