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"
18 #include "DocIterator.h"
19 #include "OutputEnums.h"
21 #include <boost/scoped_ptr.hpp>
27 class ParConstIterator;
31 /// This provides an interface between "LyX insets" and "LyX math insets"
32 class InsetMathHull : public InsetMathGrid {
35 InsetMathHull(Buffer * buf);
37 InsetMathHull(Buffer * buf, HullType type);
39 virtual ~InsetMathHull();
41 void setBuffer(Buffer &);
43 void updateBuffer(ParIterator const &, UpdateType);
45 void addToToc(DocIterator const &);
47 InsetMathHull & operator=(InsetMathHull const &);
49 mode_type currentMode() const;
51 void metrics(MetricsInfo & mi, Dimension & dim) const;
53 void drawBackground(PainterInfo & pi, int x, int y) const;
55 void draw(PainterInfo &, int x, int y) const;
57 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
59 void drawT(TextPainter &, int x, int y) const;
61 docstring label(row_type row) const;
63 void label(row_type row, docstring const & label);
65 std::vector<InsetLabel *> const & getLabels() { return label_; }
67 ColorCode backgroundColor(PainterInfo const &) const;
69 void numbered(row_type row, bool num);
71 bool numbered(row_type row) const;
73 bool numberedType() const;
77 void validate(LaTeXFeatures & features) const;
78 /// identifies HullInset
79 InsetMathHull const * asHullInset() const { return this; }
80 /// identifies HullInset
81 InsetMathHull * asHullInset() { return this; }
84 void addRow(row_type row);
86 void delRow(row_type row);
88 void swapRow(row_type row);
90 void addCol(col_type col);
92 void delCol(col_type col);
95 HullType getType() const;
97 void mutate(HullType newtype);
100 int defaultColSpace(col_type col);
102 char defaultColAlign(col_type col);
104 bool idxFirst(Cursor &) const;
106 bool idxLast(Cursor &) const;
109 void write(WriteStream & os) const;
111 void mathmlize(MathStream &) const;
113 void normalize(NormalStream &) const;
115 void infoize(odocstream & os) const;
118 void write(std::ostream & os) const;
120 void header_write(WriteStream &) const;
122 void footer_write(WriteStream &) const;
124 void read(Lexer & lex);
126 bool readQuiet(Lexer & lex);
128 int plaintext(odocstream &, OutputParams const &) const;
130 int docbook(odocstream &, OutputParams const &) const;
132 docstring xhtml(XHTMLStream &, OutputParams const &) const;
134 void toString(odocstream &) const;
136 void forToc(docstring &, size_t) const;
138 /// get notification when the cursor leaves this inset
139 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
141 //bool insetAllowed(InsetCode code) const;
143 void addPreview(DocIterator const & inset_pos,
144 graphics::PreviewLoader &) const;
145 /// Recreates the preview if preview is enabled.
146 void reloadPreview(DocIterator const & pos) const;
148 void initUnicodeMath() const;
151 static int displayMargin() { return 12; }
153 /// Force inset into LTR environment if surroundings are RTL
154 virtual bool forceLTR() const { return true; }
156 void recordLocation(DocIterator const & di);
159 docstring contextMenuName() const;
161 InsetCode lyxCode() const { return MATH_HULL_CODE; }
164 InsetMathHull(InsetMathHull const &);
166 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
168 /// do we want to handle this event?
169 bool getStatus(Cursor & cur, FuncRequest const & cmd,
170 FuncStatus & status) const;
172 docstring eolString(row_type row, bool fragile, bool latex,
173 bool last_eoln) const;
176 virtual Inset * clone() const;
177 /// Prepare the preview if preview is enabled.
178 /// \param forexport: whether this is intended for export
179 /// If so, we ignore LyXRC and wait for the image to be generated.
180 void preparePreview(DocIterator const & pos,
181 bool forexport = false) const;
182 /// like reloadPreview, but forces load
183 /// used by image export
184 void loadPreview(DocIterator const & pos) const;
186 void setType(HullType type);
188 void validate1(LaTeXFeatures & features);
190 docstring nicelabel(row_type row) const;
192 void doExtern(Cursor & cur, FuncRequest & func);
194 void glueall(HullType type);
196 * split every row at the first relation operator.
197 * The number of columns must be 1. One column is added.
198 * The first relation operator and everything after it goes to the
203 * split every row at the first relation operator.
204 * The number of columns must be < 3. One or two columns are added.
205 * The first relation operator goes to the second column.
206 * Everything after it goes to the third column.
209 /// change number of columns, split or combine columns if necessary.
210 void changeCols(col_type);
212 docstring standardFont() const;
214 ColorCode standardColor() const;
215 /// consistency check
217 /// can this change its number of rows?
218 bool rowChangeOK() const;
219 /// can this change its number of cols?
220 bool colChangeOK() const;
222 /// "none", "simple", "display", "eqnarray",...
225 std::vector<bool> numbered_;
227 std::vector<docstring> numbers_;
229 std::vector<InsetLabel *> label_;
231 boost::scoped_ptr<RenderPreview> preview_;
233 mutable bool use_preview_;
241 virtual void mutateToText();
243 virtual void revealCodes(Cursor & cur) const;
245 bool editable() const { return true; }
247 void edit(Cursor & cur, bool front,
248 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
250 Inset * editXY(Cursor & cur, int x, int y);
252 DisplayType display() const;
256 void handleFont(Cursor & cur, docstring const & arg,
257 docstring const & font);
259 void handleFont2(Cursor & cur, docstring const & arg);
261 bool previewState(BufferView * bv) const;