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