/*
* 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
*
#pragma implementation
#endif
-#include "math_iter.h"
#include "math_inset.h"
-#include "symbol_def.h"
-#include "lyxfont.h"
-#include "mathed/support.h"
-#include "Painter.h"
+#include "Lsstream.h"
+#include "math_scriptinset.h"
+#include "math_mathmlstream.h"
+#include "math_cursor.h"
+#include "math_parser.h"
+#include "debug.h"
-int MathedInset::df_asc;
-int MathedInset::df_des;
-int MathedInset::df_width;
-int MathedInset::workWidth;
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
+#include "BufferView.h"
+#include "formulabase.h"
+using std::ostream;
-MathedInset::MathedInset(MathedInset * inset)
+
+int MathInset::height() const
+{
+ return ascent() + descent();
+}
+
+
+MathInset::size_type MathInset::nargs() const
+{
+ return 0;
+}
+
+
+Dimension MathInset::dimensions() const
+{
+ lyxerr << "call MathInset::dimensions()\n";
+ return Dimension(width(), ascent(), descent());
+}
+
+
+MathArray dummyCell;
+
+MathArray & MathInset::cell(idx_type)
{
- if (inset) {
- name = inset->GetName();
- objtype = inset->GetType();
- size_ = inset->GetStyle();
- width = inset->Width();
- ascent = inset->Ascent();
- descent = inset->Descent();
- } else {
- objtype = LM_OT_UNDEF;
- size_ = LM_ST_TEXT;
- width = ascent = descent = 0;
- //name = 0;
- }
+ lyxerr << "I don't have a cell 1\n";
+ return dummyCell;
}
-MathedInset::MathedInset(string const & nm, short ot, short st)
- : name(nm), objtype(ot), size_(st)
+MathArray const & MathInset::cell(idx_type) const
{
- width = ascent = descent = 0;
+ lyxerr << "I don't have a cell 2\n";
+ return dummyCell;
}
-// In a near future maybe we use a better fonts renderer
-void MathedInset::drawStr(Painter & pain, short type, int siz,
- int x, int y, string const & s)
+MathInset::idx_type MathInset::index(row_type row, col_type col) const
{
- string st;
- if (MathIsBinary(type))
- for (string::const_iterator it = s.begin();
- it != s.end(); ++it) {
- st += ' ';
- st += *it;
- st += ' ';
- }
- else
- st = s;
-
- LyXFont const mf = mathed_get_font(type, siz);
- pain.text(x, y, st, mf);
+ if (row != 0)
+ lyxerr << "illegal row: " << row << "\n";
+ if (col != 0)
+ lyxerr << "illegal col: " << col << "\n";
+ return 0;
}
+void MathInset::substitute(MathMacro const &)
+{}
+
-int MathedInset::Ascent() const
+bool MathInset::idxNext(idx_type &, pos_type &) const
{
- return ascent;
+ return false;
}
-int MathedInset::Descent() const
+bool MathInset::idxRight(idx_type &, pos_type &) const
{
- return descent;
+ return false;
}
-int MathedInset::Width() const
+bool MathInset::idxPrev(idx_type &, pos_type &) const
{
- return width;
+ return false;
}
-int MathedInset::Height() const
+bool MathInset::idxLeft(idx_type &, pos_type &) const
{
- return ascent + descent;
+ return false;
}
-bool MathedInset::GetLimits() const
+bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
{
return false;
}
-void MathedInset::SetLimits(bool) {}
+bool MathInset::idxFirst(idx_type &, pos_type &) const
+{
+ return false;
+}
+
+
+bool MathInset::idxLast(idx_type &, pos_type &) const
+{
+ return false;
+}
+
+
+bool MathInset::idxHome(idx_type &, pos_type &) const
+{
+ return false;
+}
+
+
+bool MathInset::idxEnd(idx_type &, pos_type &) const
+{
+ return false;
+}
+
+
+void MathInset::getPos(idx_type, pos_type, int & x, int & y) const
+{
+ lyxerr << "MathInset::getPos() called directly!\n";
+ x = y = 0;
+}
+
+
+void MathInset::dump() const
+{
+ lyxerr << "---------------------------------------------\n";
+ WriteStream wi(lyxerr, false, true);
+ write(wi);
+ lyxerr << "\n---------------------------------------------\n";
+}
+
+
+bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
+{
+ return from <= idx && idx <= to;
+}
+
+
+void MathInset::metrics(MathMetricsInfo &) const
+{
+ lyxerr << "MathInset::metrics() called directly!\n";
+}
+
+
+void MathInset::draw(MathPainterInfo &, int, int) const
+{
+ lyxerr << "MathInset::draw() called directly!\n";
+}
+
+
+void MathInset::drawSelection(MathPainterInfo &,
+ idx_type, pos_type, idx_type, pos_type) const
+{
+ lyxerr << "MathInset::drawSelection() called directly!\n";
+}
+
+
+void MathInset::metricsT(TextMetricsInfo const &) const
+{
+#ifdef WITH_WARNINGS
+ lyxerr << "MathInset::metricsT(Text) called directly!\n";
+#endif
+}
-string const & MathedInset::GetName() const
+void MathInset::drawT(TextPainter &, int, int) const
{
- return name;
+#ifdef WITH_WARNINGS
+ lyxerr << "MathInset::drawT(Text) called directly!\n";
+#endif
}
-short MathedInset::GetType() const
+
+void MathInset::write(WriteStream & os) const
{
- return objtype;
+ os << '\\' << name().c_str();
+ os.pendingSpace(true);
}
-short MathedInset::GetStyle() const
+void MathInset::normalize(NormalStream & os) const
{
- return size_;
+ os << '[' << name().c_str() << "] ";
}
-void MathedInset::SetType(short t)
+void MathInset::octavize(OctaveStream & os) const
{
- objtype = t;
+ NormalStream ns(os.os());
+ normalize(ns);
}
-void MathedInset::SetStyle(short st)
+void MathInset::maplize(MapleStream & os) const
{
- size_ = st;
+ NormalStream ns(os.os());
+ normalize(ns);
}
-void MathedInset::SetName(string const & n)
+void MathInset::maximize(MaximaStream & os) const
{
- name = n;
+ MapleStream ns(os.os());
+ maplize(ns);
}
-void MathedInset::defaultAscent(int da)
+void MathInset::mathematicize(MathematicaStream & os) const
{
- df_asc = da;
+ NormalStream ns(os.os());
+ normalize(ns);
}
+void MathInset::mathmlize(MathMLStream & os) const
+{
+ NormalStream ns(os.os());
+ normalize(ns);
+}
+
-void MathedInset::defaultDescent(int dd)
+int MathInset::ascii(std::ostream &, int) const
{
- df_des = dd;
+ return 0;
}
-void MathedInset::defaultWidth(int dw)
+int MathInset::linuxdoc(std::ostream &) const
{
- df_width = dw;
+ return 0;
}
+
+int MathInset::docbook(std::ostream &, bool) const
+{
+ return 0;
+}
+
+
+MathInset::result_type
+ MathInset::dispatch(FuncRequest const &, idx_type &, pos_type &)
+{
+ return UNDISPATCHED;
+}
+
+
+string const & MathInset::getType() const
+{
+ static string t("none");
+ return t;
+}
+
+
+string MathInset::name() const
+{
+ return "unknown";
+}
+
+
+string asString(MathArray const & ar)
+{
+ std::ostringstream os;
+ WriteStream ws(os);
+ ws << ar;
+ return STRCONV(os.str());
+}
+
+
+MathArray asArray(string const & str)
+{
+ MathArray ar;
+ mathed_parse_cell(ar, str);
+ return ar;
+}
+
+
+ostream & operator<<(ostream & os, MathAtom const & at)
+{
+ WriteStream wi(os, false, false);
+ at->write(wi);
+ return os;
+}
+
+
+Dialogs & getDialogs()
+{
+ return mathcursor->formula()->view()->owner()->getDialogs();
+}