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(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(std::vector<docstring> & list) const;
64 void validate(LaTeXFeatures & features) const;
65 /// identifies HullInset
66 InsetMathHull const * asHullInset() const { return this; }
67 /// identifies HullInset
68 InsetMathHull * asHullInset() { return this; }
71 void addRow(row_type row);
73 void delRow(row_type row);
75 void swapRow(row_type row);
77 void addCol(col_type col);
79 void delCol(col_type col);
82 HullType getType() const;
84 void mutate(HullType newtype);
87 int defaultColSpace(col_type col);
89 char defaultColAlign(col_type col);
91 bool idxFirst(Cursor &) const;
93 bool idxLast(Cursor &) const;
96 void write(WriteStream & os) const;
98 void mathmlize(MathStream &) const;
100 void normalize(NormalStream &) const;
102 void infoize(odocstream & os) const;
105 void write(std::ostream & os) const;
107 void read(Lexer & lex);
109 int plaintext(odocstream &, OutputParams const &) const;
111 int docbook(odocstream &, OutputParams const &) const;
112 /// the string that is passed to the TOC
113 void textString(odocstream &) const;
115 /// get notification when the cursor leaves this inset
116 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
118 //bool insetAllowed(InsetCode code) const;
120 void addPreview(graphics::PreviewLoader &) const;
123 static int displayMargin() { return 12; }
125 /// Force inset into LTR environment if surroundings are RTL?
126 virtual bool forceLTR() const { return true; }
129 InsetMathHull(InsetMathHull const &);
131 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
133 /// do we want to handle this event?
134 bool getStatus(Cursor & cur, FuncRequest const & cmd,
135 FuncStatus & status) const;
137 docstring eolString(row_type row, bool emptyline, bool fragile) const;
140 virtual Inset * clone() const;
142 void setType(HullType type);
144 void validate1(LaTeXFeatures & features);
146 void header_write(WriteStream &) const;
148 void footer_write(WriteStream &) const;
150 docstring nicelabel(row_type row) const;
152 void doExtern(Cursor & cur, FuncRequest & func);
156 * split every row at the first relation operator.
157 * The number of columns must be 1. One column is added.
158 * The first relation operator and everything after it goes to the
163 * split every row at the first relation operator.
164 * The number of columns must be < 3. One or two columns are added.
165 * The first relation operator goes to the second column.
166 * Everything after it goes to the third column.
169 /// change number of columns, split or combine columns if necessary.
170 void changeCols(col_type);
172 docstring standardFont() const;
173 /// consistency check
175 /// can this change its number of rows?
176 bool rowChangeOK() const;
177 /// can this change its number of cols?
178 bool colChangeOK() const;
180 /// "none", "simple", "display", "eqnarray",...
183 std::vector<int> nonum_;
185 std::vector<docstring> label_;
187 boost::scoped_ptr<RenderPreview> preview_;
189 mutable bool use_preview_;
194 /// what appears in the minibuffer when opening
195 docstring editMessage() const;
197 virtual void mutateToText();
199 virtual void revealCodes(Cursor & cur) const;
201 EDITABLE editable() const { return HIGHLY_EDITABLE; }
203 void edit(Cursor & cur, bool front,
204 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
206 Inset * editXY(Cursor & cur, int x, int y);
208 DisplayType display() const;
210 InsetCode lyxCode() const;
214 void handleFont(Cursor & cur, docstring const & arg,
215 docstring const & font);
217 void handleFont2(Cursor & cur, docstring const & arg);
219 bool previewState(BufferView * bv) const;