]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
partial fix for the macro problem
[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(MathMacro const &)
125 {}
126
127
128 bool MathInset::idxNext(int &, int &) const
129 {
130         return false;
131 }
132
133
134 bool MathInset::idxRight(int &, int &) const
135 {
136         return false;
137 }
138
139
140 bool MathInset::idxPrev(int &, int &) const
141 {
142         return false;
143 }
144
145
146 bool MathInset::idxLeft(int &, int &) const
147 {
148         return false;
149 }
150
151
152 bool MathInset::idxUp(int &, int &) const
153 {
154         return false;
155 }
156
157
158 bool MathInset::idxDown(int &, int &) const
159 {
160         return false;
161 }
162
163
164 bool MathInset::idxFirst(int &, int &) const
165 {
166         return false;
167 }
168
169
170 bool MathInset::idxLast(int &, int &) const
171 {
172         return false;
173 }
174
175
176 bool MathInset::idxHome(int &, int &) const
177 {
178         return false;
179 }
180
181
182 bool MathInset::idxEnd(int &, int &) const
183 {
184         return false;
185 }
186
187
188 bool MathInset::idxFirstUp(int &, int &) const
189 {
190         return false;
191 }
192
193
194 bool MathInset::idxFirstDown(int &, int &) const
195 {
196         return false;
197 }
198
199
200 void MathInset::idxDelete(int &, bool & popit, bool & deleteit)
201 {
202         popit    = false;
203         deleteit = false;
204 }
205
206
207 void MathInset::idxDeleteRange(int, int)
208 {}
209
210
211 bool MathInset::idxLastUp(int &, int &) const
212 {
213         return false;
214 }
215
216
217 bool MathInset::idxLastDown(int &, int &) const
218 {
219         return false;
220 }
221
222
223 void MathInset::getXY(int & x, int & y) const
224 {
225    x = xo();
226    y = yo();
227 }
228
229
230 /*
231 void MathInset::userSetSize(MathStyles sz)
232 {
233         if (sz >= 0) {
234                 size_ = sz;      
235                 flag = flag & ~LMPF_FIXED_SIZE;
236         }
237 }
238 */
239
240 void MathInset::writeNormal(std::ostream & os) const
241 {
242         os << "[unknown] ";
243 }
244
245
246 void MathInset::dump() const
247 {
248         lyxerr << "---------------------------------------------\n";
249         write(lyxerr, false);
250         lyxerr << "\n---------------------------------------------\n";
251 }
252
253
254 void MathInset::push_back(unsigned char, MathTextCodes)
255 {
256         lyxerr << "can't push without a cell\n";
257 }
258
259
260 void MathInset::push_back(MathInset *)
261 {
262         lyxerr << "can't push without a cell\n";
263 }
264
265
266 bool MathInset::covers(int x, int y) const
267 {
268         //lyxerr << "cover? p: " << this << " x: " << x << " y: " <<  y
269         //      << " xo_: " << xo_ << " yo_: " << yo_  << endl;
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 }