]> git.lyx.org Git - lyx.git/blob - src/mathed/math_inset.C
fonts as insets
[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 <config.h>
23
24 #include "Lsstream.h"
25 #include "math_inset.h"
26 #include "math_scriptinset.h"
27 #include "math_mathmlstream.h"
28 #include "debug.h"
29
30
31 using std::ostream;
32 using std::vector;
33
34
35 int MathInset::height() const
36 {
37         return ascent() + descent();
38 }
39
40
41 ostream & operator<<(ostream & os, MathAtom const & at)
42 {
43         if (at.nucleus())
44                 os << *(at.nucleus());
45         else
46                 os << "(nil)";
47         return os;
48 }
49
50
51 ostream & operator<<(ostream & os, MathInset const & inset)
52 {
53         WriteStream wi(os, false, false);
54         inset.write(wi);
55         return os;
56 }
57
58 MathInset::size_type MathInset::nargs() const
59 {
60         return 0;
61 }
62
63
64 MathXArray dummyCell;
65
66 MathXArray & MathInset::xcell(idx_type)
67 {
68         lyxerr << "I don't have a cell 1\n";
69         return dummyCell;
70 }
71
72
73 MathXArray const & MathInset::xcell(idx_type) const
74 {
75         lyxerr << "I don't have a cell 2\n";
76         return dummyCell;
77 }
78
79
80 MathArray & MathInset::cell(idx_type)
81 {
82         lyxerr << "I don't have a cell 3\n";
83         return dummyCell.data_;
84 }
85
86
87 MathArray const & MathInset::cell(idx_type) const
88 {
89         lyxerr << "I don't have a cell 4\n";
90         return dummyCell.data_;
91 }
92
93
94 MathInset::idx_type MathInset::index(row_type row, col_type col) const
95 {
96         if (row != 0)
97                 lyxerr << "illegal row: " << row << "\n";
98         if (col != 0)
99                 lyxerr << "illegal col: " << col << "\n";
100         return 0;
101 }
102
103 void MathInset::substitute(MathMacro const &)
104 {}
105
106
107 bool MathInset::idxNext(idx_type &, pos_type &) const
108 {
109         return false;
110 }
111
112
113 bool MathInset::idxRight(idx_type &, pos_type &) const
114 {
115         return false;
116 }
117
118
119 bool MathInset::idxPrev(idx_type &, pos_type &) const
120 {
121         return false;
122 }
123
124
125 bool MathInset::idxLeft(idx_type &, pos_type &) const
126 {
127         return false;
128 }
129
130
131 bool MathInset::idxUpDown(idx_type &, bool) const
132 {
133         return false;
134 }
135
136
137 bool MathInset::idxFirst(idx_type &, pos_type &) const
138 {
139         return false;
140 }
141
142
143 bool MathInset::idxLast(idx_type &, pos_type &) const
144 {
145         return false;
146 }
147
148
149 bool MathInset::idxHome(idx_type &, pos_type &) const
150 {
151         return false;
152 }
153
154
155 bool MathInset::idxEnd(idx_type &, pos_type &) const
156 {
157         return false;
158 }
159
160
161 void MathInset::normalize(NormalStream & os) const
162 {
163         os << "[unknown ";
164         WriteStream wi(os.os(), false, true);
165         write(wi);
166         os << "] ";
167 }
168
169
170 void MathInset::dump() const
171 {
172         lyxerr << "---------------------------------------------\n";
173         WriteStream wi(lyxerr, false, true);
174         write(wi);
175         lyxerr << "\n---------------------------------------------\n";
176 }
177
178
179 void MathInset::validate(LaTeXFeatures &) const
180 {}
181
182
183 vector<MathInset::idx_type>
184         MathInset::idxBetween(idx_type from, idx_type to) const
185 {
186         vector<idx_type> res;
187         for (idx_type i = from; i <= to; ++i)
188                 res.push_back(i);
189         return res;
190 }
191
192
193 void MathInset::metrics(MathMetricsInfo &) const
194 {
195         lyxerr << "MathInset::metrics() called directly!\n";
196 }
197
198
199 void MathInset::draw(MathPainterInfo &, int, int) const
200 {
201         lyxerr << "MathInset::draw() called directly!\n";
202 }
203
204
205 void MathInset::metricsT(TextMetricsInfo const &) const
206 {
207 #ifdef WITH_WARNINGS
208         lyxerr << "MathInset::metricsT(Text) called directly!\n";
209 #endif
210 }
211
212
213 void MathInset::drawT(TextPainter &, int, int) const
214 {
215 #ifdef WITH_WARNINGS
216         lyxerr << "MathInset::drawT(Text) called directly!\n";
217 #endif
218 }
219
220
221
222 void MathInset::write(WriteStream &) const
223 {
224         lyxerr << "MathInset::write() called directly!\n";
225 }
226
227
228 void MathInset::octavize(OctaveStream & os) const
229 {
230         NormalStream ns(os.os());
231         normalize(ns);
232 }
233
234
235 void MathInset::maplize(MapleStream & os) const
236 {
237         NormalStream ns(os.os());
238         normalize(ns);
239 }
240
241
242 void MathInset::mathmlize(MathMLStream & os) const
243 {
244         NormalStream ns(os.os());
245         normalize(ns);
246 }