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_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"
42 int MathInset::height() const
44 return ascent() + descent();
48 ostream & operator<<(ostream & os, MathAtom const & at)
50 WriteStream wi(os, false, false);
56 MathInset::size_type MathInset::nargs() const
62 Dimension MathInset::dimensions() const
64 lyxerr << "call MathInset::dimensions()\n";
65 return Dimension(width(), ascent(), descent());
71 MathArray & MathInset::cell(idx_type)
73 lyxerr << "I don't have a cell 1\n";
78 MathArray const & MathInset::cell(idx_type) const
80 lyxerr << "I don't have a cell 2\n";
85 MathInset::idx_type MathInset::index(row_type row, col_type col) const
88 lyxerr << "illegal row: " << row << "\n";
90 lyxerr << "illegal col: " << col << "\n";
94 void MathInset::substitute(MathMacro const &)
98 bool MathInset::idxNext(idx_type &, pos_type &) const
104 bool MathInset::idxRight(idx_type &, pos_type &) const
110 bool MathInset::idxPrev(idx_type &, pos_type &) const
116 bool MathInset::idxLeft(idx_type &, pos_type &) const
122 bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
128 bool MathInset::idxFirst(idx_type &, pos_type &) const
134 bool MathInset::idxLast(idx_type &, pos_type &) const
140 bool MathInset::idxHome(idx_type &, pos_type &) const
146 bool MathInset::idxEnd(idx_type &, pos_type &) const
152 void MathInset::getPos(idx_type, pos_type, int & x, int & y) const
154 lyxerr << "MathInset::getPos() called directly!\n";
159 void MathInset::dump() const
161 lyxerr << "---------------------------------------------\n";
162 WriteStream wi(lyxerr, false, true);
164 lyxerr << "\n---------------------------------------------\n";
168 bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
170 return from <= idx && idx <= to;
174 void MathInset::metrics(MathMetricsInfo &) const
176 lyxerr << "MathInset::metrics() called directly!\n";
180 void MathInset::draw(MathPainterInfo &, int, int) const
182 lyxerr << "MathInset::draw() called directly!\n";
186 void MathInset::drawSelection(MathPainterInfo &,
187 idx_type, pos_type, idx_type, pos_type) const
189 lyxerr << "MathInset::drawSelection() called directly!\n";
193 void MathInset::metricsT(TextMetricsInfo const &) const
196 lyxerr << "MathInset::metricsT(Text) called directly!\n";
201 void MathInset::drawT(TextPainter &, int, int) const
204 lyxerr << "MathInset::drawT(Text) called directly!\n";
210 void MathInset::write(WriteStream & os) const
212 os << '\\' << name().c_str() << ' ';
216 void MathInset::normalize(NormalStream & os) const
218 os << '[' << name().c_str() << "] ";
222 void MathInset::octavize(OctaveStream & os) const
224 NormalStream ns(os.os());
229 void MathInset::maplize(MapleStream & os) const
231 NormalStream ns(os.os());
236 void MathInset::mathematicize(MathematicaStream & 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 const & MathInset::getType() const
276 static string t("none");
281 string MathInset::name() const
287 string asString(MathArray const & ar)
289 std::ostringstream os;
296 MathArray asArray(string const & str)
299 mathed_parse_cell(ar, str);
304 Dialogs * getDialogs()
306 return mathcursor->formula()->view()->owner()->getDialogs();
310 LyXFunc * getLyXFunc()
312 return mathcursor->formula()->view()->owner()->getLyXFunc();