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