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 "OutputEnums.h"
19 #include <boost/scoped_ptr.hpp>
25 class ParConstIterator;
29 /// This provides an interface between "LyX insets" and "LyX math insets"
30 class InsetMathHull : public InsetMathGrid {
33 InsetMathHull(Buffer * buf);
35 InsetMathHull(Buffer * buf, HullType type);
39 void setBuffer(Buffer &);
41 void updateLabels(ParIterator const &, UpdateType);
43 void addToToc(DocIterator const &);
45 InsetMathHull & operator=(InsetMathHull const &);
47 mode_type currentMode() const;
49 void metrics(MetricsInfo & mi, Dimension & dim) const;
51 void drawBackground(PainterInfo & pi, int x, int y) const;
53 void draw(PainterInfo &, int x, int y) const;
55 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
57 void drawT(TextPainter &, int x, int y) const;
59 docstring label(row_type row) const;
61 void label(row_type row, docstring const & label);
63 ColorCode backgroundColor(PainterInfo const &) const;
65 void numbered(row_type row, bool num);
67 bool numbered(row_type row) const;
69 bool numberedType() const;
73 void validate(LaTeXFeatures & features) const;
74 /// identifies HullInset
75 InsetMathHull const * asHullInset() const { return this; }
76 /// identifies HullInset
77 InsetMathHull * asHullInset() { return this; }
80 void addRow(row_type row);
82 void delRow(row_type row);
84 void swapRow(row_type row);
86 void addCol(col_type col);
88 void delCol(col_type col);
91 HullType getType() const;
93 void mutate(HullType newtype);
96 int defaultColSpace(col_type col);
98 char defaultColAlign(col_type col);
100 bool idxFirst(Cursor &) const;
102 bool idxLast(Cursor &) const;
105 void write(WriteStream & os) const;
107 void mathmlize(MathStream &) const;
109 void normalize(NormalStream &) const;
111 void infoize(odocstream & os) const;
114 void write(std::ostream & os) const;
116 void header_write(WriteStream &) const;
118 void footer_write(WriteStream &) const;
120 void read(Lexer & lex);
122 bool readQuiet(Lexer & lex);
124 int plaintext(odocstream &, OutputParams const &) const;
126 int docbook(odocstream &, OutputParams const &) const;
128 docstring xhtml(XHTMLStream &, OutputParams const &) const;
129 /// the string that is passed to the TOC
130 void tocString(odocstream &) const;
132 /// get notification when the cursor leaves this inset
133 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
135 //bool insetAllowed(InsetCode code) const;
137 void addPreview(DocIterator const & inset_pos,
138 graphics::PreviewLoader &) const;
139 /// Prepare the preview if preview is enabled.
140 void preparePreview(DocIterator const & pos) const;
141 /// Recreates the preview if preview is enabled.
142 void reloadPreview(DocIterator const & pos) const;
144 void initUnicodeMath() const;
147 static int displayMargin() { return 12; }
149 /// Force inset into LTR environment if surroundings are RTL?
150 virtual bool forceLTR() const { return true; }
153 virtual docstring contextMenu(BufferView const &, int, int) const;
155 InsetCode lyxCode() const { return MATH_HULL_CODE; }
158 InsetMathHull(InsetMathHull const &);
160 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
162 /// do we want to handle this event?
163 bool getStatus(Cursor & cur, FuncRequest const & cmd,
164 FuncStatus & status) const;
166 docstring eolString(row_type row, bool fragile) const;
169 virtual Inset * clone() const;
171 void setType(HullType type);
173 void validate1(LaTeXFeatures & features);
175 docstring nicelabel(row_type row) const;
177 void doExtern(Cursor & cur, FuncRequest & func);
181 * split every row at the first relation operator.
182 * The number of columns must be 1. One column is added.
183 * The first relation operator and everything after it goes to the
188 * split every row at the first relation operator.
189 * The number of columns must be < 3. One or two columns are added.
190 * The first relation operator goes to the second column.
191 * Everything after it goes to the third column.
194 /// change number of columns, split or combine columns if necessary.
195 void changeCols(col_type);
197 docstring standardFont() const;
198 /// consistency check
200 /// can this change its number of rows?
201 bool rowChangeOK() const;
202 /// can this change its number of cols?
203 bool colChangeOK() const;
205 /// "none", "simple", "display", "eqnarray",...
208 std::vector<bool> nonum_;
210 std::vector<InsetLabel *> label_;
212 boost::scoped_ptr<RenderPreview> preview_;
214 mutable bool use_preview_;
220 virtual void mutateToText();
222 virtual void revealCodes(Cursor & cur) const;
224 bool editable() const { return true; }
226 void edit(Cursor & cur, bool front,
227 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
229 Inset * editXY(Cursor & cur, int x, int y);
231 DisplayType display() const;
235 void handleFont(Cursor & cur, docstring const & arg,
236 docstring const & font);
238 void handleFont2(Cursor & cur, docstring const & arg);
240 bool previewState(BufferView * bv) const;