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