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