]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
40193c8f4a1b7d36d9fd4d196964fc56c61f96f7
[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         os.pendingSpace(true);
214 }
215
216
217 void MathInset::normalize(NormalStream & os) const
218 {
219         os << '[' << name().c_str() << "] ";
220 }
221
222
223 void MathInset::octavize(OctaveStream & os) const
224 {
225         NormalStream ns(os.os());
226         normalize(ns);
227 }
228
229
230 void MathInset::maplize(MapleStream & os) const
231 {
232         NormalStream ns(os.os());
233         normalize(ns);
234 }
235
236
237 void MathInset::mathematicize(MathematicaStream & os) const
238 {
239         NormalStream ns(os.os());
240         normalize(ns);
241 }
242
243
244 void MathInset::mathmlize(MathMLStream & os) const
245 {
246         NormalStream ns(os.os());
247         normalize(ns);
248 }
249
250
251 int MathInset::ascii(std::ostream &, int) const
252 {
253         return 0;
254 }
255
256
257 int MathInset::linuxdoc(std::ostream &) const
258 {
259         return 0;
260 }
261
262
263 int MathInset::docbook(std::ostream &, bool) const
264 {
265         return 0;
266 }
267
268
269 MathInset::result_type
270         MathInset::dispatch(FuncRequest const &, idx_type &, pos_type &) 
271 {
272         return UNDISPATCHED;
273 }
274
275
276 string const & MathInset::getType() const
277 {
278         static string t("none");
279         return t;
280 }
281
282
283 string MathInset::name() const
284 {
285         return "unknown";
286 }
287
288
289 string asString(MathArray const & ar)
290 {
291         std::ostringstream os;
292         WriteStream ws(os);
293         ws << ar;
294         return os.str();
295 }
296
297
298 MathArray asArray(string const & str)
299 {
300         MathArray ar;
301         mathed_parse_cell(ar, str);
302         return ar;
303 }
304
305
306 Dialogs & getDialogs()
307 {
308         return mathcursor->formula()->view()->owner()->getDialogs();
309 }