]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
b4e340b5086c9cee2ede07458ca95a14fdce3924
[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 MathInset::size_type MathInset::nargs() const
89 {
90         return 0;
91 }
92
93
94 MathXArray dummyCell;
95
96 MathXArray & MathInset::xcell(idx_type)
97 {
98         lyxerr << "I don't have a cell\n";
99         return dummyCell;
100 }
101
102
103 MathXArray const & MathInset::xcell(idx_type) const
104 {
105         lyxerr << "I don't have a cell\n";
106         return dummyCell;
107 }
108
109
110 MathArray & MathInset::cell(idx_type)
111 {
112         lyxerr << "I don't have a cell\n";
113         return dummyCell.data_;
114 }
115
116
117 MathArray const & MathInset::cell(idx_type) 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(idx_type &, pos_type &) const
129 {
130         return false;
131 }
132
133
134 bool MathInset::idxRight(idx_type &, pos_type &) const
135 {
136         return false;
137 }
138
139
140 bool MathInset::idxPrev(idx_type &, pos_type &) const
141 {
142         return false;
143 }
144
145
146 bool MathInset::idxLeft(idx_type &, pos_type &) const
147 {
148         return false;
149 }
150
151
152 bool MathInset::idxUp(idx_type &, pos_type &) const
153 {
154         return false;
155 }
156
157
158 bool MathInset::idxDown(idx_type &, pos_type &) const
159 {
160         return false;
161 }
162
163
164 bool MathInset::idxFirst(idx_type &, pos_type &) const
165 {
166         return false;
167 }
168
169
170 bool MathInset::idxLast(idx_type &, pos_type &) const
171 {
172         return false;
173 }
174
175
176 bool MathInset::idxHome(idx_type &, pos_type &) const
177 {
178         return false;
179 }
180
181
182 bool MathInset::idxEnd(idx_type &, pos_type &) const
183 {
184         return false;
185 }
186
187
188 void MathInset::idxDelete(idx_type &, bool & popit, bool & deleteit)
189 {
190         popit    = false;
191         deleteit = false;
192 }
193
194
195 void MathInset::idxDeleteRange(idx_type, idx_type)
196 {}
197
198
199 void MathInset::getXY(int & x, int & y) const
200 {
201    x = xo();
202    y = yo();
203 }
204
205
206 /*
207 void MathInset::userSetSize(MathStyles sz)
208 {
209         if (sz >= 0) {
210                 size_ = sz;      
211                 flag = flag & ~LMPF_FIXED_SIZE;
212         }
213 }
214 */
215
216 void MathInset::writeNormal(std::ostream & os) const
217 {
218         os << "[unknown ";
219         write(os, false);
220         os << "] ";
221 }
222
223
224 void MathInset::dump() const
225 {
226         lyxerr << "---------------------------------------------\n";
227         write(lyxerr, false);
228         lyxerr << "\n---------------------------------------------\n";
229 }
230
231
232 void MathInset::push_back(unsigned char, MathTextCodes)
233 {
234         lyxerr << "can't push without a cell\n";
235 }
236
237
238 void MathInset::push_back(MathInset *)
239 {
240         lyxerr << "can't push without a cell\n";
241 }
242
243
244 bool MathInset::covers(int x, int y) const
245 {
246         //lyxerr << "cover? p: " << this << " x: " << x << " y: " <<  y
247         //      << " xo_: " << xo_ << " yo_: " << yo_  << endl;
248         return
249                 x >= xo_ &&
250                 x <= xo_ + width() &&
251                 y >= yo_ - ascent() &&
252                 y <= yo_ + descent();
253 }
254
255
256 void MathInset::validate(LaTeXFeatures &) const
257 {}
258
259
260 std::vector<MathInset::idx_type>
261         MathInset::idxBetween(idx_type from, idx_type to) const
262 {
263         std::vector<idx_type> res;
264         for (idx_type i = from; i <= to; ++i)
265                 res.push_back(i);
266         return res;
267 }
268
269
270 void MathInset::metrics(MathStyles st) const
271 {
272         lyxerr << "MathInset::metrics() called directly!\n";
273         size_ = st;
274 }
275
276
277 void MathInset::draw(Painter &, int, int) const
278 {
279         lyxerr << "MathInset::draw() called directly!\n";
280 }
281
282
283 void MathInset::write(std::ostream &, bool) const
284 {
285         lyxerr << "MathInset::write() called directly!\n";
286 }