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 /// Prepare the preview if preview is enabled.
143 void preparePreview(DocIterator const & pos) const;
144 /// Recreates the preview if preview is enabled.
145 void reloadPreview(DocIterator const & pos, bool wait = false) const;
147 void initUnicodeMath() const;
150 static int displayMargin() { return 12; }
152 /// Force inset into LTR environment if surroundings are RTL
153 virtual bool forceLTR() const { return true; }
155 void recordLocation(DocIterator const & di);
158 virtual docstring contextMenu(BufferView const &, int, int) const;
160 InsetCode lyxCode() const { return MATH_HULL_CODE; }
163 InsetMathHull(InsetMathHull const &);
165 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
167 /// do we want to handle this event?
168 bool getStatus(Cursor & cur, FuncRequest const & cmd,
169 FuncStatus & status) const;
171 docstring eolString(row_type row, bool fragile, bool last_eoln) const;
174 virtual Inset * clone() const;
176 void setType(HullType type);
178 void validate1(LaTeXFeatures & features);
180 docstring nicelabel(row_type row) const;
182 void doExtern(Cursor & cur, FuncRequest & func);
186 * split every row at the first relation operator.
187 * The number of columns must be 1. One column is added.
188 * The first relation operator and everything after it goes to the
193 * split every row at the first relation operator.
194 * The number of columns must be < 3. One or two columns are added.
195 * The first relation operator goes to the second column.
196 * Everything after it goes to the third column.
199 /// change number of columns, split or combine columns if necessary.
200 void changeCols(col_type);
202 docstring standardFont() const;
204 docstring standardColor() const;
205 /// consistency check
207 /// can this change its number of rows?
208 bool rowChangeOK() const;
209 /// can this change its number of cols?
210 bool colChangeOK() const;
212 /// "none", "simple", "display", "eqnarray",...
215 std::vector<bool> nonum_;
217 std::vector<InsetLabel *> label_;
219 boost::scoped_ptr<RenderPreview> preview_;
221 mutable bool use_preview_;
229 virtual void mutateToText();
231 virtual void revealCodes(Cursor & cur) const;
233 bool editable() const { return true; }
235 void edit(Cursor & cur, bool front,
236 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
238 Inset * editXY(Cursor & cur, int x, int y);
240 DisplayType display() const;
244 void handleFont(Cursor & cur, docstring const & arg,
245 docstring const & font);
247 void handleFont2(Cursor & cur, docstring const & arg);
249 bool previewState(BufferView * bv) const;