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