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