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