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.
21 #pragma implementation
24 #include "math_inset.h"
26 #include "math_scriptinset.h"
27 #include "math_mathmlstream.h"
28 #include "math_cursor.h"
29 #include "math_parser.h"
32 #include "frontends/LyXView.h"
33 #include "frontends/Dialogs.h"
34 #include "BufferView.h"
35 #include "formulabase.h"
40 int MathInset::height() const
42 return ascent() + descent();
46 MathInset::size_type MathInset::nargs() const
52 Dimension MathInset::dimensions() const
54 lyxerr << "call MathInset::dimensions()\n";
55 return Dimension(width(), ascent(), descent());
61 MathArray & MathInset::cell(idx_type)
63 lyxerr << "I don't have a cell 1\n";
68 MathArray const & MathInset::cell(idx_type) const
70 lyxerr << "I don't have a cell 2\n";
75 MathInset::idx_type MathInset::index(row_type row, col_type col) const
78 lyxerr << "illegal row: " << row << "\n";
80 lyxerr << "illegal col: " << col << "\n";
84 void MathInset::substitute(MathMacro const &)
88 bool MathInset::idxNext(idx_type &, pos_type &) const
94 bool MathInset::idxRight(idx_type &, pos_type &) const
100 bool MathInset::idxPrev(idx_type &, pos_type &) const
106 bool MathInset::idxLeft(idx_type &, pos_type &) const
112 bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
118 bool MathInset::idxFirst(idx_type &, pos_type &) const
124 bool MathInset::idxLast(idx_type &, pos_type &) const
130 bool MathInset::idxHome(idx_type &, pos_type &) const
136 bool MathInset::idxEnd(idx_type &, pos_type &) const
142 void MathInset::getPos(idx_type, pos_type, int & x, int & y) const
144 lyxerr << "MathInset::getPos() called directly!\n";
149 void MathInset::dump() const
151 lyxerr << "---------------------------------------------\n";
152 WriteStream wi(lyxerr, false, true);
154 lyxerr << "\n---------------------------------------------\n";
158 bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
160 return from <= idx && idx <= to;
164 void MathInset::metrics(MathMetricsInfo &) const
166 lyxerr << "MathInset::metrics() called directly!\n";
170 void MathInset::draw(MathPainterInfo &, int, int) const
172 lyxerr << "MathInset::draw() called directly!\n";
176 void MathInset::drawSelection(MathPainterInfo &,
177 idx_type, pos_type, idx_type, pos_type) const
179 lyxerr << "MathInset::drawSelection() called directly!\n";
183 void MathInset::metricsT(TextMetricsInfo const &) const
186 lyxerr << "MathInset::metricsT(Text) called directly!\n";
191 void MathInset::drawT(TextPainter &, int, int) const
194 lyxerr << "MathInset::drawT(Text) called directly!\n";
200 void MathInset::write(WriteStream & os) const
202 os << '\\' << name().c_str();
203 os.pendingSpace(true);
207 void MathInset::normalize(NormalStream & os) const
209 os << '[' << name().c_str() << "] ";
213 void MathInset::octavize(OctaveStream & os) const
215 NormalStream ns(os.os());
220 void MathInset::maplize(MapleStream & os) const
222 NormalStream ns(os.os());
227 void MathInset::maximize(MaximaStream & os) const
229 MapleStream ns(os.os());
234 void MathInset::mathematicize(MathematicaStream & os) const
236 NormalStream ns(os.os());
241 void MathInset::mathmlize(MathMLStream & os) const
243 NormalStream ns(os.os());
248 int MathInset::ascii(std::ostream &, int) const
254 int MathInset::linuxdoc(std::ostream &) const
260 int MathInset::docbook(std::ostream &, bool) const
266 MathInset::result_type
267 MathInset::dispatch(FuncRequest const &, idx_type &, pos_type &)
273 string const & MathInset::getType() const
275 static string t("none");
280 string MathInset::name() const
286 string asString(MathArray const & ar)
288 std::ostringstream os;
291 return STRCONV(os.str());
295 MathArray asArray(string const & str)
298 mathed_parse_cell(ar, str);
303 ostream & operator<<(ostream & os, MathAtom const & at)
305 WriteStream wi(os, false, false);
311 Dialogs & getDialogs()
313 return mathcursor->formula()->view()->owner()->getDialogs();