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