/*
* File: math_inset.C
* Purpose: Implementation of insets for mathed
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
- * Description:
+ * Description:
*
* Dependencies: Xlib, XForms
*
* the GNU General Public Licence version 2 or later.
*/
+#include <config.h>
+
#ifdef __GNUG__
#pragma implementation
#endif
#include "math_inset.h"
+#include "Lsstream.h"
#include "math_scriptinset.h"
+#include "math_mathmlstream.h"
+#include "math_cursor.h"
+#include "math_parser.h"
#include "debug.h"
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
+#include "BufferView.h"
+#include "formulabase.h"
-int MathInset::workwidth;
-
-
-MathInset::MathInset()
- : size_(LM_ST_DISPLAY), xo_(0), yo_(0)
-{}
-
-
-MathInset::~MathInset()
-{}
+using std::ostream;
int MathInset::height() const
}
-MathStyles MathInset::size() const
+MathInset::size_type MathInset::nargs() const
{
- return size_;
+ return 0;
}
-void MathInset::size(MathStyles s) const
+Dimension MathInset::dimensions() const
{
- size_ = s;
+ lyxerr << "call MathInset::dimensions()\n";
+ return Dimension(width(), ascent(), descent());
}
-std::ostream & operator<<(std::ostream & os, MathInset const & inset)
-{
- inset.write(os, false);
- return os;
-}
+MathArray dummyCell;
-
-int MathInset::xo() const
+MathArray & MathInset::cell(idx_type)
{
- return xo_;
+ lyxerr << "I don't have a cell 1\n";
+ return dummyCell;
}
-int MathInset::yo() const
+MathArray const & MathInset::cell(idx_type) const
{
- return yo_;
+ lyxerr << "I don't have a cell 2\n";
+ return dummyCell;
}
-void MathInset::xo(int x) const
+MathInset::idx_type MathInset::index(row_type row, col_type col) const
{
- xo_ = x;
+ if (row != 0)
+ lyxerr << "illegal row: " << row << "\n";
+ if (col != 0)
+ lyxerr << "illegal col: " << col << "\n";
+ return 0;
}
-
-void MathInset::yo(int y) const
-{
- yo_ = y;
-}
+void MathInset::substitute(MathMacro const &)
+{}
-int MathInset::nargs() const
+bool MathInset::idxNext(idx_type &, pos_type &) const
{
- return 0;
+ return false;
}
-MathXArray dummyCell;
-
-MathXArray & MathInset::xcell(int)
+bool MathInset::idxRight(idx_type &, pos_type &) const
{
- lyxerr << "I don't have a cell\n";
- return dummyCell;
+ return false;
}
-MathXArray const & MathInset::xcell(int) const
+bool MathInset::idxPrev(idx_type &, pos_type &) const
{
- lyxerr << "I don't have a cell\n";
- return dummyCell;
+ return false;
}
-MathArray & MathInset::cell(int)
+bool MathInset::idxLeft(idx_type &, pos_type &) const
{
- lyxerr << "I don't have a cell\n";
- return dummyCell.data_;
+ return false;
}
-MathArray const & MathInset::cell(int) const
+bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
{
- lyxerr << "I don't have a cell\n";
- return dummyCell.data_;
+ return false;
}
-void MathInset::substitute(MathArray & array, MathMacro const &) const
+bool MathInset::idxFirst(idx_type &, pos_type &) const
{
- array.push_back(clone());
+ return false;
}
-bool MathInset::idxNext(int &, int &) const
+bool MathInset::idxLast(idx_type &, pos_type &) const
{
return false;
}
-bool MathInset::idxRight(int &, int &) const
+bool MathInset::idxHome(idx_type &, pos_type &) const
{
return false;
}
-bool MathInset::idxPrev(int &, int &) const
+bool MathInset::idxEnd(idx_type &, pos_type &) const
{
return false;
}
-bool MathInset::idxLeft(int &, int &) const
+void MathInset::getPos(idx_type, pos_type, int & x, int & y) const
{
- return false;
+ lyxerr << "MathInset::getPos() called directly!\n";
+ x = y = 0;
}
-bool MathInset::idxUp(int &, int &) const
+void MathInset::dump() const
{
- return false;
+ lyxerr << "---------------------------------------------\n";
+ WriteStream wi(lyxerr, false, true);
+ write(wi);
+ lyxerr << "\n---------------------------------------------\n";
}
-bool MathInset::idxDown(int &, int &) const
+bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
{
- return false;
+ return from <= idx && idx <= to;
}
-bool MathInset::idxFirst(int &, int &) const
+void MathInset::metrics(MathMetricsInfo &) const
{
- return false;
+ lyxerr << "MathInset::metrics() called directly!\n";
}
-bool MathInset::idxLast(int &, int &) const
+void MathInset::draw(MathPainterInfo &, int, int) const
{
- return false;
+ lyxerr << "MathInset::draw() called directly!\n";
}
-bool MathInset::idxHome(int &, int &) const
+void MathInset::drawSelection(MathPainterInfo &,
+ idx_type, pos_type, idx_type, pos_type) const
{
- return false;
+ lyxerr << "MathInset::drawSelection() called directly!\n";
}
-bool MathInset::idxEnd(int &, int &) const
+void MathInset::metricsT(TextMetricsInfo const &) const
{
- return false;
+#ifdef WITH_WARNINGS
+ lyxerr << "MathInset::metricsT(Text) called directly!\n";
+#endif
}
-bool MathInset::idxFirstUp(int &, int &) const
+void MathInset::drawT(TextPainter &, int, int) const
{
- return false;
+#ifdef WITH_WARNINGS
+ lyxerr << "MathInset::drawT(Text) called directly!\n";
+#endif
}
-bool MathInset::idxFirstDown(int &, int &) const
+
+void MathInset::write(WriteStream & os) const
{
- return false;
+ os << '\\' << name().c_str();
+ os.pendingSpace(true);
}
-void MathInset::idxDelete(int &, bool & popit, bool & deleteit)
+void MathInset::normalize(NormalStream & os) const
{
- popit = false;
- deleteit = false;
+ os << '[' << name().c_str() << "] ";
}
-void MathInset::idxDeleteRange(int, int)
-{}
+void MathInset::octavize(OctaveStream & os) const
+{
+ NormalStream ns(os.os());
+ normalize(ns);
+}
-bool MathInset::idxLastUp(int &, int &) const
+void MathInset::maplize(MapleStream & os) const
{
- return false;
+ NormalStream ns(os.os());
+ normalize(ns);
}
-bool MathInset::idxLastDown(int &, int &) const
+void MathInset::maximize(MaximaStream & os) const
{
- return false;
+ MapleStream ns(os.os());
+ maplize(ns);
}
-void MathInset::getXY(int & x, int & y) const
+void MathInset::mathematicize(MathematicaStream & os) const
{
- x = xo();
- y = yo();
+ NormalStream ns(os.os());
+ normalize(ns);
}
-/*
-void MathInset::userSetSize(MathStyles sz)
+void MathInset::mathmlize(MathMLStream & os) const
{
- if (sz >= 0) {
- size_ = sz;
- flag = flag & ~LMPF_FIXED_SIZE;
- }
+ NormalStream ns(os.os());
+ normalize(ns);
}
-*/
-void MathInset::writeNormal(std::ostream & os) const
+
+int MathInset::ascii(std::ostream &, int) const
{
- os << "[unknown] ";
+ return 0;
}
-void MathInset::dump() const
+int MathInset::linuxdoc(std::ostream &) const
{
- lyxerr << "---------------------------------------------\n";
- write(lyxerr, false);
- lyxerr << "\n---------------------------------------------\n";
+ return 0;
}
-void MathInset::push_back(unsigned char, MathTextCodes)
+int MathInset::docbook(std::ostream &, bool) const
{
- lyxerr << "can't push without a cell\n";
+ return 0;
}
-void MathInset::push_back(MathInset *)
+MathInset::result_type
+ MathInset::dispatch(FuncRequest const &, idx_type &, pos_type &)
{
- lyxerr << "can't push without a cell\n";
+ return UNDISPATCHED;
}
-bool MathInset::covers(int x, int y) const
+string const & MathInset::getType() const
{
- //lyxerr << "cover? p: " << this << " x: " << x << " y: " << y
- // << " xo_: " << xo_ << " yo_: " << yo_ << endl;
- return
- x >= xo_ &&
- x <= xo_ + width() &&
- y >= yo_ - ascent() &&
- y <= yo_ + descent();
+ static string t("none");
+ return t;
}
-void MathInset::validate(LaTeXFeatures &) const
-{}
+string MathInset::name() const
+{
+ return "unknown";
+}
-std::vector<int> MathInset::idxBetween(int from, int to) const
+string asString(MathArray const & ar)
{
- std::vector<int> res;
- for (int i = from; i <= to; ++i)
- res.push_back(i);
- return res;
+ std::ostringstream os;
+ WriteStream ws(os);
+ ws << ar;
+ return STRCONV(os.str());
}
-void MathInset::metrics(MathStyles st) const
+MathArray asArray(string const & str)
{
- lyxerr << "MathInset::metrics() called directly!\n";
- size_ = st;
+ MathArray ar;
+ mathed_parse_cell(ar, str);
+ return ar;
}
-void MathInset::draw(Painter &, int, int) const
+ostream & operator<<(ostream & os, MathAtom const & at)
{
- lyxerr << "MathInset::draw() called directly!\n";
+ WriteStream wi(os, false, false);
+ at->write(wi);
+ return os;
}
-void MathInset::write(std::ostream &, bool) const
+Dialogs & getDialogs()
{
- lyxerr << "MathInset::write() called directly!\n";
+ return mathcursor->formula()->view()->owner()->getDialogs();
}