]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_inset.C
use a single function dimension() instead of three.
[lyx.git] / src / mathed / math_inset.C
index e132d5ce50bd39317aef40817b5b397005b7dad3..428a5297137a7db2bf08699341339bffa682d5ed 100644 (file)
@@ -1,9 +1,9 @@
 /*
  *  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 <config.h>
+
+#include "Lsstream.h"
 #include "math_inset.h"
 #include "math_scriptinset.h"
+#include "math_charinset.h"
+#include "math_mathmlstream.h"
+#include "math_cursor.h"
 #include "debug.h"
 
-
-int MathInset::workwidth;
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
+#include "BufferView.h"
+#include "formulabase.h"
 
 
-MathInset::MathInset()
-       : size_(LM_ST_DISPLAY), xo_(0), yo_(0)
-{}
-
-
-MathInset::~MathInset()
-{}
+using std::ostream;
+using std::vector;
 
 
 int MathInset::height() const
@@ -42,268 +45,292 @@ int MathInset::height() const
 }
 
 
-MathStyles MathInset::size() const
-{
-       return size_;
-}
-
-
-void MathInset::size(MathStyles s) const
+ostream & operator<<(ostream & os, MathAtom const & at)
 {
-       size_ = s;
+       if (at.nucleus())
+               os << *(at.nucleus());
+       else
+               os << "(nil)";
+       return os;
 }
 
 
-std::ostream & operator<<(std::ostream & os, MathInset const & inset)
+ostream & operator<<(ostream & os, MathInset const & inset)
 {
-       inset.write(os, false);
+       WriteStream wi(os, false, false);
+       inset.write(wi);
        return os;
 }
 
-
-int MathInset::xo() const
+MathInset::size_type MathInset::nargs() const
 {
-       return xo_;
+       return 0;
 }
 
 
-int MathInset::yo() const
+void MathInset::dimensions(int & w, int & a, int & d) const
 {
-       return yo_;
+       w = width();
+       a = ascent();
+       d = descent();
 }
 
 
-void MathInset::xo(int x) const
+MathXArray dummyCell;
+
+MathXArray & MathInset::xcell(idx_type)
 {
-       xo_ = x;
+       lyxerr << "I don't have a cell 1\n";
+       return dummyCell;
 }
 
 
-void MathInset::yo(int y) const
+MathXArray const & MathInset::xcell(idx_type) const
 {
-       yo_ = y;
+       lyxerr << "I don't have a cell 2\n";
+       return dummyCell;
 }
 
 
-int MathInset::nargs() const
+MathArray & MathInset::cell(idx_type)
 {
-       return 0;
+       lyxerr << "I don't have a cell 3\n";
+       return dummyCell.data();
 }
 
 
-MathXArray dummyCell;
-
-MathXArray & MathInset::xcell(int)
+MathArray const & MathInset::cell(idx_type) const
 {
-       lyxerr << "I don't have a cell\n";
-       return dummyCell;
+       lyxerr << "I don't have a cell 4\n";
+       return dummyCell.data();
 }
 
 
-MathXArray const & MathInset::xcell(int) const
+MathInset::idx_type MathInset::index(row_type row, col_type col) const
 {
-       lyxerr << "I don't have a cell\n";
-       return dummyCell;
+       if (row != 0)
+               lyxerr << "illegal row: " << row << "\n";
+       if (col != 0)
+               lyxerr << "illegal col: " << col << "\n";
+       return 0;
 }
 
+void MathInset::substitute(MathMacro const &)
+{}
+
 
-MathArray & MathInset::cell(int)
+bool MathInset::idxNext(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::idxRight(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::idxPrev(idx_type &, pos_type &) const
 {
-       array.push_back(clone());
+       return false;
 }
 
 
-bool MathInset::idxNext(int &, int &) const
+bool MathInset::idxLeft(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxRight(int &, int &) const
+bool MathInset::idxUpDown(idx_type &, bool) const
 {
        return false;
 }
 
 
-bool MathInset::idxPrev(int &, int &) const
+bool MathInset::idxFirst(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxLeft(int &, int &) const
+bool MathInset::idxLast(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxUp(int &, int &) const
+bool MathInset::idxHome(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxDown(int &, int &) const
+bool MathInset::idxEnd(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxFirst(int &, int &) const
+void MathInset::normalize(NormalStream & os) const
 {
-       return false;
+       os << "[unknown ";
+       WriteStream wi(os.os(), false, true);
+       write(wi);
+       os << "] ";
 }
 
 
-bool MathInset::idxLast(int &, int &) const
+void MathInset::dump() const
 {
-       return false;
+       lyxerr << "---------------------------------------------\n";
+       WriteStream wi(lyxerr, false, true);
+       write(wi);
+       lyxerr << "\n---------------------------------------------\n";
 }
 
 
-bool MathInset::idxHome(int &, int &) const
+void MathInset::validate(LaTeXFeatures &) const
+{}
+
+
+vector<MathInset::idx_type>
+       MathInset::idxBetween(idx_type from, idx_type to) const
 {
-       return false;
+       vector<idx_type> res;
+       for (idx_type i = from; i <= to; ++i)
+               res.push_back(i);
+       return res;
 }
 
 
-bool MathInset::idxEnd(int &, int &) const
+void MathInset::metrics(MathMetricsInfo &) const
 {
-       return false;
+       lyxerr << "MathInset::metrics() called directly!\n";
 }
 
 
-bool MathInset::idxFirstUp(int &, int &) const
+void MathInset::draw(MathPainterInfo &, int, int) const
 {
-       return false;
+       lyxerr << "MathInset::draw() called directly!\n";
 }
 
 
-bool MathInset::idxFirstDown(int &, int &) const
+void MathInset::metricsT(TextMetricsInfo const &) const
 {
-       return false;
+#ifdef WITH_WARNINGS
+       lyxerr << "MathInset::metricsT(Text) called directly!\n";
+#endif
 }
 
 
-void MathInset::idxDelete(int &, bool & popit, bool & deleteit)
+void MathInset::drawT(TextPainter &, int, int) const
 {
-       popit    = false;
-       deleteit = false;
+#ifdef WITH_WARNINGS
+       lyxerr << "MathInset::drawT(Text) called directly!\n";
+#endif
 }
 
 
-void MathInset::idxDeleteRange(int, int)
-{}
 
+void MathInset::write(WriteStream &) const
+{
+       lyxerr << "MathInset::write() called directly!\n";
+}
 
-bool MathInset::idxLastUp(int &, int &) const
+
+void MathInset::octavize(OctaveStream & os) const
 {
-       return false;
+       NormalStream ns(os.os());
+       normalize(ns);
 }
 
 
-bool MathInset::idxLastDown(int &, int &) const
+void MathInset::maplize(MapleStream & os) const
 {
-       return false;
+       NormalStream ns(os.os());
+       normalize(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 *)
+int MathInset::dispatch(string const &, idx_type, pos_type) 
 {
-       lyxerr << "can't push without a cell\n";
+       return 0; // undispatched
 }
 
 
-bool MathInset::covers(int x, int y) const
+std::vector<string> MathInset::getLabelList() 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();
+       return std::vector<string>();
 }
 
 
-void MathInset::validate(LaTeXFeatures &) const
-{}
+string const & MathInset::getType() const
+{
+       static string t("none");
+       return t;
+}
 
 
-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);
+       string res;
+       for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
+               if ((*it)->getChar())
+                       res += (*it)->getChar();
        return res;
 }
 
 
-void MathInset::metrics(MathStyles st) const
+MathArray asArray(string const & str)
 {
-       lyxerr << "MathInset::metrics() called directly!\n";
-       size_ = st;
+       MathArray ar;
+       for (string::const_iterator it = str.begin(); it != str.end(); ++it)
+               ar.push_back(MathAtom(new MathCharInset(*it)));
+       return ar;
 }
 
 
-void MathInset::draw(Painter &, int, int) const
+Dialogs * getDialogs()
 {
-       lyxerr << "MathInset::draw() called directly!\n";
+       return mathcursor->formula()->view()->owner()->getDialogs();
 }
 
 
-void MathInset::write(std::ostream &, bool) const
+LyXFunc * getLyXFunc()
 {
-       lyxerr << "MathInset::write() called directly!\n";
+       return mathcursor->formula()->view()->owner()->getLyXFunc();
 }