]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
d5d6af8653c90962a0250adb69fee0c773f598f3
[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 #include "math_inset.h"
21 #include "Lsstream.h"
22 #include "math_scriptinset.h"
23 #include "math_mathmlstream.h"
24 #include "math_cursor.h"
25 #include "math_parser.h"
26 #include "debug.h"
27
28 #include "frontends/LyXView.h"
29 #include "frontends/Dialogs.h"
30 #include "BufferView.h"
31 #include "formulabase.h"
32
33 using std::ostream;
34
35
36 BufferView * MathInset::view() const
37 {
38         if (!mathcursor)
39                 return 0;
40         return mathcursor->formula()->view();
41 }
42
43
44 MathInset::size_type MathInset::nargs() const
45 {
46         return 0;
47 }
48
49
50 MathArray dummyCell;
51
52 MathArray & MathInset::cell(idx_type)
53 {
54         lyxerr << "I don't have a cell 1\n";
55         return dummyCell;
56 }
57
58
59 MathArray const & MathInset::cell(idx_type) const
60 {
61         lyxerr << "I don't have a cell 2\n";
62         return dummyCell;
63 }
64
65
66 MathInset::idx_type MathInset::index(row_type row, col_type col) const
67 {
68         if (row != 0)
69                 lyxerr << "illegal row: " << row << "\n";
70         if (col != 0)
71                 lyxerr << "illegal col: " << col << "\n";
72         return 0;
73 }
74
75 void MathInset::substitute(MathMacro const &)
76 {}
77
78
79 bool MathInset::idxNext(idx_type &, pos_type &) const
80 {
81         return false;
82 }
83
84
85 bool MathInset::idxRight(idx_type &, pos_type &) const
86 {
87         return false;
88 }
89
90
91 bool MathInset::idxPrev(idx_type &, pos_type &) const
92 {
93         return false;
94 }
95
96
97 bool MathInset::idxLeft(idx_type &, pos_type &) const
98 {
99         return false;
100 }
101
102
103 bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
104 {
105         return false;
106 }
107
108
109 bool MathInset::idxUpDown2(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::draw(PainterInfo &, int, int) const
162 {
163         lyxerr << "MathInset::draw() called directly!\n";
164 }
165
166
167 void MathInset::drawSelection(PainterInfo &,
168         idx_type, pos_type, idx_type, pos_type) const
169 {
170         lyxerr << "MathInset::drawSelection() called directly!\n";
171 }
172
173
174 void MathInset::metricsT(TextMetricsInfo const &, Dimension &) const
175 {
176 #ifdef WITH_WARNINGS
177         lyxerr << "MathInset::metricsT(Text) called directly!\n";
178 #endif
179 }
180
181
182 void MathInset::drawT(TextPainter &, int, int) const
183 {
184 #ifdef WITH_WARNINGS
185         lyxerr << "MathInset::drawT(Text) called directly!\n";
186 #endif
187 }
188
189
190
191 void MathInset::write(WriteStream & os) const
192 {
193         os << '\\' << name().c_str();
194         os.pendingSpace(true);
195 }
196
197
198 void MathInset::normalize(NormalStream & os) const
199 {
200         os << '[' << name().c_str() << "] ";
201 }
202
203
204 void MathInset::octave(OctaveStream & os) const
205 {
206         NormalStream ns(os.os());
207         normalize(ns);
208 }
209
210
211 void MathInset::maple(MapleStream & os) const
212 {
213         NormalStream ns(os.os());
214         normalize(ns);
215 }
216
217
218 void MathInset::maxima(MaximaStream & os) const
219 {
220         MapleStream ns(os.os());
221         maple(ns);
222 }
223
224
225 void MathInset::mathematica(MathematicaStream & os) const
226 {
227         NormalStream ns(os.os());
228         normalize(ns);
229 }
230
231
232 void MathInset::mathmlize(MathMLStream & os) const
233 {
234         NormalStream ns(os.os());
235         normalize(ns);
236 }
237
238
239 int MathInset::ascii(std::ostream &, int) const
240 {
241         return 0;
242 }
243
244
245 int MathInset::linuxdoc(std::ostream &) const
246 {
247         return 0;
248 }
249
250
251 int MathInset::docbook(std::ostream &, bool) const
252 {
253         return 0;
254 }
255
256
257 string const & MathInset::getType() const
258 {
259         static string const t("none");
260         return t;
261 }
262
263
264 string MathInset::name() const
265 {
266         return "unknown";
267 }
268
269
270 string asString(MathArray const & ar)
271 {
272         std::ostringstream os;
273         WriteStream ws(os);
274         ws << ar;
275         return STRCONV(os.str());
276 }
277
278
279 MathArray asArray(string const & str)
280 {
281         MathArray ar;
282         mathed_parse_cell(ar, str);
283         return ar;
284 }
285
286
287 ostream & operator<<(ostream & os, MathAtom const & at)
288 {
289         WriteStream wi(os, false, false);
290         at->write(wi);
291         return os;
292 }
293
294
295 string MathInset::fileInsetLabel() const
296 {
297         return "Formula";
298 }