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;
39 void drawDecoration(PainterInfo & pi, int x, int y) const
40 { drawMarkers(pi, x, y); }
41 /// identifies NestInsets
42 InsetMathNest * asNestInset() { return this; }
43 /// identifies NestInsets
44 InsetMathNest const * asNestInset() const { return this; }
45 /// get cursor position
46 void cursorPos(BufferView const & bv, CursorSlice const & sl,
47 bool boundary, int & x, int & y) const;
49 void edit(LCursor & cur, bool left);
51 InsetBase * editXY(LCursor & cur, int x, int y);
53 /// order of movement through the cells when pressing the left key
54 bool idxLeft(LCursor &) const;
55 /// order of movement through the cells when pressing the right key
56 bool idxRight(LCursor &) const;
58 /// move one physical cell up
59 bool idxNext(LCursor &) const;
60 /// move one physical cell down
61 bool idxPrev(LCursor &) const;
63 /// target pos when we enter the inset from the left by pressing "Right"
64 bool idxFirst(LCursor &) const;
65 /// target pos when we enter the inset from the right by pressing "Left"
66 bool idxLast(LCursor &) const;
68 /// number of cells currently governed by us
69 idx_type nargs() const;
70 /// access to the lock
72 /// access to the lock
74 /// get notification when the cursor leaves this inset
75 bool notifyCursorLeaves(LCursor & cur);
77 /// direct access to the cell
78 MathArray & cell(idx_type);
79 /// direct access to the cell
80 MathArray const & cell(idx_type) const;
82 /// can we move into this cell (see macroarg.h)
83 bool isActive() const;
84 /// request "external features"
85 void validate(LaTeXFeatures & features) const;
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;
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;
102 int latex(Buffer const &, odocstream & os,
103 OutputParams const & runparams) const;
107 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
108 /// do we want to handle this event?
109 bool getStatus(LCursor & cur, FuncRequest const & cmd,
110 FuncStatus & status) const;
112 void handleFont(LCursor & cur,
113 docstring const & arg, docstring const & font);
114 void handleFont(LCursor & cur,
115 docstring const & arg, char const * const font);
117 void handleFont2(LCursor & cur, docstring const & arg);
119 /// interpret \p c and insert the result at the current position of
120 /// of \p cur. Return whether the cursor should stay in the formula.
121 bool interpretChar(LCursor & cur, char_type c);
123 bool script(LCursor & cur, bool,
124 docstring const & save_selection = docstring());
127 /// interpret \p str and insert the result at the current position of
128 /// \p cur if it is something known. Return whether \p cur was
130 bool interpretString(LCursor & cur, docstring const & str);
134 void lfunMousePress(LCursor &, FuncRequest &);
136 void lfunMouseRelease(LCursor &, FuncRequest &);
138 void lfunMouseMotion(LCursor &, FuncRequest &);
141 /// we store the cells in a vector
142 typedef std::vector<MathArray> cells_type;
145 /// if the inset is locked, it can't be entered with the cursor