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