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 "DocIterator.h"
18 #include "OutputEnums.h"
20 #include <boost/scoped_ptr.hpp>
26 class ParConstIterator;
30 /// This provides an interface between "LyX insets" and "LyX math insets"
31 class InsetMathHull : public InsetMathGrid {
34 InsetMathHull(Buffer * buf);
36 InsetMathHull(Buffer * buf, HullType type);
38 virtual ~InsetMathHull();
40 void setBuffer(Buffer &);
42 void updateBuffer(ParIterator const &, UpdateType);
44 void addToToc(DocIterator const &);
46 InsetMathHull & operator=(InsetMathHull const &);
48 mode_type currentMode() const;
50 void metrics(MetricsInfo & mi, Dimension & dim) const;
52 void drawBackground(PainterInfo & pi, int x, int y) const;
54 void draw(PainterInfo &, int x, int y) const;
56 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
58 void drawT(TextPainter &, int x, int y) const;
60 docstring label(row_type row) const;
62 void label(row_type row, docstring const & label);
64 std::vector<InsetLabel *> const & getLabels() { return label_; }
66 ColorCode backgroundColor(PainterInfo const &) const;
68 void numbered(row_type row, bool num);
70 bool numbered(row_type row) const;
72 bool numberedType() const;
76 void validate(LaTeXFeatures & features) const;
77 /// identifies HullInset
78 InsetMathHull const * asHullInset() const { return this; }
79 /// identifies HullInset
80 InsetMathHull * asHullInset() { return this; }
83 void addRow(row_type row);
85 void delRow(row_type row);
87 void swapRow(row_type row);
89 void addCol(col_type col);
91 void delCol(col_type col);
94 HullType getType() const;
96 void mutate(HullType newtype);
99 int defaultColSpace(col_type col);
101 char defaultColAlign(col_type col);
103 bool idxFirst(Cursor &) const;
105 bool idxLast(Cursor &) const;
108 void write(WriteStream & os) const;
110 void mathmlize(MathStream &) const;
112 void normalize(NormalStream &) const;
114 void infoize(odocstream & os) const;
117 void write(std::ostream & os) const;
119 void header_write(WriteStream &) const;
121 void footer_write(WriteStream &) const;
123 void read(Lexer & lex);
125 bool readQuiet(Lexer & lex);
127 int plaintext(odocstream &, OutputParams const &) const;
129 int docbook(odocstream &, OutputParams const &) const;
131 docstring xhtml(XHTMLStream &, OutputParams const &) const;
132 /// the string that is passed to the TOC
133 void tocString(odocstream &) const;
135 /// get notification when the cursor leaves this inset
136 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
138 //bool insetAllowed(InsetCode code) const;
140 void addPreview(DocIterator const & inset_pos,
141 graphics::PreviewLoader &) const;
142 /// Recreates the preview if preview is enabled.
143 void reloadPreview(DocIterator const & pos) const;
145 void initUnicodeMath() const;
148 static int displayMargin() { return 12; }
150 /// Force inset into LTR environment if surroundings are RTL
151 virtual bool forceLTR() const { return true; }
153 void recordLocation(DocIterator const & di);
156 virtual docstring contextMenu(BufferView const &, int, int) const;
158 InsetCode lyxCode() const { return MATH_HULL_CODE; }
161 InsetMathHull(InsetMathHull const &);
163 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
165 /// do we want to handle this event?
166 bool getStatus(Cursor & cur, FuncRequest const & cmd,
167 FuncStatus & status) const;
169 docstring eolString(row_type row, bool fragile, bool last_eoln) const;
172 virtual Inset * clone() const;
173 /// Prepare the preview if preview is enabled.
174 /// \param forexport: whether this is intended for export
175 /// If so, we ignore LyXRC and wait for the image to be generated.
176 void preparePreview(DocIterator const & pos,
177 bool forexport = false) const;
178 /// like reloadPreview, but forces load
179 /// used by image export
180 void loadPreview(DocIterator const & pos) const;
182 void setType(HullType type);
184 void validate1(LaTeXFeatures & features);
186 docstring nicelabel(row_type row) const;
188 void doExtern(Cursor & cur, FuncRequest & func);
192 * split every row at the first relation operator.
193 * The number of columns must be 1. One column is added.
194 * The first relation operator and everything after it goes to the
199 * split every row at the first relation operator.
200 * The number of columns must be < 3. One or two columns are added.
201 * The first relation operator goes to the second column.
202 * Everything after it goes to the third column.
205 /// change number of columns, split or combine columns if necessary.
206 void changeCols(col_type);
208 docstring standardFont() const;
210 docstring standardColor() const;
211 /// consistency check
213 /// can this change its number of rows?
214 bool rowChangeOK() const;
215 /// can this change its number of cols?
216 bool colChangeOK() const;
218 /// "none", "simple", "display", "eqnarray",...
221 std::vector<bool> nonum_;
223 std::vector<InsetLabel *> label_;
225 boost::scoped_ptr<RenderPreview> preview_;
227 mutable bool use_preview_;
235 virtual void mutateToText();
237 virtual void revealCodes(Cursor & cur) const;
239 bool editable() const { return true; }
241 void edit(Cursor & cur, bool front,
242 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
244 Inset * editXY(Cursor & cur, int x, int y);
246 DisplayType display() const;
250 void handleFont(Cursor & cur, docstring const & arg,
251 docstring const & font);
253 void handleFont2(Cursor & cur, docstring const & arg);
255 bool previewState(BufferView * bv) const;