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"
16 #include <boost/scoped_ptr.hpp>
24 /// This provides an interface between "LyX insets" and "LyX math insets"
25 class InsetMathHull : public InsetMathGrid {
30 explicit InsetMathHull(HullType type);
34 InsetMathHull & operator=(InsetMathHull const &);
36 mode_type currentMode() const;
38 void metrics(MetricsInfo & mi, Dimension & dim) const;
40 void draw(PainterInfo &, int x, int y) const;
42 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
44 void drawT(TextPainter &, int x, int y) const;
46 docstring label(row_type row) const;
48 void label(row_type row, docstring const & label);
50 void numbered(row_type row, bool num);
52 bool numbered(row_type row) const;
54 bool numberedType() const;
57 /// Appends \c list with all labels found within this inset.
58 void getLabelList(Buffer const &,
59 std::vector<docstring> & list) const;
61 void validate(LaTeXFeatures & features) const;
62 /// identifies HullInset
63 InsetMathHull const * asHullInset() const { return this; }
64 /// identifies HullInset
65 InsetMathHull * asHullInset() { return this; }
68 void addRow(row_type row);
70 void delRow(row_type row);
72 void swapRow(row_type row);
74 void addCol(col_type col);
76 void delCol(col_type col);
79 HullType getType() const;
81 void mutate(HullType newtype);
84 int defaultColSpace(col_type col);
86 char defaultColAlign(col_type col);
88 bool idxFirst(LCursor &) const;
90 bool idxLast(LCursor &) const;
93 void write(WriteStream & os) const;
95 void mathmlize(MathStream &) const;
97 void normalize(NormalStream &) const;
99 void infoize(odocstream & os) const;
102 void write(Buffer const &, std::ostream & os) const;
104 void read(Buffer const &, LyXLex & lex);
106 int plaintext(Buffer const &, odocstream &,
107 OutputParams const &) const;
109 int docbook(Buffer const &, odocstream &,
110 OutputParams const &) const;
111 /// the string that is passed to the TOC
112 virtual int textString(Buffer const &, odocstream &,
113 OutputParams const &) const;
115 /// get notification when the cursor leaves this inset
116 bool notifyCursorLeaves(LCursor & cur);
118 //bool insetAllowed(Code code) const;
120 void addPreview(graphics::PreviewLoader &) const;
123 static int displayMargin() { return 12; }
126 InsetMathHull(InsetMathHull const &);
128 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
130 /// do we want to handle this event?
131 bool getStatus(LCursor & cur, FuncRequest const & cmd,
132 FuncStatus & status) const;
134 docstring eolString(row_type row, bool emptyline, bool fragile) const;
137 virtual std::auto_ptr<InsetBase> doClone() const;
139 void setType(HullType type);
141 void validate1(LaTeXFeatures & features);
143 void header_write(WriteStream &) const;
145 void footer_write(WriteStream &) const;
147 docstring nicelabel(row_type row) const;
149 void doExtern(LCursor & cur, FuncRequest & func);
153 * split every row at the first relation operator.
154 * The number of columns must be 1. One column is added.
155 * The first relation operator and everything after it goes to the
160 * split every row at the first relation operator.
161 * The number of columns must be < 3. One or two columns are added.
162 * The first relation operator goes to the second column.
163 * Everything after it goes to the third column.
166 /// change number of columns, split or combine columns if necessary.
167 void changeCols(col_type);
169 docstring standardFont() const;
170 /// consistency check
172 /// can this change its number of rows?
173 bool rowChangeOK() const;
174 /// can this change its number of cols?
175 bool colChangeOK() const;
177 /// "none", "simple", "display", "eqnarray",...
180 std::vector<int> nonum_;
182 std::vector<docstring> label_;
184 boost::scoped_ptr<RenderPreview> preview_;
186 mutable bool use_preview_;
191 /// what appears in the minibuffer when opening
192 virtual docstring const editMessage() const;
194 virtual void mutateToText();
196 virtual void revealCodes(LCursor & cur) const;
198 EDITABLE editable() const { return HIGHLY_EDITABLE; }
200 void edit(LCursor & cur, bool left);
202 InsetBase * editXY(LCursor & cur, int x, int y);
204 bool display() const;
206 Code lyxCode() const;
210 void handleFont(LCursor & cur, docstring const & arg,
211 docstring const & font);
213 void handleFont2(LCursor & cur, docstring const & arg);
215 bool previewState(BufferView * bv) const;