Give inset codes to all the math insets, so we get more information when
[lyx.git] / src / mathed / InsetMathHull.h
blob12b3acd7d7072f7bcfabebf550e8a8a747ed0e9c
1 // -*- C++ -*-
2 /**
3 * \file InsetMathHull.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author André Pönitz
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>
20 namespace lyx {
22 class InsetLabel;
23 class ParConstIterator;
24 class RenderPreview;
27 /// This provides an interface between "LyX insets" and "LyX math insets"
28 class InsetMathHull : public InsetMathGrid {
29 public:
30 ///
31 InsetMathHull();
32 ///
33 explicit InsetMathHull(HullType type);
34 ///
35 ~InsetMathHull();
36 ///
37 void setBuffer(Buffer &);
38 ///
39 void updateLabels(ParIterator const &);
40 ///
41 void addToToc(DocIterator const &);
42 ///
43 InsetMathHull & operator=(InsetMathHull const &);
44 ///
45 mode_type currentMode() const;
46 ///
47 void metrics(MetricsInfo & mi, Dimension & dim) const;
48 ///
49 void drawBackground(PainterInfo & pi, int x, int y) const;
50 ///
51 void draw(PainterInfo &, int x, int y) const;
52 ///
53 void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
54 ///
55 void drawT(TextPainter &, int x, int y) const;
56 ///
57 docstring label(row_type row) const;
58 ///
59 void label(row_type row, docstring const & label);
60 ///
61 ColorCode backgroundColor() const { return Color_mathbg; }
62 ///
63 void numbered(row_type row, bool num);
64 ///
65 bool numbered(row_type row) const;
66 ///
67 bool numberedType() const;
68 ///
69 bool ams() const;
70 ///
71 void validate(LaTeXFeatures & features) const;
72 /// identifies HullInset
73 InsetMathHull const * asHullInset() const { return this; }
74 /// identifies HullInset
75 InsetMathHull * asHullInset() { return this; }
77 /// add a row
78 void addRow(row_type row);
79 /// delete a row
80 void delRow(row_type row);
81 /// swap two rows
82 void swapRow(row_type row);
83 /// add a column
84 void addCol(col_type col);
85 /// delete a column
86 void delCol(col_type col);
88 /// get type
89 HullType getType() const;
90 /// change type
91 void mutate(HullType newtype);
93 ///
94 int defaultColSpace(col_type col);
95 ///
96 char defaultColAlign(col_type col);
97 ///
98 bool idxFirst(Cursor &) const;
99 ///
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;
125 /// the string that is passed to the TOC
126 void tocString(odocstream &) const;
128 /// get notification when the cursor leaves this inset
129 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
131 //bool insetAllowed(InsetCode code) const;
133 void addPreview(graphics::PreviewLoader &) const;
135 void initUnicodeMath() const;
138 static int displayMargin() { return 12; }
140 /// Force inset into LTR environment if surroundings are RTL?
141 virtual bool forceLTR() const { return true; }
144 virtual docstring contextMenu(BufferView const &, int, int) const;
146 InsetCode lyxCode() const { return MATH_HULL_CODE; }
148 protected:
149 InsetMathHull(InsetMathHull const &);
151 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
153 /// do we want to handle this event?
154 bool getStatus(Cursor & cur, FuncRequest const & cmd,
155 FuncStatus & status) const;
157 docstring eolString(row_type row, bool emptyline, bool fragile) const;
159 private:
160 virtual Inset * clone() const;
162 void setType(HullType type);
164 void validate1(LaTeXFeatures & features);
166 docstring nicelabel(row_type row) const;
168 void doExtern(Cursor & cur, FuncRequest & func);
170 void glueall();
172 * split every row at the first relation operator.
173 * The number of columns must be 1. One column is added.
174 * The first relation operator and everything after it goes to the
175 * second column.
177 void splitTo2Cols();
179 * split every row at the first relation operator.
180 * The number of columns must be < 3. One or two columns are added.
181 * The first relation operator goes to the second column.
182 * Everything after it goes to the third column.
184 void splitTo3Cols();
185 /// change number of columns, split or combine columns if necessary.
186 void changeCols(col_type);
188 docstring standardFont() const;
189 /// consistency check
190 void check() const;
191 /// can this change its number of rows?
192 bool rowChangeOK() const;
193 /// can this change its number of cols?
194 bool colChangeOK() const;
196 /// "none", "simple", "display", "eqnarray",...
197 HullType type_;
199 std::vector<bool> nonum_;
201 std::vector<InsetLabel *> label_;
203 boost::scoped_ptr<RenderPreview> preview_;
205 mutable bool use_preview_;
207 // Incorporate me
209 public:
211 virtual void mutateToText();
213 virtual void revealCodes(Cursor & cur) const;
215 bool editable() const { return true; }
217 void edit(Cursor & cur, bool front,
218 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
220 Inset * editXY(Cursor & cur, int x, int y);
222 DisplayType display() const;
224 protected:
226 void handleFont(Cursor & cur, docstring const & arg,
227 docstring const & font);
229 void handleFont2(Cursor & cur, docstring const & arg);
231 bool previewState(BufferView * bv) const;
236 } // namespace lyx
237 #endif