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