-/*
- * File: math_inset.C
- * Purpose: Implementation of insets for mathed
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
- * Created: January 1996
- * Description:
+/**
+ * \file math_inset.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * Dependencies: Xlib, XForms
+ * \author Alejandro Aguilar Sierra
+ * \author André Pönitz
*
- * Copyright: 1996, 1997 Alejandro Aguilar Sierra
- *
- * Version: 0.8beta.
- *
- * You are free to use and modify this code under the terms of
- * the GNU General Public Licence version 2 or later.
+ * Full author contact details are available in file CREDITS.
*/
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
#include "math_inset.h"
+#include "math_data.h"
+#include "math_mathmlstream.h"
#include "debug.h"
-
-int MathInset::workwidth;
-
-
-MathInset::MathInset(string const & name)
- : name_(name), width_(0), ascent_(0), descent_(0),
- size_(LM_ST_DISPLAY), code_(LM_TC_MIN), xo_(0), yo_(0)
-{}
-
-
-int MathInset::ascent() const
-{
- return ascent_;
-}
-
-
-int MathInset::descent() const
-{
- return descent_;
-}
-
-
-int MathInset::width() const
-{
- return width_;
-}
-
-
-int MathInset::height() const
-{
- return ascent_ + descent_;
-}
-
-
-string const & MathInset::name() const
-{
- return name_;
-}
+using std::string;
+using std::ostream;
+using std::endl;
-void MathInset::setName(string const & n)
+MathInset::size_type MathInset::nargs() const
{
- name_ = n;
-}
-
-
-MathStyles MathInset::size() const
-{
- return size_;
-}
-
-
-void MathInset::size(MathStyles s)
-{
- size_ = s;
-}
-
-
-std::ostream & operator<<(std::ostream & os, MathInset const & inset)
-{
- inset.write(os, false);
- return os;
-}
-
-
-int MathInset::xo() const
-{
- return xo_;
+ return 0;
}
-int MathInset::yo() const
-{
- return yo_;
-}
-
+MathArray dummyCell;
-void MathInset::xo(int x)
+MathArray & MathInset::cell(idx_type)
{
- xo_ = x;
+ lyxerr << "I don't have a cell 1" << endl;
+ return dummyCell;
}
-void MathInset::yo(int y)
+MathArray const & MathInset::cell(idx_type) const
{
- yo_ = y;
+ lyxerr << "I don't have a cell 2" << endl;
+ return dummyCell;
}
-int MathInset::nargs() const
+MathInset::idx_type MathInset::index(row_type row, col_type col) const
{
+ if (row != 0)
+ lyxerr << "illegal row: " << row << endl;
+ if (col != 0)
+ lyxerr << "illegal col: " << col << endl;
return 0;
}
+void MathInset::substitute(MathMacro const &)
+{}
-MathXArray dummyCell;
-MathXArray & MathInset::xcell(int)
+bool MathInset::idxNext(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::idxRight(idx_type &, pos_type &) const
{
- lyxerr << "I don't have a cell\n";
- return dummyCell;
+ return false;
}
-MathArray & MathInset::cell(int)
+bool MathInset::idxPrev(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::idxLeft(idx_type &, pos_type &) const
{
- lyxerr << "I don't have a cell\n";
- return dummyCell.data_;
+ return false;
}
-void MathInset::substitute(MathArray & array, MathMacro const &) const
+bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
{
- array.push_back(clone());
+ return false;
}
-bool MathInset::idxNext(int &, int &) const
+bool MathInset::idxUpDown2(idx_type &, pos_type &, bool, int) const
{
return false;
}
-bool MathInset::idxRight(int &, int &) const
+bool MathInset::idxFirst(idx_type &, pos_type &) const
{
return false;
}
-bool MathInset::idxPrev(int &, int &) const
+bool MathInset::idxLast(idx_type &, pos_type &) const
{
return false;
}
-bool MathInset::idxLeft(int &, int &) const
+bool MathInset::idxHome(idx_type &, pos_type &) const
{
return false;
}
-bool MathInset::idxUp(int &, int &) const
+bool MathInset::idxEnd(idx_type &, pos_type &) const
{
return false;
}
-bool MathInset::idxDown(int &, int &) const
+void MathInset::getPos(idx_type, pos_type, int & x, int & y) const
{
- return false;
+ lyxerr << "MathInset::getPos() called directly!" << endl;
+ x = y = 0;
}
-bool MathInset::idxFirst(int &, int &) const
+void MathInset::dump() const
{
- return false;
+ lyxerr << "---------------------------------------------" << endl;
+ WriteStream wi(lyxerr, false, true);
+ write(wi);
+ lyxerr << "\n---------------------------------------------" << endl;
}
-bool MathInset::idxLast(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::idxHome(int &, int &) const
+void MathInset::drawSelection(PainterInfo &,
+ idx_type, pos_type, idx_type, pos_type) const
{
- return false;
+ lyxerr << "MathInset::drawSelection() called directly!" << endl;
}
-bool MathInset::idxEnd(int &, int &) const
+void MathInset::metricsT(TextMetricsInfo const &, Dimension &) const
{
- return false;
+#ifdef WITH_WARNINGS
+ lyxerr << "MathInset::metricsT(Text) called directly!" << endl;
+#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!" << endl;
+#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)
-{}
-
-
-bool MathInset::idxLastUp(int &, int &) const
+void MathInset::octave(OctaveStream & os) const
{
- return false;
+ NormalStream ns(os.os());
+ normalize(ns);
}
-bool MathInset::idxLastDown(int &, int &) const
+void MathInset::maple(MapleStream & os) const
{
- return false;
+ NormalStream ns(os.os());
+ normalize(ns);
}
-void MathInset::getXY(int & x, int & y) const
+void MathInset::maxima(MaximaStream & os) const
{
- x = xo();
- y = yo();
+ MapleStream ns(os.os());
+ maple(ns);
}
-/*
-void MathInset::userSetSize(MathStyles sz)
+void MathInset::mathematica(MathematicaStream & 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
+
+void MathInset::mathmlize(MathMLStream & os) const
{
- os << "[" << name_ << "] ";
+ NormalStream ns(os.os());
+ normalize(ns);
}
-void MathInset::dump() const
+int MathInset::plaintext(std::ostream &, OutputParams const &) const
{
- lyxerr << "---------------------------------------------\n";
- write(lyxerr, false);
- lyxerr << "\n---------------------------------------------\n";
+ return 0;
}
-void MathInset::push_back(unsigned char, MathTextCodes)
+int MathInset::linuxdoc(std::ostream &, OutputParams const &) const
{
- lyxerr << "can't push without a cell\n";
+ return 0;
}
-void MathInset::push_back(MathInset * p)
+int MathInset::docbook(std::ostream &, OutputParams const &) const
{
- lyxerr << "can't push without a cell\n";
+ return 0;
}
-bool MathInset::covers(int x, int y) const
+string const & MathInset::getType() const
{
- return
- x >= xo_ &&
- x <= xo_ + width_ &&
- y >= yo_ - ascent_ &&
- y <= yo_ + descent_;
+ static string const t("none");
+ return t;
}
-void MathInset::validate(LaTeXFeatures &) const
-{}
-
-
-std::vector<int> MathInset::idxBetween(int from, int to) const
+string MathInset::name() const
{
- std::vector<int> res;
- for (int i = from; i <= to; ++i)
- res.push_back(i);
- return res;
+ return "unknown";
}
-MathTextCodes MathInset::code() const
+ostream & operator<<(ostream & os, MathAtom const & at)
{
- return code_;
+ WriteStream wi(os, false, false);
+ at->write(wi);
+ return os;
}
-void MathInset::code(MathTextCodes t)
+string MathInset::fileInsetLabel() const
{
- code_ = t;
+ return "Formula";
}