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