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::idxFirst(idx_type &, pos_type &) const
129 bool MathInset::idxLast(idx_type &, pos_type &) const
135 bool MathInset::idxHome(idx_type &, pos_type &) const
141 bool MathInset::idxEnd(idx_type &, pos_type &) const
147 void MathInset::getPos(idx_type, pos_type, int & x, int & y) const
149 lyxerr << "MathInset::getPos() called directly!\n";
154 void MathInset::dump() const
156 lyxerr << "---------------------------------------------\n";
157 WriteStream wi(lyxerr, false, true);
159 lyxerr << "\n---------------------------------------------\n";
163 bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
165 return from <= idx && idx <= to;
169 void MathInset::metrics(MetricsInfo &) const
171 lyxerr << "MathInset::metrics() called directly!\n";
175 void MathInset::draw(PainterInfo &, int, int) const
177 lyxerr << "MathInset::draw() called directly!\n";
181 void MathInset::drawSelection(PainterInfo &,
182 idx_type, pos_type, idx_type, pos_type) const
184 lyxerr << "MathInset::drawSelection() called directly!\n";
188 void MathInset::metricsT(TextMetricsInfo const &) const
191 lyxerr << "MathInset::metricsT(Text) called directly!\n";
196 void MathInset::drawT(TextPainter &, int, int) const
199 lyxerr << "MathInset::drawT(Text) called directly!\n";
205 void MathInset::write(WriteStream & os) const
207 os << '\\' << name().c_str();
208 os.pendingSpace(true);
212 void MathInset::normalize(NormalStream & os) const
214 os << '[' << name().c_str() << "] ";
218 void MathInset::octave(OctaveStream & os) const
220 NormalStream ns(os.os());
225 void MathInset::maple(MapleStream & os) const
227 NormalStream ns(os.os());
232 void MathInset::maxima(MaximaStream & os) const
234 MapleStream ns(os.os());
239 void MathInset::mathematica(MathematicaStream & os) const
241 NormalStream ns(os.os());
246 void MathInset::mathmlize(MathMLStream & os) const
248 NormalStream ns(os.os());
253 int MathInset::ascii(std::ostream &, int) const
259 int MathInset::linuxdoc(std::ostream &) const
265 int MathInset::docbook(std::ostream &, bool) const
271 string const & MathInset::getType() const
273 static string t("none");
278 string MathInset::name() const
284 string asString(MathArray const & ar)
286 std::ostringstream os;
289 return STRCONV(os.str());
293 MathArray asArray(string const & str)
296 mathed_parse_cell(ar, str);
301 ostream & operator<<(ostream & os, MathAtom const & at)
303 WriteStream wi(os, false, false);