]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
70010e623466f26d637b7dfe6273798668b28443
[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 MathArray dummyCell;
80
81 MathArray & MathInset::cell(idx_type)
82 {
83         lyxerr << "I don't have a cell 1\n";
84         return dummyCell;
85 }
86
87
88 MathArray const & MathInset::cell(idx_type) const
89 {
90         lyxerr << "I don't have a cell 2\n";
91         return dummyCell;
92 }
93
94
95 MathInset::idx_type MathInset::index(row_type row, col_type col) const
96 {
97         if (row != 0)
98                 lyxerr << "illegal row: " << row << "\n";
99         if (col != 0)
100                 lyxerr << "illegal col: " << col << "\n";
101         return 0;
102 }
103
104 void MathInset::substitute(MathMacro const &)
105 {}
106
107
108 bool MathInset::idxNext(idx_type &, pos_type &) const
109 {
110         return false;
111 }
112
113
114 bool MathInset::idxRight(idx_type &, pos_type &) const
115 {
116         return false;
117 }
118
119
120 bool MathInset::idxPrev(idx_type &, pos_type &) const
121 {
122         return false;
123 }
124
125
126 bool MathInset::idxLeft(idx_type &, pos_type &) const
127 {
128         return false;
129 }
130
131
132 bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
133 {
134         return false;
135 }
136
137
138 bool MathInset::idxFirst(idx_type &, pos_type &) const
139 {
140         return false;
141 }
142
143
144 bool MathInset::idxLast(idx_type &, pos_type &) const
145 {
146         return false;
147 }
148
149
150 bool MathInset::idxHome(idx_type &, pos_type &) const
151 {
152         return false;
153 }
154
155
156 bool MathInset::idxEnd(idx_type &, pos_type &) const
157 {
158         return false;
159 }
160
161
162 void MathInset::getPos(idx_type, pos_type, int & x, int & y) const
163 {
164         lyxerr << "MathInset::getPos() called directly!\n";
165         x = y = 0;
166 }
167
168
169 void MathInset::normalize(NormalStream & os) const
170 {
171         os << "[unknown ";
172         WriteStream wi(os.os(), false, true);
173         write(wi);
174         os << "] ";
175 }
176
177
178 void MathInset::dump() const
179 {
180         lyxerr << "---------------------------------------------\n";
181         WriteStream wi(lyxerr, false, true);
182         write(wi);
183         lyxerr << "\n---------------------------------------------\n";
184 }
185
186
187 bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
188 {
189         return from <= idx && idx <= to;
190 }
191
192
193 void MathInset::metrics(MathMetricsInfo &) const
194 {
195         lyxerr << "MathInset::metrics() called directly!\n";
196 }
197
198
199 void MathInset::draw(MathPainterInfo &, int, int) const
200 {
201         lyxerr << "MathInset::draw() called directly!\n";
202 }
203
204
205 void MathInset::drawSelection(MathPainterInfo &,
206         idx_type, pos_type, idx_type, pos_type) const
207 {
208         lyxerr << "MathInset::drawSelection() 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 string const & MathInset::getType() const
288 {
289         static string t("none");
290         return t;
291 }
292
293
294 string MathInset::name() const
295 {
296         return "unknown";
297 }
298
299
300 string asString(MathArray const & ar)
301 {
302         std::ostringstream os;
303         WriteStream ws(os);
304         ws << ar;
305         return os.str();
306 }
307
308
309 MathArray asArray(string const & str)
310 {
311         MathArray ar;
312         mathed_parse_cell(ar, str);
313         return ar;
314 }
315
316
317 Dialogs * getDialogs()
318 {
319         return mathcursor->formula()->view()->owner()->getDialogs();
320 }
321
322
323 LyXFunc * getLyXFunc()
324 {
325         return mathcursor->formula()->view()->owner()->getLyXFunc();
326 }