]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathHull.h
do what the FIXME suggested
[lyx.git] / src / mathed / InsetMathHull.h
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.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef MATH_HULLINSET_H
13 #define MATH_HULLINSET_H
14
15 #include "InsetMathGrid.h"
16
17 #include <boost/scoped_ptr.hpp>
18
19
20 namespace lyx {
21
22 class InsetLabel;
23 class ParConstIterator;
24 class RenderPreview;
25
26
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(ParConstIterator const &) 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 draw(PainterInfo &, int x, int y) const;
50         ///
51         void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
52         ///
53         void drawT(TextPainter &, int x, int y) const;
54         ///
55         docstring label(row_type row) const;
56         ///
57         void label(row_type row, docstring const & label);
58         ///
59         void numbered(row_type row, bool num);
60         ///
61         bool numbered(row_type row) const;
62         ///
63         bool numberedType() const;
64         ///
65         bool ams() const;
66         /// Appends \c list with all labels found within this inset.
67         void getLabelList(std::vector<docstring> & list) const;
68         ///
69         void validate(LaTeXFeatures & features) const;
70         /// identifies HullInset
71         InsetMathHull const * asHullInset() const { return this; }
72         /// identifies HullInset
73         InsetMathHull * asHullInset() { return this; }
74
75         /// add a row
76         void addRow(row_type row);
77         /// delete a row
78         void delRow(row_type row);
79         /// swap two rows
80         void swapRow(row_type row);
81         /// add a column
82         void addCol(col_type col);
83         /// delete a column
84         void delCol(col_type col);
85
86         /// get type
87         HullType getType() const;
88         /// change type
89         void mutate(HullType newtype);
90
91         ///
92         int defaultColSpace(col_type col);
93         ///
94         char defaultColAlign(col_type col);
95         ///
96         bool idxFirst(Cursor &) const;
97         ///
98         bool idxLast(Cursor &) const;
99
100         ///
101         void write(WriteStream & os) const;
102         ///
103         void mathmlize(MathStream &) const;
104         ///
105         void normalize(NormalStream &) const;
106         ///
107         void infoize(odocstream & os) const;
108
109         ///
110         void write(std::ostream & os) const;
111         ///
112         void read(Lexer & lex);
113         ///
114         int plaintext(odocstream &, OutputParams const &) const;
115         ///
116         int docbook(odocstream &, OutputParams const &) const;
117         /// the string that is passed to the TOC
118         void textString(odocstream &) const;
119
120         /// get notification when the cursor leaves this inset
121         bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
122         ///
123         //bool insetAllowed(InsetCode code) const;
124         ///
125         void addPreview(graphics::PreviewLoader &) const;
126
127         ///
128         static int displayMargin() { return 12; }
129         
130         /// Force inset into LTR environment if surroundings are RTL?
131         virtual bool forceLTR() const { return true; }
132
133 protected:
134         InsetMathHull(InsetMathHull const &);
135
136         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
137
138         /// do we want to handle this event?
139         bool getStatus(Cursor & cur, FuncRequest const & cmd,
140                 FuncStatus & status) const;
141         ///
142         docstring eolString(row_type row, bool emptyline, bool fragile) const;
143
144 private:
145         virtual Inset * clone() const;
146         ///
147         void setType(HullType type);
148         ///
149         void validate1(LaTeXFeatures & features);
150         ///
151         void header_write(WriteStream &) const;
152         ///
153         void footer_write(WriteStream &) const;
154         ///
155         docstring nicelabel(row_type row) const;
156         ///
157         void doExtern(Cursor & cur, FuncRequest & func);
158         ///
159         void glueall();
160         /*!
161          * split every row at the first relation operator.
162          * The number of columns must be 1. One column is added.
163          * The first relation operator and everything after it goes to the
164          * second column.
165          */
166         void splitTo2Cols();
167         /*!
168          * split every row at the first relation operator.
169          * The number of columns must be < 3. One or two columns are added.
170          * The first relation operator goes to the second column.
171          * Everything after it goes to the third column.
172          */
173         void splitTo3Cols();
174         /// change number of columns, split or combine columns if necessary.
175         void changeCols(col_type);
176         ///
177         docstring standardFont() const;
178         /// consistency check
179         void check() const;
180         /// can this change its number of rows?
181         bool rowChangeOK() const;
182         /// can this change its number of cols?
183         bool colChangeOK() const;
184
185         /// "none", "simple", "display", "eqnarray",...
186         HullType type_;
187         ///
188         std::vector<bool> nonum_;
189         ///
190         std::vector<InsetLabel *> label_;
191         ///
192         boost::scoped_ptr<RenderPreview> preview_;
193         ///
194         mutable bool use_preview_;
195 //
196 // Incorporate me
197 //
198 public:
199         /// what appears in the minibuffer when opening
200         docstring editMessage() const;
201         ///
202         virtual void mutateToText();
203         ///
204         virtual void revealCodes(Cursor & cur) const;
205         ///
206         EDITABLE editable() const { return HIGHLY_EDITABLE; }
207         ///
208         void edit(Cursor & cur, bool front, 
209                 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
210         ///
211         Inset * editXY(Cursor & cur, int x, int y);
212         ///
213         DisplayType display() const;
214         ///
215         InsetCode lyxCode() const;
216
217 protected:
218         ///
219         void handleFont(Cursor & cur, docstring const & arg,
220                 docstring const & font);
221         ///
222         void handleFont2(Cursor & cur, docstring const & arg);
223         ///
224         bool previewState(BufferView * bv) const;
225 };
226
227
228
229 } // namespace lyx
230 #endif