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