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