]> git.lyx.org Git - lyx.git/blob - src/mathed/math_hullinset.h
more IU
[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
17
18 class LaTeXFeatures;
19
20 /// This provides an interface between "LyX insets" and "LyX math insets"
21 class MathHullInset : public MathGridInset {
22 public:
23         ///
24         MathHullInset();
25         ///
26         explicit MathHullInset(std::string const & type);
27         ///
28         virtual std::auto_ptr<InsetBase> clone() const;
29         ///
30         mode_type currentMode() const;
31         ///
32         void metrics(MetricsInfo & mi, Dimension & dim) const;
33         ///
34         void draw(PainterInfo &, int x, int y) const;
35         ///
36         void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
37         ///
38         void drawT(TextPainter &, int x, int y) const;
39         ///
40         std::string label(row_type row) const;
41         ///
42         void label(row_type row, std::string const & label);
43         ///
44         void numbered(row_type row, bool num);
45         ///
46         bool numbered(row_type row) const;
47         ///
48         bool numberedType() const;
49         ///
50         bool ams() const;
51         /// Appends \c list with all labels found within this inset.
52         void getLabelList(Buffer const &,
53                           std::vector<std::string> & list) const;
54         ///
55         void validate(LaTeXFeatures & features) const;
56         /// identifies MatrixInsets
57         MathHullInset const * asHullInset() const { return this; }
58         /// identifies HullInset
59         MathHullInset * asHullInset() { return this; }
60
61         /// add a row
62         void addRow(row_type row);
63         /// delete a row
64         void delRow(row_type row);
65         ///
66         void swapRow(row_type row);
67         /// add a column
68         void addCol(col_type col);
69         /// delete a column
70         void delCol(col_type col);
71
72         /// get type
73         std::string const & getType() const;
74         /// change type
75         void mutate(std::string const &);
76
77         ///
78         int defaultColSpace(col_type col);
79         ///
80         char defaultColAlign(col_type col);
81         ///
82         bool idxFirst(LCursor &) const;
83         ///
84         bool idxLast(LCursor &) const;
85
86         ///
87         std::string fileInsetLabel() const;
88         ///
89         void write(WriteStream & os) const;
90         ///
91         void mathmlize(MathMLStream &) const;
92         ///
93         void normalize(NormalStream &) const;
94         ///
95         void infoize(std::ostream & os) const;
96
97 protected:
98         ///
99         DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
100         ///
101         std::string eolString(row_type row, bool fragile) const;
102
103 private:
104         ///
105         void setType(std::string const & type);
106         ///
107         void validate1(LaTeXFeatures & features);
108         ///
109         void header_write(WriteStream &) const;
110         ///
111         void footer_write(WriteStream &) const;
112         ///
113         std::string nicelabel(row_type row) const;
114         ///
115         void doExtern(LCursor & cur, FuncRequest const & func);
116         ///
117         void glueall();
118         ///
119         char const * standardFont() const;
120         /// consistency check
121         void check() const;
122         /// can this change its number of cols?
123         bool colChangeOK() const;
124
125         /// "none", "simple", "display", "eqnarray",...
126         std::string type_;
127         ///
128         std::vector<int> nonum_;
129         ///
130         std::vector<std::string> label_;
131
132 //
133 // Incorporate me
134 //
135 public:
136         /// lowest x coordinate
137         int xlow() const;
138         /// highest x coordinate
139         int xhigh() const;
140         /// lowest y coordinate
141         int ylow() const;
142         /// highest y coordinate
143         int yhigh() const;
144
145
146         /// what appears in the minibuffer when opening
147         virtual std::string const editMessage() const;
148         /// get the absolute document x,y of the cursor
149         virtual void getCursorPos(BufferView & bv, int & x, int & y) const;
150         ///
151         virtual void getCursorDim(int &, int &) const;
152         ///
153         virtual void insetUnlock(BufferView & bv);
154
155         /// To allow transparent use of math editing functions
156         //virtual void status(FuncRequest const &);
157
158         ///
159         virtual bool searchForward(BufferView *, std::string const &,
160                                    bool = true, bool = false);
161         ///
162         virtual bool searchBackward(BufferView *, std::string const &,
163                                     bool = true, bool = false);
164         ///
165         virtual bool isTextInset() const { return true; }
166         ///
167         virtual void mutateToText();
168         ///
169         virtual void revealCodes(LCursor & cur) const;
170         ///
171         virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
172         ///
173         bool display() const;
174         ///
175         void edit(LCursor & cur, bool);
176         ///
177         void edit(LCursor & cur, int, int);
178         ///
179         Code MathHullInset::lyxCode() const;
180
181 private:
182         /// common base for handling accents
183         void handleAccent(BufferView & bv, std::string const & arg,
184                 std::string const & name);
185
186         /// lfun handler
187         DispatchResult lfunMousePress(LCursor &, FuncRequest const &);
188         ///
189         DispatchResult lfunMouseRelease(LCursor &, FuncRequest const &);
190         ///
191         DispatchResult lfunMouseMotion(LCursor &, FuncRequest const &);
192         ///
193         int x() const { return xo_; }
194         ///
195         int y() const { return yo_; }
196         ///
197         int yo_;
198         ///
199         int xo_;
200
201 protected:
202
203         /** Find the PreviewLoader, add a LaTeX snippet to it and
204          *  start the loading process.
205          *
206          *  Most insets have no interest in this capability, so the method
207          *  defaults to empty.
208          */
209         virtual void generatePreview(Buffer const &) const {}
210
211         ///
212         void handleFont(LCursor &, std::string const & arg, std::string const & font);
213         ///
214         void handleFont2(LCursor &, std::string const & arg);
215 };
216
217 // We don't really mess want around with mathed stuff outside mathed.
218 // So do it here.
219 void mathDispatch(LCursor & cur, FuncRequest const & cmd);
220 #endif