]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
the up/down stuff reworked
[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_mathmlstream.h"
28 #include "math_cursor.h"
29 #include "math_parser.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
66 MathInset::size_type MathInset::nargs() const
67 {
68         return 0;
69 }
70
71
72 Dimension MathInset::dimensions() const
73 {
74         lyxerr << "call MathInset::dimensions()\n";
75         return Dimension(width(), ascent(), descent());
76 }
77
78
79 MathXArray dummyCell;
80
81 MathXArray & MathInset::xcell(idx_type)
82 {
83         lyxerr << "I don't have a cell 1\n";
84         return dummyCell;
85 }
86
87
88 MathXArray const & MathInset::xcell(idx_type) const
89 {
90         lyxerr << "I don't have a cell 2\n";
91         return dummyCell;
92 }
93
94
95 MathArray & MathInset::cell(idx_type)
96 {
97         lyxerr << "I don't have a cell 3\n";
98         return dummyCell.data();
99 }
100
101
102 MathArray const & MathInset::cell(idx_type) const
103 {
104         lyxerr << "I don't have a cell 4\n";
105         return dummyCell.data();
106 }
107
108
109 MathInset::idx_type MathInset::index(row_type row, col_type col) const
110 {
111         if (row != 0)
112                 lyxerr << "illegal row: " << row << "\n";
113         if (col != 0)
114                 lyxerr << "illegal col: " << col << "\n";
115         return 0;
116 }
117
118 void MathInset::substitute(MathMacro const &)
119 {}
120
121
122 bool MathInset::idxNext(idx_type &, pos_type &) const
123 {
124         return false;
125 }
126
127
128 bool MathInset::idxRight(idx_type &, pos_type &) const
129 {
130         return false;
131 }
132
133
134 bool MathInset::idxPrev(idx_type &, pos_type &) const
135 {
136         return false;
137 }
138
139
140 bool MathInset::idxLeft(idx_type &, pos_type &) const
141 {
142         return false;
143 }
144
145
146 bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
147 {
148         return false;
149 }
150
151
152 bool MathInset::idxFirst(idx_type &, pos_type &) const
153 {
154         return false;
155 }
156
157
158 bool MathInset::idxLast(idx_type &, pos_type &) const
159 {
160         return false;
161 }
162
163
164 bool MathInset::idxHome(idx_type &, pos_type &) const
165 {
166         return false;
167 }
168
169
170 bool MathInset::idxEnd(idx_type &, pos_type &) const
171 {
172         return false;
173 }
174
175
176 void MathInset::getPos(idx_type, pos_type, int & x, int & y) const
177 {
178         lyxerr << "MathInset::getPos() called directly!\n";
179         x = y = 0;
180 }
181
182
183 void MathInset::normalize(NormalStream & os) const
184 {
185         os << "[unknown ";
186         WriteStream wi(os.os(), false, true);
187         write(wi);
188         os << "] ";
189 }
190
191
192 void MathInset::dump() const
193 {
194         lyxerr << "---------------------------------------------\n";
195         WriteStream wi(lyxerr, false, true);
196         write(wi);
197         lyxerr << "\n---------------------------------------------\n";
198 }
199
200
201 void MathInset::validate(LaTeXFeatures &) const
202 {}
203
204
205 vector<MathInset::idx_type>
206         MathInset::idxBetween(idx_type from, idx_type to) const
207 {
208         vector<idx_type> res;
209         for (idx_type i = from; i <= to; ++i)
210                 res.push_back(i);
211         return res;
212 }
213
214
215 void MathInset::metrics(MathMetricsInfo &) const
216 {
217         lyxerr << "MathInset::metrics() called directly!\n";
218 }
219
220
221 void MathInset::draw(MathPainterInfo &, int, int) const
222 {
223         lyxerr << "MathInset::draw() called directly!\n";
224 }
225
226
227 void MathInset::drawSelection(MathPainterInfo &,
228         idx_type, pos_type, idx_type, pos_type) const
229 {
230         lyxerr << "MathInset::drawSelection() called directly!\n";
231 }
232
233
234 void MathInset::metricsT(TextMetricsInfo const &) const
235 {
236 #ifdef WITH_WARNINGS
237         lyxerr << "MathInset::metricsT(Text) called directly!\n";
238 #endif
239 }
240
241
242 void MathInset::drawT(TextPainter &, int, int) const
243 {
244 #ifdef WITH_WARNINGS
245         lyxerr << "MathInset::drawT(Text) called directly!\n";
246 #endif
247 }
248
249
250
251 void MathInset::write(WriteStream &) const
252 {
253         lyxerr << "MathInset::write() called directly!\n";
254 }
255
256
257 void MathInset::octavize(OctaveStream & os) const
258 {
259         NormalStream ns(os.os());
260         normalize(ns);
261 }
262
263
264 void MathInset::maplize(MapleStream & os) const
265 {
266         NormalStream ns(os.os());
267         normalize(ns);
268 }
269
270
271 void MathInset::mathematicize(MathematicaStream & os) const
272 {
273         NormalStream ns(os.os());
274         normalize(ns);
275 }
276
277
278 void MathInset::mathmlize(MathMLStream & os) const
279 {
280         NormalStream ns(os.os());
281         normalize(ns);
282 }
283
284
285 int MathInset::ascii(std::ostream &, int) const
286 {
287         return 0;
288 }
289
290
291 int MathInset::linuxdoc(std::ostream &) const
292 {
293         return 0;
294 }
295
296
297 int MathInset::docbook(std::ostream &, bool) const
298 {
299         return 0;
300 }
301
302
303 int MathInset::dispatch(string const &, idx_type, pos_type) 
304 {
305         return 0; // undispatched
306 }
307
308
309 std::vector<string> MathInset::getLabelList() const
310 {
311         return std::vector<string>();
312 }
313
314
315 string const & MathInset::getType() const
316 {
317         static string t("none");
318         return t;
319 }
320
321
322 string asString(MathArray const & ar)
323 {
324         std::ostringstream os;
325         WriteStream ws(os);
326         ws << ar;
327         return os.str();
328 }
329
330
331 MathArray asArray(string const & str)
332 {
333         MathArray ar;
334         mathed_parse_cell(ar, str);
335         return ar;
336 }
337
338
339 Dialogs * getDialogs()
340 {
341         return mathcursor->formula()->view()->owner()->getDialogs();
342 }
343
344
345 LyXFunc * getLyXFunc()
346 {
347         return mathcursor->formula()->view()->owner()->getLyXFunc();
348 }