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"
21 /** Abstract base class for all math objects that contain nested items.
22 This is basically everything that is not a single character or a
26 class InsetMathNest : public InsetMathDim {
28 /// nestinsets have a fixed size to start with
29 explicit InsetMathNest(idx_type ncells);
31 /// the size is usually some sort of convex hull of the cells
32 /// hides inset::metrics() intentionally!
33 void metrics(MetricsInfo const & mi) const;
34 /// draw background if locked
35 void draw(PainterInfo & pi, int x, int y) const;
36 /// draw selection background
37 void drawSelection(PainterInfo & pi, int x, int y) const;
38 /// identifies NestInsets
39 InsetMathNest * asNestInset() { return this; }
40 /// identifies NestInsets
41 InsetMathNest const * asNestInset() const { return this; }
42 /// get cursor position
43 void cursorPos(BufferView const & bv, CursorSlice const & sl,
44 bool boundary, int & x, int & y) const;
46 void edit(LCursor & cur, bool left);
48 InsetBase * editXY(LCursor & cur, int x, int y);
50 /// order of movement through the cells when pressing the left key
51 bool idxLeft(LCursor &) const;
52 /// order of movement through the cells when pressing the right key
53 bool idxRight(LCursor &) const;
55 /// move one physical cell up
56 bool idxNext(LCursor &) const;
57 /// move one physical cell down
58 bool idxPrev(LCursor &) const;
60 /// target pos when we enter the inset from the left by pressing "Right"
61 bool idxFirst(LCursor &) const;
62 /// target pos when we enter the inset from the right by pressing "Left"
63 bool idxLast(LCursor &) const;
65 /// number of cells currently governed by us
66 idx_type nargs() const;
67 /// access to the lock
69 /// access to the lock
71 /// get notification when the cursor leaves this inset
72 bool notifyCursorLeaves(LCursor & cur);
74 /// direct access to the cell
75 MathArray & cell(idx_type);
76 /// direct access to the cell
77 MathArray const & cell(idx_type) const;
79 /// can we move into this cell (see macroarg.h)
80 bool isActive() const;
81 /// request "external features"
82 void validate(LaTeXFeatures & features) const;
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;
94 /// writes \\, name(), and args in braces and '\\lyxlock' if necessary
95 void write(WriteStream & os) const;
96 /// writes [, name(), and args in []
97 void normalize(NormalStream & os) const;
99 int latex(Buffer const &, odocstream & os,
100 OutputParams const & runparams) const;
104 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
105 /// do we want to handle this event?
106 bool getStatus(LCursor & cur, FuncRequest const & cmd,
107 FuncStatus & status) const;
109 void handleFont(LCursor & cur,
110 std::string const & arg, std::string const & font);
112 void handleFont2(LCursor & cur, std::string const & arg);
114 /// interpret \p c and insert the result at the current position of
115 /// of \p cur. Return whether the cursor should stay in the formula.
116 bool interpretChar(LCursor & cur, char_type c);
118 bool script(LCursor & cur, bool,
119 std::string const & save_selection = std::string());
122 /// interpret \p str and insert the result at the current position of
123 /// \p cur if it is something known. Return whether \p cur was
125 bool interpretString(LCursor & cur, std::string const & str);
129 void lfunMousePress(LCursor &, FuncRequest &);
131 void lfunMouseRelease(LCursor &, FuncRequest &);
133 void lfunMouseMotion(LCursor &, FuncRequest &);
136 /// we store the cells in a vector
137 typedef std::vector<MathArray> cells_type;
140 /// if the inset is locked, it can't be entered with the cursor