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>
23 class ParConstIterator;
27 /// This provides an interface between "LyX insets" and "LyX math insets"
28 class InsetMathHull : public InsetMathGrid {
31 InsetMathHull(Buffer * buf);
33 InsetMathHull(Buffer * buf, HullType type);
37 void setBuffer(Buffer &);
39 void updateLabels(ParIterator const &, bool);
41 void addToToc(DocIterator const &);
43 InsetMathHull & operator=(InsetMathHull const &);
45 mode_type currentMode() const;
47 void metrics(MetricsInfo & mi, Dimension & dim) const;
49 void drawBackground(PainterInfo & pi, int x, int y) const;
51 void draw(PainterInfo &, int x, int y) const;
53 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
55 void drawT(TextPainter &, int x, int y) const;
57 docstring label(row_type row) const;
59 void label(row_type row, docstring const & label);
61 ColorCode backgroundColor() const { return Color_mathbg; }
63 void numbered(row_type row, bool num);
65 bool numbered(row_type row) const;
67 bool numberedType() const;
71 void validate(LaTeXFeatures & features) const;
72 /// identifies HullInset
73 InsetMathHull const * asHullInset() const { return this; }
74 /// identifies HullInset
75 InsetMathHull * asHullInset() { return this; }
78 void addRow(row_type row);
80 void delRow(row_type row);
82 void swapRow(row_type row);
84 void addCol(col_type col);
86 void delCol(col_type col);
89 HullType getType() const;
91 void mutate(HullType newtype);
94 int defaultColSpace(col_type col);
96 char defaultColAlign(col_type col);
98 bool idxFirst(Cursor &) const;
100 bool idxLast(Cursor &) const;
103 void write(WriteStream & os) const;
105 void mathmlize(MathStream &) const;
107 void normalize(NormalStream &) const;
109 void infoize(odocstream & os) const;
112 void write(std::ostream & os) const;
114 void header_write(WriteStream &) const;
116 void footer_write(WriteStream &) const;
118 void read(Lexer & lex);
120 bool readQuiet(Lexer & lex);
122 int plaintext(odocstream &, OutputParams const &) const;
124 int docbook(odocstream &, OutputParams const &) const;
126 docstring xhtml(odocstream &, OutputParams const &) const;
127 /// the string that is passed to the TOC
128 void tocString(odocstream &) const;
130 /// get notification when the cursor leaves this inset
131 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
133 //bool insetAllowed(InsetCode code) const;
135 void addPreview(DocIterator const & inset_pos,
136 graphics::PreviewLoader &) const;
137 /// Prepare the preview if preview is enabled. A subsequent
138 /// call to reloadPreview will recreate the preview.
139 void preparePreview(DocIterator const & pos) const;
141 void initUnicodeMath() const;
144 static int displayMargin() { return 12; }
146 /// Force inset into LTR environment if surroundings are RTL?
147 virtual bool forceLTR() const { return true; }
150 virtual docstring contextMenu(BufferView const &, int, int) const;
152 InsetCode lyxCode() const { return MATH_HULL_CODE; }
155 InsetMathHull(InsetMathHull const &);
157 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
159 /// do we want to handle this event?
160 bool getStatus(Cursor & cur, FuncRequest const & cmd,
161 FuncStatus & status) const;
163 docstring eolString(row_type row, bool fragile) const;
166 virtual Inset * clone() const;
168 void setType(HullType type);
170 void validate1(LaTeXFeatures & features);
172 docstring nicelabel(row_type row) const;
174 void doExtern(Cursor & cur, FuncRequest & func);
178 * split every row at the first relation operator.
179 * The number of columns must be 1. One column is added.
180 * The first relation operator and everything after it goes to the
185 * split every row at the first relation operator.
186 * The number of columns must be < 3. One or two columns are added.
187 * The first relation operator goes to the second column.
188 * Everything after it goes to the third column.
191 /// change number of columns, split or combine columns if necessary.
192 void changeCols(col_type);
194 docstring standardFont() const;
195 /// consistency check
197 /// can this change its number of rows?
198 bool rowChangeOK() const;
199 /// can this change its number of cols?
200 bool colChangeOK() const;
202 /// "none", "simple", "display", "eqnarray",...
205 std::vector<bool> nonum_;
207 std::vector<InsetLabel *> label_;
209 boost::scoped_ptr<RenderPreview> preview_;
211 mutable bool use_preview_;
217 virtual void mutateToText();
219 virtual void revealCodes(Cursor & cur) const;
221 bool editable() const { return true; }
223 void edit(Cursor & cur, bool front,
224 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
226 Inset * editXY(Cursor & cur, int x, int y);
228 DisplayType display() const;
232 void handleFont(Cursor & cur, docstring const & arg,
233 docstring const & font);
235 void handleFont2(Cursor & cur, docstring const & arg);
237 bool previewState(BufferView * bv) const;