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