]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_inset.C
make \newcommand{\bb}[1]{\mathbf{#1}} work for read/write/display.
[lyx.git] / src / mathed / math_inset.C
index e132d5ce50bd39317aef40817b5b397005b7dad3..7b1b8cfba162b1dcdcf732f8e718d3f4ac20d679 100644 (file)
 #pragma implementation
 #endif
 
+#include <config.h>
+
+#include "Lsstream.h"
 #include "math_inset.h"
 #include "math_scriptinset.h"
+#include "math_mathmlstream.h"
 #include "debug.h"
 
 
-int MathInset::workwidth;
-
-
-MathInset::MathInset()
-       : size_(LM_ST_DISPLAY), xo_(0), yo_(0)
-{}
-
-
-MathInset::~MathInset()
-{}
-
-
 int MathInset::height() const
 {
        return ascent() + descent();
 }
 
 
-MathStyles MathInset::size() const
-{
-       return size_;
-}
-
-
-void MathInset::size(MathStyles s) const
-{
-       size_ = s;
-}
-
-
 std::ostream & operator<<(std::ostream & os, MathInset const & inset)
 {
-       inset.write(os, false);
+       WriteStream wi(os, false);
+       inset.write(wi);
        return os;
 }
 
 
-int MathInset::xo() const
-{
-       return xo_;
-}
-
-
-int MathInset::yo() const
-{
-       return yo_;
-}
-
-
-void MathInset::xo(int x) const
-{
-       xo_ = x;
-}
-
-
-void MathInset::yo(int y) const
-{
-       yo_ = y;
-}
-
-
-int MathInset::nargs() const
+MathInset::size_type MathInset::nargs() const
 {
        return 0;
 }
@@ -93,217 +50,184 @@ int MathInset::nargs() const
 
 MathXArray dummyCell;
 
-MathXArray & MathInset::xcell(int)
+MathXArray & MathInset::xcell(idx_type)
 {
-       lyxerr << "I don't have a cell\n";
+       lyxerr << "I don't have a cell 1\n";
        return dummyCell;
 }
 
 
-MathXArray const & MathInset::xcell(int) const
+MathXArray const & MathInset::xcell(idx_type) const
 {
-       lyxerr << "I don't have a cell\n";
+       lyxerr << "I don't have a cell 2\n";
        return dummyCell;
 }
 
 
-MathArray & MathInset::cell(int)
+MathArray & MathInset::cell(idx_type)
 {
-       lyxerr << "I don't have a cell\n";
+       lyxerr << "I don't have a cell 3\n";
        return dummyCell.data_;
 }
 
 
-MathArray const & MathInset::cell(int) const
+MathArray const & MathInset::cell(idx_type) const
 {
-       lyxerr << "I don't have a cell\n";
+       lyxerr << "I don't have a cell 4\n";
        return dummyCell.data_;
 }
 
 
-void MathInset::substitute(MathArray & array, MathMacro const &) const
-{
-       array.push_back(clone());
-}
-
-
-bool MathInset::idxNext(int &, int &) const
+MathInset::idx_type MathInset::index(row_type row, col_type col) const
 {
-       return false;
+       if (row != 0)
+               lyxerr << "illegal row: " << row << "\n";
+       if (col != 0)
+               lyxerr << "illegal col: " << col << "\n";
+       return 0;
 }
 
-
-bool MathInset::idxRight(int &, int &) const
-{
-       return false;
-}
+void MathInset::substitute(MathMacro const &)
+{}
 
 
-bool MathInset::idxPrev(int &, int &) const
+bool MathInset::idxNext(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxLeft(int &, int &) const
+bool MathInset::idxRight(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxUp(int &, int &) const
+bool MathInset::idxPrev(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxDown(int &, int &) const
+bool MathInset::idxLeft(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxFirst(int &, int &) const
+bool MathInset::idxUp(idx_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxLast(int &, int &) const
+bool MathInset::idxDown(idx_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxHome(int &, int &) const
+bool MathInset::idxFirst(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxEnd(int &, int &) const
+bool MathInset::idxLast(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxFirstUp(int &, int &) const
+bool MathInset::idxHome(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-bool MathInset::idxFirstDown(int &, int &) const
+bool MathInset::idxEnd(idx_type &, pos_type &) const
 {
        return false;
 }
 
 
-void MathInset::idxDelete(int &, bool & popit, bool & deleteit)
+void MathInset::idxDelete(idx_type &, bool & popit, bool & deleteit)
 {
        popit    = false;
        deleteit = false;
 }
 
 
-void MathInset::idxDeleteRange(int, int)
+void MathInset::idxDeleteRange(idx_type, idx_type)
 {}
 
 
-bool MathInset::idxLastUp(int &, int &) const
-{
-       return false;
-}
-
-
-bool MathInset::idxLastDown(int &, int &) const
-{
-       return false;
-}
-
-
-void MathInset::getXY(int & x, int & y) const
-{
-   x = xo();
-   y = yo();
-}
-
-
-/*
-void MathInset::userSetSize(MathStyles sz)
-{
-       if (sz >= 0) {
-               size_ = sz;      
-               flag = flag & ~LMPF_FIXED_SIZE;
-       }
-}
-*/
-
-void MathInset::writeNormal(std::ostream & os) const
+void MathInset::normalize(NormalStream & os) const
 {
-       os << "[unknown] ";
+       os << "[unknown ";
+       WriteStream wi(os.os(), false);
+       write(wi);
+       os << "] ";
 }
 
 
 void MathInset::dump() const
 {
        lyxerr << "---------------------------------------------\n";
-       write(lyxerr, false);
+       WriteStream wi(lyxerr, false);
+       write(wi);
        lyxerr << "\n---------------------------------------------\n";
 }
 
 
-void MathInset::push_back(unsigned char, MathTextCodes)
-{
-       lyxerr << "can't push without a cell\n";
-}
+void MathInset::validate(LaTeXFeatures &) const
+{}
 
 
-void MathInset::push_back(MathInset *)
+std::vector<MathInset::idx_type>
+       MathInset::idxBetween(idx_type from, idx_type to) const
 {
-       lyxerr << "can't push without a cell\n";
+       std::vector<idx_type> res;
+       for (idx_type i = from; i <= to; ++i)
+               res.push_back(i);
+       return res;
 }
 
 
-bool MathInset::covers(int x, int y) const
+void MathInset::metrics(MathMetricsInfo const &) 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();
+       lyxerr << "MathInset::metrics() called directly!\n";
 }
 
 
-void MathInset::validate(LaTeXFeatures &) const
-{}
+void MathInset::draw(Painter &, int, int) const
+{
+       lyxerr << "MathInset::draw() called directly!\n";
+}
 
 
-std::vector<int> MathInset::idxBetween(int from, int to) const
+void MathInset::write(WriteStream &) const
 {
-       std::vector<int> res;
-       for (int i = from; i <= to; ++i)
-               res.push_back(i);
-       return res;
+       lyxerr << "MathInset::write() called directly!\n";
 }
 
 
-void MathInset::metrics(MathStyles st) const
+void MathInset::octavize(OctaveStream & os) const
 {
-       lyxerr << "MathInset::metrics() called directly!\n";
-       size_ = st;
+       NormalStream ns(os.os());
+       normalize(ns);
 }
 
 
-void MathInset::draw(Painter &, int, int) const
+void MathInset::maplize(MapleStream & os) const
 {
-       lyxerr << "MathInset::draw() called directly!\n";
+       NormalStream ns(os.os());
+       normalize(ns);
 }
 
 
-void MathInset::write(std::ostream &, bool) const
+void MathInset::mathmlize(MathMLStream & os) const
 {
-       lyxerr << "MathInset::write() called directly!\n";
+       NormalStream ns(os.os());
+       normalize(ns);
 }