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();
213 os.pendingSpace(true);
217 void MathInset::normalize(NormalStream & os) const
219 os << '[' << name().c_str() << "] ";
223 void MathInset::octavize(OctaveStream & os) const
225 NormalStream ns(os.os());
230 void MathInset::maplize(MapleStream & os) const
232 NormalStream ns(os.os());
237 void MathInset::mathematicize(MathematicaStream & os) const
239 NormalStream ns(os.os());
244 void MathInset::mathmlize(MathMLStream & os) const
246 NormalStream ns(os.os());
251 int MathInset::ascii(std::ostream &, int) const
257 int MathInset::linuxdoc(std::ostream &) const
263 int MathInset::docbook(std::ostream &, bool) const
269 MathInset::result_type
270 MathInset::dispatch(FuncRequest const &, idx_type &, pos_type &)
276 string const & MathInset::getType() const
278 static string t("none");
283 string MathInset::name() const
289 string asString(MathArray const & ar)
291 std::ostringstream os;
298 MathArray asArray(string const & str)
301 mathed_parse_cell(ar, str);
306 Dialogs & getDialogs()
308 return mathcursor->formula()->view()->owner()->getDialogs();