]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_inset.C
Always use std::endl with lyxerr
[lyx.git] / src / mathed / math_inset.C
index e39af4dc2a2bde97fc4886938112080998ff0869..1a9b26d3e5d3924af921f8105d1240eea70ff8fd 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
  *
  *   the GNU General Public Licence version 2 or later.
  */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
 
 #include "math_inset.h"
+#include "math_scriptinset.h"
+#include "math_mathmlstream.h"
+#include "math_cursor.h"
 #include "debug.h"
 
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
+#include "BufferView.h"
+#include "formulabase.h"
 
-int MathInset::workwidth;
-
+using std::ostream;
+using std::endl;
 
-MathInset::MathInset(int nargs, string const & name, MathInsetTypes ot)
-       : name_(name), objtype(ot), width_(0), ascent_(0), descent_(0),
-               size_(LM_ST_DISPLAY), cells_(nargs), xo_(0), yo_(0)
-{}
 
-
-int MathInset::ascent() const
+BufferView * MathInset::view() const
 {
-       return ascent_;
+       return mathcursor ? mathcursor->formula()->view() : 0;
 }
 
 
-int MathInset::descent() const
+MathInset::size_type MathInset::nargs() const
 {
-       return descent_;
+       return 0;
 }
 
 
-int MathInset::width() const
-{
-       return width_;
-}
-
+MathArray dummyCell;
 
-int MathInset::height() const
+MathArray & MathInset::cell(idx_type)
 {
-       return ascent_ + descent_;
+       lyxerr << "I don't have a cell 1" << endl;
+       return dummyCell;
 }
 
 
-int MathInset::limits() const
+MathArray const & MathInset::cell(idx_type) const
 {
-       return false;
+       lyxerr << "I don't have a cell 2" << endl;
+       return dummyCell;
 }
 
 
-void MathInset::limits(int)
+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;
 }
 
-string const & MathInset::name() const
-{
-       return name_;
-}
-
-
-MathInsetTypes MathInset::GetType() const
-{
-       return objtype;
-}
-
-
-void MathInset::SetType(MathInsetTypes t)
-{
-       objtype = t;
-}
+void MathInset::substitute(MathMacro const &)
+{}
 
 
-void MathInset::SetName(string const & n)
+bool MathInset::idxNext(idx_type &, pos_type &) const
 {
-       name_ = n;
+       return false;
 }
 
 
-MathStyles MathInset::size() const
+bool MathInset::idxRight(idx_type &, pos_type &) const
 {
-       return size_;
+       return false;
 }
 
 
-void MathInset::size(MathStyles s)
+bool MathInset::idxPrev(idx_type &, pos_type &) const
 {
-       size_ = s;
-}
-
-std::ostream & operator<<(std::ostream & os, MathInset const & inset)
-{
-       inset.Write(os, false);
-       return os;
+       return false;
 }
 
 
-int MathInset::xo() const
+bool MathInset::idxLeft(idx_type &, pos_type &) const
 {
-       return xo_;
+       return false;
 }
 
 
-int MathInset::yo() const
+bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
 {
-       return yo_;
+       return false;
 }
 
 
-void MathInset::xo(int x)
+bool MathInset::idxUpDown2(idx_type &, pos_type &, bool, int) const
 {
-       xo_ = x;
+       return false;
 }
 
 
-void MathInset::yo(int y)
+bool MathInset::idxFirst(idx_type &, pos_type &) const
 {
-       yo_ = y;
+       return false;
 }
 
 
-int MathInset::nargs() const
+bool MathInset::idxLast(idx_type &, pos_type &) const
 {
-       return cells_.size();
+       return false;
 }
 
 
-
-MathXArray & MathInset::xcell(int i)
+bool MathInset::idxHome(idx_type &, pos_type &) const
 {
-       return cells_[i];
-}
-
-MathXArray const & MathInset::xcell(int i) const
-{
-       return cells_[i];
+       return false;
 }
 
 
-
-MathArray & MathInset::cell(int i)
+bool MathInset::idxEnd(idx_type &, pos_type &) const
 {
-       return cells_[i].data_;
-}
-
-MathArray const & MathInset::cell(int i) const
-{
-       return cells_[i].data_;
+       return false;
 }
 
 
-void MathInset::substitute(MathArray & array, MathMacro const & m) const
+void MathInset::getPos(idx_type, pos_type, int & x, int & y) const
 {
-       MathInset * p = clone();
-       for (int i = 0; i < nargs(); ++i)
-               p->cell(i).substitute(m);
-       array.push_back(p);
+       lyxerr << "MathInset::getPos() called directly!" << endl;
+       x = y = 0;
 }
 
-void MathInset::Metrics(MathStyles st, int, int)
-{
-       size_ = st;
-       for (int i = 0; i < nargs(); ++i)
-               xcell(i).Metrics(st);
-}
 
-void MathInset::draw(Painter & pain, int x, int y)
+void MathInset::dump() const
 {
-       xo_ = x;
-       yo_ = y;
-       for (int i = 0; i < nargs(); ++i)
-               xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
+       lyxerr << "---------------------------------------------" << endl;
+       WriteStream wi(lyxerr, false, true);
+       write(wi);
+       lyxerr << "\n---------------------------------------------" << endl;
 }
 
 
-bool MathInset::idxNext(int & idx, int & pos) const
+bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
 {
-       if (idx + 1 >= nargs())
-               return false;
-       ++idx;
-       pos = 0;
-       return true;
+       return from <= idx && idx <= to;
 }
 
 
-bool MathInset::idxRight(int & idx, int & pos) const
+void MathInset::drawSelection(PainterInfo &,
+       idx_type, pos_type, idx_type, pos_type) const
 {
-       return idxNext(idx, pos);
+       lyxerr << "MathInset::drawSelection() called directly!" << endl;
 }
 
 
-bool MathInset::idxPrev(int & idx, int & pos) const
+void MathInset::metricsT(TextMetricsInfo const &, Dimension &) const
 {
-       if (idx == 0)
-               return false;
-       --idx;
-       pos = cell(idx).size();
-       return true;
+#ifdef WITH_WARNINGS
+       lyxerr << "MathInset::metricsT(Text) called directly!" << endl;
+#endif
 }
 
 
-bool MathInset::idxLeft(int & idx, int & pos) const
+void MathInset::drawT(TextPainter &, int, int) const
 {
-       return idxPrev(idx, pos);
+#ifdef WITH_WARNINGS
+       lyxerr << "MathInset::drawT(Text) called directly!" << endl;
+#endif
 }
 
-bool MathInset::idxUp(int &, int &) const
-{
-       return false;
-}
 
 
-bool MathInset::idxDown(int &, int &) const
+void MathInset::write(WriteStream & os) const
 {
-       return false;
+       os << '\\' << name().c_str();
+       os.pendingSpace(true);
 }
 
 
-bool MathInset::idxFirst(int & i, int & pos) const
+void MathInset::normalize(NormalStream & os) const
 {
-       if (nargs() == 0)
-               return false;
-       i = 0;
-       pos = 0;
-       return true;
-}
-
-bool MathInset::idxLast(int & i, int & pos) const
-{
-       if (nargs() == 0)
-               return false;
-       i = nargs() - 1;
-       pos = cell(i).size();
-       return true;
+       os << '[' << name().c_str() << "] ";
 }
 
 
-bool MathInset::idxHome(int & /* idx */, int & pos) const
+void MathInset::octave(OctaveStream & os) const
 {
-       if (pos == 0)
-               return false;
-       pos = 0;
-       return true;
+       NormalStream ns(os.os());
+       normalize(ns);
 }
 
 
-bool MathInset::idxEnd(int & idx, int & pos) const
+void MathInset::maple(MapleStream & os) const
 {
-       if (pos == cell(idx).size())
-               return false;
-
-       pos = cell(idx).size();
-       return true;
+       NormalStream ns(os.os());
+       normalize(ns);
 }
 
 
-bool MathInset::idxFirstUp(int &, int &) const
+void MathInset::maxima(MaximaStream & os) const
 {
-       return false;
+       MapleStream ns(os.os());
+       maple(ns);
 }
 
 
-bool MathInset::idxFirstDown(int &, int &) const
-{
-       return false;
-}
-
-void MathInset::idxDelete(int &, bool & popit, bool & deleteit)
+void MathInset::mathematica(MathematicaStream & os) const
 {
-       popit    = false;
-       deleteit = false;
+       NormalStream ns(os.os());
+       normalize(ns);
 }
 
 
-bool MathInset::idxLastUp(int &, int &) const
+void MathInset::mathmlize(MathMLStream & os) const
 {
-       return false;
+       NormalStream ns(os.os());
+       normalize(ns);
 }
 
 
-bool MathInset::idxLastDown(int &, int &) const
+int MathInset::ascii(std::ostream &, int) const
 {
-       return false;
+       return 0;
 }
 
 
-void MathInset::GetXY(int & x, int & y) const
+int MathInset::linuxdoc(std::ostream &) const
 {
-   x = xo();
-   y = yo();
+       return 0;
 }
 
 
-/*
-void MathInset::UserSetSize(MathStyles sz)
-{
-       if (sz >= 0) {
-               size_ = sz;      
-               flag = flag & ~LMPF_FIXED_SIZE;
-       }
-}
-*/
-
-void MathInset::WriteNormal(std::ostream & os) const
+int MathInset::docbook(std::ostream &, bool) const
 {
-       os << "[" << name_ << "] ";
+       return 0;
 }
 
 
-void MathInset::dump() const
+string const & MathInset::getType() const
 {
-       lyxerr << "---------------------------------------------\n";
-       Write(lyxerr, false);
-       lyxerr << "\n";
-       for (int i = 0; i < nargs(); ++i)
-               lyxerr << cell(i) << "\n";
-       lyxerr << "---------------------------------------------\n";
+       static string const t("none");
+       return t;
 }
 
 
-void MathInset::push_back(unsigned char ch, MathTextCodes fcode)
+string MathInset::name() const
 {
-       if (nargs())
-               cells_.back().data_.push_back(ch, fcode);
-       else
-               lyxerr << "can't push without a cell\n";
+       return "unknown";
 }
 
 
-void MathInset::push_back(MathInset * p)
+ostream & operator<<(ostream & os, MathAtom const & at)
 {
-       if (nargs())
-               cells_.back().data_.push_back(p);
-       else
-               lyxerr << "can't push without a cell\n";
+       WriteStream wi(os, false, false);
+       at->write(wi);
+       return os;
 }
 
 
-bool MathInset::covers(int x, int y) const
+string MathInset::fileInsetLabel() const
 {
-       return
-               x >= xo_ &&
-               x <= xo_ + width_ &&
-               y >= yo_ - ascent_ &&
-               y <= yo_ + descent_;
+       return "Formula";
 }