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