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>
21 /// This provides an interface between "LyX insets" and "LyX math insets"
22 class InsetMathHull : public InsetMathGrid {
27 explicit InsetMathHull(HullType type);
31 InsetMathHull & operator=(InsetMathHull const &);
33 mode_type currentMode() const;
35 void metrics(MetricsInfo & mi, Dimension & dim) const;
37 void draw(PainterInfo &, int x, int y) const;
39 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
41 void drawT(TextPainter &, int x, int y) const;
43 std::string label(row_type row) const;
45 void label(row_type row, std::string const & label);
47 void numbered(row_type row, bool num);
49 bool numbered(row_type row) const;
51 bool numberedType() const;
54 /// Appends \c list with all labels found within this inset.
55 void getLabelList(Buffer const &,
56 std::vector<std::string> & list) const;
58 void validate(LaTeXFeatures & features) const;
59 /// identifies HullInset
60 InsetMathHull const * asHullInset() const { return this; }
61 /// identifies HullInset
62 InsetMathHull * asHullInset() { return this; }
65 void addRow(row_type row);
67 void delRow(row_type row);
69 void swapRow(row_type row);
71 void addCol(col_type col);
73 void delCol(col_type col);
76 HullType getType() const;
78 void mutate(HullType newtype);
81 int defaultColSpace(col_type col);
83 char defaultColAlign(col_type col);
85 bool idxFirst(LCursor &) const;
87 bool idxLast(LCursor &) const;
90 void write(WriteStream & os) const;
92 void mathmlize(MathMLStream &) const;
94 void normalize(NormalStream &) const;
96 void infoize(std::ostream & os) const;
99 void write(Buffer const &, std::ostream & os) const;
101 void read(Buffer const &, LyXLex & lex);
103 int plaintext(Buffer const &, lyx::odocstream &,
104 OutputParams const &) const;
106 int docbook(Buffer const &, std::ostream &,
107 OutputParams const &) const;
108 /// the string that is passed to the TOC
109 virtual int textString(Buffer const &, lyx::odocstream &,
110 OutputParams const &) const;
112 /// get notification when the cursor leaves this inset
113 bool notifyCursorLeaves(LCursor & cur);
115 //bool insetAllowed(Code code) const;
117 void addPreview(lyx::graphics::PreviewLoader &) const;
120 static int displayMargin() { return 12; }
123 InsetMathHull(InsetMathHull const &);
125 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
127 /// do we want to handle this event?
128 bool getStatus(LCursor & cur, FuncRequest const & cmd,
129 FuncStatus & status) const;
131 std::string eolString(row_type row, bool emptyline, bool fragile) const;
134 virtual std::auto_ptr<InsetBase> doClone() const;
136 void setType(HullType type);
138 void validate1(LaTeXFeatures & features);
140 void header_write(WriteStream &) const;
142 void footer_write(WriteStream &) const;
144 std::string nicelabel(row_type row) const;
146 void doExtern(LCursor & cur, FuncRequest & func);
150 * split every row at the first relation operator.
151 * The number of columns must be 1. One column is added.
152 * The first relation operator and everything after it goes to the
157 * split every row at the first relation operator.
158 * The number of columns must be < 3. One or two columns are added.
159 * The first relation operator goes to the second column.
160 * Everything after it goes to the third column.
163 /// change number of columns, split or combine columns if necessary.
164 void changeCols(col_type);
166 char const * standardFont() const;
167 /// consistency check
169 /// can this change its number of rows?
170 bool rowChangeOK() const;
171 /// can this change its number of cols?
172 bool colChangeOK() const;
174 /// "none", "simple", "display", "eqnarray",...
177 std::vector<int> nonum_;
179 std::vector<std::string> label_;
181 boost::scoped_ptr<RenderPreview> preview_;
183 mutable bool use_preview_;
188 /// what appears in the minibuffer when opening
189 virtual lyx::docstring const editMessage() const;
191 virtual void mutateToText();
193 virtual void revealCodes(LCursor & cur) const;
195 EDITABLE editable() const { return HIGHLY_EDITABLE; }
197 void edit(LCursor & cur, bool left);
199 InsetBase * editXY(LCursor & cur, int x, int y);
201 bool display() const;
203 Code lyxCode() const;
207 void handleFont(LCursor & cur, std::string const & arg,
208 std::string const & font);
210 void handleFont2(LCursor & cur, std::string const & arg);
212 bool previewState(BufferView * bv) const;