3 * \file InsetMathHull.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_HULLINSET_H
13 #define MATH_HULLINSET_H
15 #include "InsetMathGrid.h"
17 #include <boost/scoped_ptr.hpp>
22 class ParConstIterator;
26 /// This provides an interface between "LyX insets" and "LyX math insets"
27 class InsetMathHull : public InsetMathGrid {
32 explicit InsetMathHull(HullType type);
36 void addToToc(Buffer const &, ParConstIterator const &) const;
38 InsetMathHull & operator=(InsetMathHull const &);
40 mode_type currentMode() const;
42 void metrics(MetricsInfo & mi, Dimension & dim) const;
44 void draw(PainterInfo &, int x, int y) const;
46 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
48 void drawT(TextPainter &, int x, int y) const;
50 docstring label(row_type row) const;
52 void label(row_type row, docstring const & label);
54 void numbered(row_type row, bool num);
56 bool numbered(row_type row) const;
58 bool numberedType() const;
61 /// Appends \c list with all labels found within this inset.
62 void getLabelList(Buffer const &,
63 std::vector<docstring> & list) const;
65 void validate(LaTeXFeatures & features) const;
66 /// identifies HullInset
67 InsetMathHull const * asHullInset() const { return this; }
68 /// identifies HullInset
69 InsetMathHull * asHullInset() { return this; }
72 void addRow(row_type row);
74 void delRow(row_type row);
76 void swapRow(row_type row);
78 void addCol(col_type col);
80 void delCol(col_type col);
83 HullType getType() const;
85 void mutate(HullType newtype);
88 int defaultColSpace(col_type col);
90 char defaultColAlign(col_type col);
92 bool idxFirst(Cursor &) const;
94 bool idxLast(Cursor &) const;
97 void write(WriteStream & os) const;
99 void mathmlize(MathStream &) const;
101 void normalize(NormalStream &) const;
103 void infoize(odocstream & os) const;
106 void write(Buffer const &, std::ostream & os) const;
108 void read(Buffer const &, Lexer & lex);
110 int plaintext(Buffer const &, odocstream &,
111 OutputParams const &) const;
113 int docbook(Buffer const &, odocstream &,
114 OutputParams const &) const;
115 /// the string that is passed to the TOC
116 virtual void textString(Buffer const &, odocstream &) const;
118 /// get notification when the cursor leaves this inset
119 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
121 //bool insetAllowed(InsetCode code) const;
123 void addPreview(graphics::PreviewLoader &) const;
126 static int displayMargin() { return 12; }
128 /// Force inset into LTR environment if surroundings are RTL?
129 virtual bool forceLTR() const { return true; }
132 InsetMathHull(InsetMathHull const &);
134 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
136 /// do we want to handle this event?
137 bool getStatus(Cursor & cur, FuncRequest const & cmd,
138 FuncStatus & status) const;
140 docstring eolString(row_type row, bool emptyline, bool fragile) const;
143 virtual Inset * clone() const;
145 void setType(HullType type);
147 void validate1(LaTeXFeatures & features);
149 void header_write(WriteStream &) const;
151 void footer_write(WriteStream &) const;
153 docstring nicelabel(row_type row) const;
155 void doExtern(Cursor & cur, FuncRequest & func);
159 * split every row at the first relation operator.
160 * The number of columns must be 1. One column is added.
161 * The first relation operator and everything after it goes to the
166 * split every row at the first relation operator.
167 * The number of columns must be < 3. One or two columns are added.
168 * The first relation operator goes to the second column.
169 * Everything after it goes to the third column.
172 /// change number of columns, split or combine columns if necessary.
173 void changeCols(col_type);
175 docstring standardFont() const;
176 /// consistency check
178 /// can this change its number of rows?
179 bool rowChangeOK() const;
180 /// can this change its number of cols?
181 bool colChangeOK() const;
183 /// "none", "simple", "display", "eqnarray",...
186 std::vector<int> nonum_;
188 std::vector<docstring> label_;
190 boost::scoped_ptr<RenderPreview> preview_;
192 mutable bool use_preview_;
197 /// what appears in the minibuffer when opening
198 virtual docstring const editMessage() const;
200 virtual void mutateToText();
202 virtual void revealCodes(Cursor & cur) const;
204 EDITABLE editable() const { return HIGHLY_EDITABLE; }
206 void edit(Cursor & cur, bool front,
207 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
209 Inset * editXY(Cursor & cur, int x, int y);
211 DisplayType display() const;
213 InsetCode lyxCode() const;
217 void handleFont(Cursor & cur, docstring const & arg,
218 docstring const & font);
220 void handleFont2(Cursor & cur, docstring const & arg);
222 bool previewState(BufferView * bv) const;