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