]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
e9e4bb654bc82dbd2cb9acde22b38094b1d93809
[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 "math_inset.h"
23 #include "math_scriptinset.h"
24 #include "debug.h"
25
26
27 int MathInset::workwidth;
28
29
30 MathInset::MathInset()
31         : size_(LM_ST_DISPLAY), xo_(0), yo_(0)
32 {}
33
34
35 MathInset::~MathInset()
36 {}
37
38
39 int MathInset::height() const
40 {
41         return ascent() + descent();
42 }
43
44
45 MathStyles MathInset::size() const
46 {
47         return size_;
48 }
49
50
51 void MathInset::size(MathStyles s) const
52 {
53         size_ = s;
54 }
55
56
57 std::ostream & operator<<(std::ostream & os, MathInset const & inset)
58 {
59         inset.write(os, false);
60         return os;
61 }
62
63
64 int MathInset::xo() const
65 {
66         return xo_;
67 }
68
69
70 int MathInset::yo() const
71 {
72         return yo_;
73 }
74
75
76 void MathInset::xo(int x) const
77 {
78         xo_ = x;
79 }
80
81
82 void MathInset::yo(int y) const
83 {
84         yo_ = y;
85 }
86
87
88 int MathInset::nargs() const
89 {
90         return 0;
91 }
92
93
94 MathXArray dummyCell;
95
96 MathXArray & MathInset::xcell(int)
97 {
98         lyxerr << "I don't have a cell\n";
99         return dummyCell;
100 }
101
102
103 MathXArray const & MathInset::xcell(int) const
104 {
105         lyxerr << "I don't have a cell\n";
106         return dummyCell;
107 }
108
109
110 MathArray & MathInset::cell(int)
111 {
112         lyxerr << "I don't have a cell\n";
113         return dummyCell.data_;
114 }
115
116
117 MathArray const & MathInset::cell(int) const
118 {
119         lyxerr << "I don't have a cell\n";
120         return dummyCell.data_;
121 }
122
123
124 void MathInset::substitute(MathArray & array, MathMacro const &) const
125 {
126         array.push_back(clone());
127 }
128
129
130 bool MathInset::idxNext(int &, int &) const
131 {
132         return false;
133 }
134
135
136 bool MathInset::idxRight(int &, int &) const
137 {
138         return false;
139 }
140
141
142 bool MathInset::idxPrev(int &, int &) const
143 {
144         return false;
145 }
146
147
148 bool MathInset::idxLeft(int &, int &) const
149 {
150         return false;
151 }
152
153
154 bool MathInset::idxUp(int &, int &) const
155 {
156         return false;
157 }
158
159
160 bool MathInset::idxDown(int &, int &) const
161 {
162         return false;
163 }
164
165
166 bool MathInset::idxFirst(int &, int &) const
167 {
168         return false;
169 }
170
171
172 bool MathInset::idxLast(int &, int &) const
173 {
174         return false;
175 }
176
177
178 bool MathInset::idxHome(int &, int &) const
179 {
180         return false;
181 }
182
183
184 bool MathInset::idxEnd(int &, int &) const
185 {
186         return false;
187 }
188
189
190 bool MathInset::idxFirstUp(int &, int &) const
191 {
192         return false;
193 }
194
195
196 bool MathInset::idxFirstDown(int &, int &) const
197 {
198         return false;
199 }
200
201
202 void MathInset::idxDelete(int &, bool & popit, bool & deleteit)
203 {
204         popit    = false;
205         deleteit = false;
206 }
207
208
209 void MathInset::idxDeleteRange(int, int)
210 {}
211
212
213 bool MathInset::idxLastUp(int &, int &) const
214 {
215         return false;
216 }
217
218
219 bool MathInset::idxLastDown(int &, int &) const
220 {
221         return false;
222 }
223
224
225 void MathInset::getXY(int & x, int & y) const
226 {
227    x = xo();
228    y = yo();
229 }
230
231
232 /*
233 void MathInset::userSetSize(MathStyles sz)
234 {
235         if (sz >= 0) {
236                 size_ = sz;      
237                 flag = flag & ~LMPF_FIXED_SIZE;
238         }
239 }
240 */
241
242 void MathInset::writeNormal(std::ostream & os) const
243 {
244         os << "[unknown] ";
245 }
246
247
248 void MathInset::dump() const
249 {
250         lyxerr << "---------------------------------------------\n";
251         write(lyxerr, false);
252         lyxerr << "\n---------------------------------------------\n";
253 }
254
255
256 void MathInset::push_back(unsigned char, MathTextCodes)
257 {
258         lyxerr << "can't push without a cell\n";
259 }
260
261
262 void MathInset::push_back(MathInset *)
263 {
264         lyxerr << "can't push without a cell\n";
265 }
266
267
268 bool MathInset::covers(int x, int y) const
269 {
270         return
271                 x >= xo_ &&
272                 x <= xo_ + width() &&
273                 y >= yo_ - ascent() &&
274                 y <= yo_ + descent();
275 }
276
277
278 void MathInset::validate(LaTeXFeatures &) const
279 {}
280
281
282 std::vector<int> MathInset::idxBetween(int from, int to) const
283 {
284         std::vector<int> res;
285         for (int i = from; i <= to; ++i)
286                 res.push_back(i);
287         return res;
288 }
289
290
291 void MathInset::metrics(MathStyles st) const
292 {
293         lyxerr << "MathInset::metrics() called directly!\n";
294         size_ = st;
295 }
296
297
298 void MathInset::draw(Painter &, int, int) const
299 {
300         lyxerr << "MathInset::draw() called directly!\n";
301 }
302
303
304 void MathInset::write(std::ostream &, bool) const
305 {
306         lyxerr << "MathInset::write() called directly!\n";
307 }