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 #include "math_inset.h"
23 #include "math_scriptinset.h"
24 #include "math_mathmlstream.h"
25 #include "math_cursor.h"
26 #include "math_parser.h"
29 #include "frontends/LyXView.h"
30 #include "frontends/Dialogs.h"
31 #include "BufferView.h"
32 #include "formulabase.h"
37 BufferView * MathInset::view() const
41 return mathcursor->formula()->view();
45 int MathInset::height() const
47 return ascent() + descent();
51 MathInset::size_type MathInset::nargs() const
57 Dimension MathInset::dimensions() const
59 lyxerr << "call MathInset::dimensions()\n";
60 return Dimension(width(), ascent(), descent());
66 MathArray & MathInset::cell(idx_type)
68 lyxerr << "I don't have a cell 1\n";
73 MathArray const & MathInset::cell(idx_type) const
75 lyxerr << "I don't have a cell 2\n";
80 MathInset::idx_type MathInset::index(row_type row, col_type col) const
83 lyxerr << "illegal row: " << row << "\n";
85 lyxerr << "illegal col: " << col << "\n";
89 void MathInset::substitute(MathMacro const &)
93 bool MathInset::idxNext(idx_type &, pos_type &) const
99 bool MathInset::idxRight(idx_type &, pos_type &) const
105 bool MathInset::idxPrev(idx_type &, pos_type &) const
111 bool MathInset::idxLeft(idx_type &, pos_type &) const
117 bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
123 bool MathInset::idxUpDown2(idx_type &, pos_type &, bool, int) const
129 bool MathInset::idxFirst(idx_type &, pos_type &) const
135 bool MathInset::idxLast(idx_type &, pos_type &) const
141 bool MathInset::idxHome(idx_type &, pos_type &) const
147 bool MathInset::idxEnd(idx_type &, pos_type &) const
153 void MathInset::getPos(idx_type, pos_type, int & x, int & y) const
155 lyxerr << "MathInset::getPos() called directly!\n";
160 void MathInset::dump() const
162 lyxerr << "---------------------------------------------\n";
163 WriteStream wi(lyxerr, false, true);
165 lyxerr << "\n---------------------------------------------\n";
169 bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
171 return from <= idx && idx <= to;
175 void MathInset::metrics(MetricsInfo &) const
177 lyxerr << "MathInset::metrics() called directly!\n";
181 void MathInset::draw(PainterInfo &, int, int) const
183 lyxerr << "MathInset::draw() called directly!\n";
187 void MathInset::drawSelection(PainterInfo &,
188 idx_type, pos_type, idx_type, pos_type) const
190 lyxerr << "MathInset::drawSelection() called directly!\n";
194 void MathInset::metricsT(TextMetricsInfo const &) const
197 lyxerr << "MathInset::metricsT(Text) called directly!\n";
202 void MathInset::drawT(TextPainter &, int, int) const
205 lyxerr << "MathInset::drawT(Text) called directly!\n";
211 void MathInset::write(WriteStream & os) const
213 os << '\\' << name().c_str();
214 os.pendingSpace(true);
218 void MathInset::normalize(NormalStream & os) const
220 os << '[' << name().c_str() << "] ";
224 void MathInset::octave(OctaveStream & os) const
226 NormalStream ns(os.os());
231 void MathInset::maple(MapleStream & os) const
233 NormalStream ns(os.os());
238 void MathInset::maxima(MaximaStream & os) const
240 MapleStream ns(os.os());
245 void MathInset::mathematica(MathematicaStream & os) const
247 NormalStream ns(os.os());
252 void MathInset::mathmlize(MathMLStream & os) const
254 NormalStream ns(os.os());
259 int MathInset::ascii(std::ostream &, int) const
265 int MathInset::linuxdoc(std::ostream &) const
271 int MathInset::docbook(std::ostream &, bool) const
277 string const & MathInset::getType() const
279 static string const t("none");
284 string MathInset::name() const
290 string asString(MathArray const & ar)
292 std::ostringstream os;
295 return STRCONV(os.str());
299 MathArray asArray(string const & str)
302 mathed_parse_cell(ar, str);
307 ostream & operator<<(ostream & os, MathAtom const & at)
309 WriteStream wi(os, false, false);
315 string MathInset::fileInsetLabel() const