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 updateBuffer(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 std::vector<InsetLabel *> const & getLabels() { return label_; }
65 ColorCode backgroundColor(PainterInfo const &) const;
67 void numbered(row_type row, bool num);
69 bool numbered(row_type row) const;
71 bool numberedType() const;
75 void validate(LaTeXFeatures & features) const;
76 /// identifies HullInset
77 InsetMathHull const * asHullInset() const { return this; }
78 /// identifies HullInset
79 InsetMathHull * asHullInset() { return this; }
82 void addRow(row_type row);
84 void delRow(row_type row);
86 void swapRow(row_type row);
88 void addCol(col_type col);
90 void delCol(col_type col);
93 HullType getType() const;
95 void mutate(HullType newtype);
98 int defaultColSpace(col_type col);
100 char defaultColAlign(col_type col);
102 bool idxFirst(Cursor &) const;
104 bool idxLast(Cursor &) const;
107 void write(WriteStream & os) const;
109 void mathmlize(MathStream &) const;
111 void normalize(NormalStream &) const;
113 void infoize(odocstream & os) const;
116 void write(std::ostream & os) const;
118 void header_write(WriteStream &) const;
120 void footer_write(WriteStream &) const;
122 void read(Lexer & lex);
124 bool readQuiet(Lexer & lex);
126 int plaintext(odocstream &, OutputParams const &) const;
128 int docbook(odocstream &, OutputParams const &) const;
130 docstring xhtml(XHTMLStream &, OutputParams const &) const;
131 /// the string that is passed to the TOC
132 void tocString(odocstream &) const;
134 /// get notification when the cursor leaves this inset
135 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
137 //bool insetAllowed(InsetCode code) const;
139 void addPreview(DocIterator const & inset_pos,
140 graphics::PreviewLoader &) const;
141 /// Prepare the preview if preview is enabled.
142 void preparePreview(DocIterator const & pos) const;
143 /// Recreates the preview if preview is enabled.
144 void reloadPreview(DocIterator const & pos) const;
146 void initUnicodeMath() const;
149 static int displayMargin() { return 12; }
151 /// Force inset into LTR environment if surroundings are RTL?
152 virtual bool forceLTR() const { return true; }
155 virtual docstring contextMenu(BufferView const &, int, int) const;
157 InsetCode lyxCode() const { return MATH_HULL_CODE; }
160 InsetMathHull(InsetMathHull const &);
162 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
164 /// do we want to handle this event?
165 bool getStatus(Cursor & cur, FuncRequest const & cmd,
166 FuncStatus & status) const;
168 docstring eolString(row_type row, bool fragile) const;
171 virtual Inset * clone() const;
173 void setType(HullType type);
175 void validate1(LaTeXFeatures & features);
177 docstring nicelabel(row_type row) const;
179 void doExtern(Cursor & cur, FuncRequest & func);
183 * split every row at the first relation operator.
184 * The number of columns must be 1. One column is added.
185 * The first relation operator and everything after it goes to the
190 * split every row at the first relation operator.
191 * The number of columns must be < 3. One or two columns are added.
192 * The first relation operator goes to the second column.
193 * Everything after it goes to the third column.
196 /// change number of columns, split or combine columns if necessary.
197 void changeCols(col_type);
199 docstring standardFont() const;
200 /// consistency check
202 /// can this change its number of rows?
203 bool rowChangeOK() const;
204 /// can this change its number of cols?
205 bool colChangeOK() const;
207 /// "none", "simple", "display", "eqnarray",...
210 std::vector<bool> nonum_;
212 std::vector<InsetLabel *> label_;
214 boost::scoped_ptr<RenderPreview> preview_;
216 mutable bool use_preview_;
222 virtual void mutateToText();
224 virtual void revealCodes(Cursor & cur) const;
226 bool editable() const { return true; }
228 void edit(Cursor & cur, bool front,
229 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
231 Inset * editXY(Cursor & cur, int x, int y);
233 DisplayType display() const;
237 void handleFont(Cursor & cur, docstring const & arg,
238 docstring const & font);
240 void handleFont2(Cursor & cur, docstring const & arg);
242 bool previewState(BufferView * bv) const;