]> git.lyx.org Git - features.git/blob - src/mathed/math_inset.C
f8e45759743f4197364504f9b3bdcd61e79746b2
[features.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 void MathInset::writeNormal(std::ostream & os) const
193 {
194         os << "[unknown ";
195         MathWriteInfo wi(0, os, false);
196         write(wi);
197         os << "] ";
198 }
199
200
201 void MathInset::dump() const
202 {
203         lyxerr << "---------------------------------------------\n";
204         MathWriteInfo wi(0, lyxerr, false);
205         write(wi);
206         lyxerr << "\n---------------------------------------------\n";
207 }
208
209
210 bool MathInset::covers(int x, int y) const
211 {
212         //lyxerr << "cover? p: " << this << " x: " << x << " y: " <<  y
213         //      << " xo_: " << xo_ << " yo_: " << yo_  << endl;
214         return
215                 x >= xo_ &&
216                 x <= xo_ + width() &&
217                 y >= yo_ - ascent() &&
218                 y <= yo_ + descent();
219 }
220
221
222 void MathInset::validate(LaTeXFeatures &) const
223 {}
224
225
226 std::vector<MathInset::idx_type>
227         MathInset::idxBetween(idx_type from, idx_type to) const
228 {
229         std::vector<idx_type> res;
230         for (idx_type i = from; i <= to; ++i)
231                 res.push_back(i);
232         return res;
233 }
234
235
236 void MathInset::metrics(MathMetricsInfo const &) const
237 {
238         lyxerr << "MathInset::metrics() called directly!\n";
239 }
240
241
242 void MathInset::draw(Painter &, int, int) const
243 {
244         lyxerr << "MathInset::draw() called directly!\n";
245 }
246
247
248 void MathInset::write(MathWriteInfo &) const
249 {
250         lyxerr << "MathInset::write() called directly!\n";
251 }