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