3 * Purpose: Implementation of insets for mathed
4 * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
5 * Created: January 1996
8 * Dependencies: Xlib, XForms
10 * Copyright: 1996, 1997 Alejandro Aguilar Sierra
14 * You are free to use and modify this code under the terms of
15 * the GNU General Public Licence version 2 or later.
19 #pragma implementation
25 #include "math_inset.h"
26 #include "math_scriptinset.h"
27 #include "math_charinset.h"
28 #include "math_mathmlstream.h"
36 int MathInset::height() const
38 return ascent() + descent();
42 ostream & operator<<(ostream & os, MathAtom const & at)
45 os << *(at.nucleus());
52 ostream & operator<<(ostream & os, MathInset const & inset)
54 WriteStream wi(os, false, false);
59 MathInset::size_type MathInset::nargs() const
67 MathXArray & MathInset::xcell(idx_type)
69 lyxerr << "I don't have a cell 1\n";
74 MathXArray const & MathInset::xcell(idx_type) const
76 lyxerr << "I don't have a cell 2\n";
81 MathArray & MathInset::cell(idx_type)
83 lyxerr << "I don't have a cell 3\n";
84 return dummyCell.data_;
88 MathArray const & MathInset::cell(idx_type) const
90 lyxerr << "I don't have a cell 4\n";
91 return dummyCell.data_;
95 MathInset::idx_type MathInset::index(row_type row, col_type col) const
98 lyxerr << "illegal row: " << row << "\n";
100 lyxerr << "illegal col: " << col << "\n";
104 void MathInset::substitute(MathMacro const &)
108 bool MathInset::idxNext(idx_type &, pos_type &) const
114 bool MathInset::idxRight(idx_type &, pos_type &) const
120 bool MathInset::idxPrev(idx_type &, pos_type &) const
126 bool MathInset::idxLeft(idx_type &, pos_type &) const
132 bool MathInset::idxUpDown(idx_type &, bool) const
138 bool MathInset::idxFirst(idx_type &, pos_type &) const
144 bool MathInset::idxLast(idx_type &, pos_type &) const
150 bool MathInset::idxHome(idx_type &, pos_type &) const
156 bool MathInset::idxEnd(idx_type &, pos_type &) const
162 void MathInset::normalize(NormalStream & os) const
165 WriteStream wi(os.os(), false, true);
171 void MathInset::dump() const
173 lyxerr << "---------------------------------------------\n";
174 WriteStream wi(lyxerr, false, true);
176 lyxerr << "\n---------------------------------------------\n";
180 void MathInset::validate(LaTeXFeatures &) const
184 vector<MathInset::idx_type>
185 MathInset::idxBetween(idx_type from, idx_type to) const
187 vector<idx_type> res;
188 for (idx_type i = from; i <= to; ++i)
194 void MathInset::metrics(MathMetricsInfo &) const
196 lyxerr << "MathInset::metrics() called directly!\n";
200 void MathInset::draw(MathPainterInfo &, int, int) const
202 lyxerr << "MathInset::draw() called directly!\n";
206 void MathInset::metricsT(TextMetricsInfo const &) const
209 lyxerr << "MathInset::metricsT(Text) called directly!\n";
214 void MathInset::drawT(TextPainter &, int, int) const
217 lyxerr << "MathInset::drawT(Text) called directly!\n";
223 void MathInset::write(WriteStream &) const
225 lyxerr << "MathInset::write() called directly!\n";
229 void MathInset::octavize(OctaveStream & os) const
231 NormalStream ns(os.os());
236 void MathInset::maplize(MapleStream & os) const
238 NormalStream ns(os.os());
243 void MathInset::mathmlize(MathMLStream & os) const
245 NormalStream ns(os.os());
250 int MathInset::ascii(std::ostream &, int) const
256 int MathInset::linuxdoc(std::ostream &) const
262 int MathInset::docbook(std::ostream &, bool) const
268 int MathInset::dispatch(string const &, idx_type, pos_type)
270 return 0; // undispatched
274 string asString(MathArray const & ar)
277 for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
278 if ((*it)->getChar())
279 res += (*it)->getChar();
284 MathArray asArray(string const & str)
287 for (string::const_iterator it = str.begin(); it != str.end(); ++it)
288 ar.push_back(MathAtom(new MathCharInset(*it)));