]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
5b29fefe340256d7fb10199593153e7287e2faa7
[lyx.git] / src / mathed / math_inset.C
1 /*
2  *  File:        math_inset.C
3  *  Purpose:     Implementation of insets for mathed
4  *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
5  *  Created:     January 1996
6  *  Description:
7  *
8  *  Dependencies: Xlib, XForms
9  *
10  *  Copyright: 1996, 1997 Alejandro Aguilar Sierra
11  *
12  *   Version: 0.8beta.
13  *
14  *   You are free to use and modify this code under the terms of
15  *   the GNU General Public Licence version 2 or later.
16  */
17
18 #ifdef __GNUG__
19 #pragma implementation
20 #endif
21
22 #include <config.h>
23
24 #include "Lsstream.h"
25 #include "math_inset.h"
26 #include "math_scriptinset.h"
27 #include "math_charinset.h"
28 #include "math_mathmlstream.h"
29 #include "math_cursor.h"
30 #include "debug.h"
31
32 #include "frontends/LyXView.h"
33 #include "frontends/Dialogs.h"
34 #include "BufferView.h"
35 #include "formulabase.h"
36
37
38 using std::ostream;
39 using std::vector;
40
41
42 int MathInset::height() const
43 {
44         return ascent() + descent();
45 }
46
47
48 ostream & operator<<(ostream & os, MathAtom const & at)
49 {
50         if (at.nucleus())
51                 os << *(at.nucleus());
52         else
53                 os << "(nil)";
54         return os;
55 }
56
57
58 ostream & operator<<(ostream & os, MathInset const & inset)
59 {
60         WriteStream wi(os, false, false);
61         inset.write(wi);
62         return os;
63 }
64
65 MathInset::size_type MathInset::nargs() const
66 {
67         return 0;
68 }
69
70
71 MathXArray dummyCell;
72
73 MathXArray & MathInset::xcell(idx_type)
74 {
75         lyxerr << "I don't have a cell 1\n";
76         return dummyCell;
77 }
78
79
80 MathXArray const & MathInset::xcell(idx_type) const
81 {
82         lyxerr << "I don't have a cell 2\n";
83         return dummyCell;
84 }
85
86
87 MathArray & MathInset::cell(idx_type)
88 {
89         lyxerr << "I don't have a cell 3\n";
90         return dummyCell.data();
91 }
92
93
94 MathArray const & MathInset::cell(idx_type) const
95 {
96         lyxerr << "I don't have a cell 4\n";
97         return dummyCell.data();
98 }
99
100
101 MathInset::idx_type MathInset::index(row_type row, col_type col) const
102 {
103         if (row != 0)
104                 lyxerr << "illegal row: " << row << "\n";
105         if (col != 0)
106                 lyxerr << "illegal col: " << col << "\n";
107         return 0;
108 }
109
110 void MathInset::substitute(MathMacro const &)
111 {}
112
113
114 bool MathInset::idxNext(idx_type &, pos_type &) const
115 {
116         return false;
117 }
118
119
120 bool MathInset::idxRight(idx_type &, pos_type &) const
121 {
122         return false;
123 }
124
125
126 bool MathInset::idxPrev(idx_type &, pos_type &) const
127 {
128         return false;
129 }
130
131
132 bool MathInset::idxLeft(idx_type &, pos_type &) const
133 {
134         return false;
135 }
136
137
138 bool MathInset::idxUpDown(idx_type &, bool) const
139 {
140         return false;
141 }
142
143
144 bool MathInset::idxFirst(idx_type &, pos_type &) const
145 {
146         return false;
147 }
148
149
150 bool MathInset::idxLast(idx_type &, pos_type &) const
151 {
152         return false;
153 }
154
155
156 bool MathInset::idxHome(idx_type &, pos_type &) const
157 {
158         return false;
159 }
160
161
162 bool MathInset::idxEnd(idx_type &, pos_type &) const
163 {
164         return false;
165 }
166
167
168 void MathInset::normalize(NormalStream & os) const
169 {
170         os << "[unknown ";
171         WriteStream wi(os.os(), false, true);
172         write(wi);
173         os << "] ";
174 }
175
176
177 void MathInset::dump() const
178 {
179         lyxerr << "---------------------------------------------\n";
180         WriteStream wi(lyxerr, false, true);
181         write(wi);
182         lyxerr << "\n---------------------------------------------\n";
183 }
184
185
186 void MathInset::validate(LaTeXFeatures &) const
187 {}
188
189
190 vector<MathInset::idx_type>
191         MathInset::idxBetween(idx_type from, idx_type to) const
192 {
193         vector<idx_type> res;
194         for (idx_type i = from; i <= to; ++i)
195                 res.push_back(i);
196         return res;
197 }
198
199
200 void MathInset::metrics(MathMetricsInfo &) const
201 {
202         lyxerr << "MathInset::metrics() called directly!\n";
203 }
204
205
206 void MathInset::draw(MathPainterInfo &, int, int) const
207 {
208         lyxerr << "MathInset::draw() called directly!\n";
209 }
210
211
212 void MathInset::metricsT(TextMetricsInfo const &) const
213 {
214 #ifdef WITH_WARNINGS
215         lyxerr << "MathInset::metricsT(Text) called directly!\n";
216 #endif
217 }
218
219
220 void MathInset::drawT(TextPainter &, int, int) const
221 {
222 #ifdef WITH_WARNINGS
223         lyxerr << "MathInset::drawT(Text) called directly!\n";
224 #endif
225 }
226
227
228
229 void MathInset::write(WriteStream &) const
230 {
231         lyxerr << "MathInset::write() called directly!\n";
232 }
233
234
235 void MathInset::octavize(OctaveStream & os) const
236 {
237         NormalStream ns(os.os());
238         normalize(ns);
239 }
240
241
242 void MathInset::maplize(MapleStream & os) const
243 {
244         NormalStream ns(os.os());
245         normalize(ns);
246 }
247
248
249 void MathInset::mathematicize(MathematicaStream & os) const
250 {
251         NormalStream ns(os.os());
252         normalize(ns);
253 }
254
255
256 void MathInset::mathmlize(MathMLStream & os) const
257 {
258         NormalStream ns(os.os());
259         normalize(ns);
260 }
261
262
263 int MathInset::ascii(std::ostream &, int) const
264 {
265         return 0;
266 }
267
268
269 int MathInset::linuxdoc(std::ostream &) const
270 {
271         return 0;
272 }
273
274
275 int MathInset::docbook(std::ostream &, bool) const
276 {
277         return 0;
278 }
279
280
281 int MathInset::dispatch(string const &, idx_type, pos_type) 
282 {
283         return 0; // undispatched
284 }
285
286
287 std::vector<string> MathInset::getLabelList() const
288 {
289         return std::vector<string>();
290 }
291
292
293 string const & MathInset::getType() const
294 {
295         static string t("none");
296         return t;
297 }
298
299
300 string asString(MathArray const & ar)
301 {
302         string res;
303         for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
304                 if ((*it)->getChar())
305                         res += (*it)->getChar();
306         return res;
307 }
308
309
310 MathArray asArray(string const & str)
311 {
312         MathArray ar;
313         for (string::const_iterator it = str.begin(); it != str.end(); ++it)
314                 ar.push_back(MathAtom(new MathCharInset(*it)));
315         return ar;
316 }
317
318
319 Dialogs * getDialogs()
320 {
321         return mathcursor->formula()->view()->owner()->getDialogs();
322 }
323
324
325 LyXFunc * getLyXFunc()
326 {
327         return mathcursor->formula()->view()->owner()->getLyXFunc();
328 }