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(Cursor & cur, bool left);
51 InsetBase * editXY(Cursor & cur, int x, int y);
53 /// order of movement through the cells when pressing the left key
54 bool idxLeft(Cursor &) const;
55 /// order of movement through the cells when pressing the right key
56 bool idxRight(Cursor &) const;
58 /// move one physical cell up
59 bool idxNext(Cursor &) const;
60 /// move one physical cell down
61 bool idxPrev(Cursor &) const;
63 /// target pos when we enter the inset from the left by pressing "Right"
64 bool idxFirst(Cursor &) const;
65 /// target pos when we enter the inset from the right by pressing "Left"
66 bool idxLast(Cursor &) 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(Cursor & cur);
77 /// direct access to the cell.
78 /// inlined because shows in profile.
80 MathData & cell(idx_type i) { return cells_[i]; }
81 MathData const & cell(idx_type i) const { return cells_[i]; }
84 /// can we move into this cell (see macroarg.h)
85 bool isActive() const;
86 /// request "external features"
87 void validate(LaTeXFeatures & features) const;
89 /// replace in all cells
90 void replace(ReplaceData &);
91 /// do we contain a given pattern?
92 bool contains(MathData const &) const;
93 /// glue everything to a single cell
94 MathData glue() const;
99 /// writes \\, name(), and args in braces and '\\lyxlock' if necessary
100 void write(WriteStream & os) const;
101 /// writes [, name(), and args in []
102 void normalize(NormalStream & os) const;
104 int latex(Buffer const &, odocstream & os,
105 OutputParams const & runparams) const;
109 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
110 /// do we want to handle this event?
111 bool getStatus(Cursor & cur, FuncRequest const & cmd,
112 FuncStatus & status) const;
114 void handleFont(Cursor & cur,
115 docstring const & arg, docstring const & font);
116 void handleFont(Cursor & cur,
117 docstring const & arg, char const * const font);
119 void handleFont2(Cursor & cur, docstring const & arg);
121 /// interpret \p c and insert the result at the current position of
122 /// of \p cur. Return whether the cursor should stay in the formula.
123 bool interpretChar(Cursor & cur, char_type c);
125 bool script(Cursor & cur, bool,
126 docstring const & save_selection = docstring());
129 /// interpret \p str and insert the result at the current position of
130 /// \p cur if it is something known. Return whether \p cur was
132 bool interpretString(Cursor & cur, docstring const & str);
136 void lfunMousePress(Cursor &, FuncRequest &);
138 void lfunMouseRelease(Cursor &, FuncRequest &);
140 void lfunMouseMotion(Cursor &, FuncRequest &);
143 /// we store the cells in a vector
144 typedef std::vector<MathData> cells_type;
147 /// if the inset is locked, it can't be entered with the cursor