* the GNU General Public Licence version 2 or later.
*/
-#include <config.h>
-
#ifdef __GNUG__
#pragma implementation
#endif
#include "math_inset.h"
-#include "mathed/support.h"
-#include "Painter.h"
#include "debug.h"
int MathInset::workwidth;
-MathInset::MathInset(string const & name, MathInsetTypes ot, int nargs)
- : name_(name), objtype(ot), width_(0), ascent_(0), descent_(0),
- size_(LM_ST_DISPLAY), cells_(nargs), xo_(0), yo_(0)
+MathInset::MathInset()
+ : size_(LM_ST_DISPLAY), 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_;
-}
-
-
-int MathInset::limits() const
-{
- return false;
-}
-
-
-void MathInset::limits(int)
-{
-}
-
-bool MathInset::hasLimits() const
-{
- return false;
-}
-
-
-string const & MathInset::name() const
-{
- return name_;
-}
-
-
-MathInsetTypes MathInset::GetType() const
-{
- return objtype;
-}
-
-
-void MathInset::SetType(MathInsetTypes t)
-{
- objtype = t;
-}
-
-
-void MathInset::SetName(string const & n)
-{
- name_ = n;
+ return ascent() + descent();
}
}
-void MathInset::size(MathStyles s)
+void MathInset::size(MathStyles s) const
{
size_ = s;
}
+
std::ostream & operator<<(std::ostream & os, MathInset const & inset)
{
- inset.Write(os, false);
+ inset.write(os, false);
return os;
}
}
-void MathInset::xo(int x)
+void MathInset::xo(int x) const
{
xo_ = x;
}
-void MathInset::yo(int y)
+void MathInset::yo(int y) const
{
yo_ = y;
}
int MathInset::nargs() const
{
- return cells_.size();
+ return 0;
}
+MathXArray dummyCell;
-MathXArray & MathInset::xcell(int i)
-{
- return cells_[i];
-}
-
-MathXArray const & MathInset::xcell(int i) const
+MathXArray & MathInset::xcell(int)
{
- return cells_[i];
+ lyxerr << "I don't have a cell\n";
+ return dummyCell;
}
-
-MathArray & MathInset::cell(int i)
-{
- return cells_[i].data_;
-}
-
-MathArray const & MathInset::cell(int i) const
+MathXArray const & MathInset::xcell(int) const
{
- return cells_[i].data_;
+ lyxerr << "I don't have a cell\n";
+ return dummyCell;
}
-void MathInset::setData(MathArray const & a, int idx)
+MathArray & MathInset::cell(int)
{
- cells_[idx].data_ = a;
+ lyxerr << "I don't have a cell\n";
+ return dummyCell.data_;
}
-void MathInset::substitute(MathArray & array, MathMacro const & m) const
+MathArray const & MathInset::cell(int) const
{
- MathInset * p = clone();
- for (int i = 0; i < nargs(); ++i)
- p->cell(i).substitute(m);
- array.push_back(p);
+ lyxerr << "I don't have a cell\n";
+ return dummyCell.data_;
}
-void MathInset::Metrics(MathStyles st)
-{
- size_ = st;
- for (int i = 0; i < nargs(); ++i)
- xcell(i).Metrics(st);
-}
-void MathInset::draw(Painter & pain, int x, int y)
+void MathInset::substitute(MathArray & array, MathMacro const &) const
{
- xo_ = x;
- yo_ = y;
- for (int i = 0; i < nargs(); ++i)
- xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
+ array.push_back(clone());
}
-bool MathInset::idxNext(int & idx, int & pos) const
+bool MathInset::idxNext(int &, int &) const
{
- if (idx + 1 >= nargs())
- return false;
- ++idx;
- pos = 0;
- return true;
+ return false;
}
-bool MathInset::idxRight(int & idx, int & pos) const
+bool MathInset::idxRight(int &, int &) const
{
- return idxNext(idx, pos);
+ return false;
}
-bool MathInset::idxPrev(int & idx, int & pos) const
+bool MathInset::idxPrev(int &, int &) const
{
- if (idx == 0)
- return false;
- --idx;
- pos = cell(idx).size();
- return true;
+ return false;
}
-bool MathInset::idxLeft(int & idx, int & pos) const
+bool MathInset::idxLeft(int &, int &) const
{
- return idxPrev(idx, pos);
+ return false;
}
+
bool MathInset::idxUp(int &, int &) const
{
return false;
}
-bool MathInset::idxFirst(int & i, int & pos) const
+bool MathInset::idxFirst(int &, int &) const
{
- if (nargs() == 0)
- return false;
- i = 0;
- pos = 0;
- return true;
+ return false;
}
-bool MathInset::idxLast(int & i, int & pos) const
+
+bool MathInset::idxLast(int &, int &) const
{
- if (nargs() == 0)
- return false;
- i = nargs() - 1;
- pos = cell(i).size();
- return true;
+ return false;
}
-bool MathInset::idxHome(int & /* idx */, int & pos) const
+bool MathInset::idxHome(int &, int &) const
{
- if (pos == 0)
- return false;
- pos = 0;
- return true;
+ return false;
}
-bool MathInset::idxEnd(int & idx, int & pos) const
+bool MathInset::idxEnd(int &, int &) const
{
- if (pos == cell(idx).size())
- return false;
-
- pos = cell(idx).size();
- return true;
+ return false;
}
return false;
}
-bool MathInset::idxDelete(int)
+
+void MathInset::idxDelete(int &, bool & popit, bool & deleteit)
{
- return false;
+ popit = false;
+ deleteit = false;
}
+void MathInset::idxDeleteRange(int, int)
+{}
+
+
bool MathInset::idxLastUp(int &, int &) const
{
return false;
}
-void MathInset::GetXY(int & x, int & y) const
+void MathInset::getXY(int & x, int & y) const
{
x = xo();
y = yo();
/*
-void MathInset::UserSetSize(MathStyles sz)
+void MathInset::userSetSize(MathStyles sz)
{
if (sz >= 0) {
size_ = sz;
}
*/
-void MathInset::WriteNormal(std::ostream & os) const
+void MathInset::writeNormal(std::ostream & os) const
{
- os << "[" << name_ << "] ";
+ os << "[unknown] ";
}
void MathInset::dump() const
{
lyxerr << "---------------------------------------------\n";
- Write(lyxerr, false);
- lyxerr << "\n";
- for (int i = 0; i < nargs(); ++i)
- lyxerr << cell(i) << "\n";
- lyxerr << "---------------------------------------------\n";
+ write(lyxerr, false);
+ lyxerr << "\n---------------------------------------------\n";
}
-void MathInset::push_back(byte ch, MathTextCodes fcode)
+void MathInset::push_back(unsigned char, MathTextCodes)
{
- if (nargs())
- cells_.back().data_.push_back(ch, fcode);
- else
- lyxerr << "can't push without a cell\n";
+ lyxerr << "can't push without a cell\n";
}
-void MathInset::push_back(MathInset * p)
+void MathInset::push_back(MathInset *)
{
- if (nargs())
- cells_.back().data_.push_back(p);
- else
- lyxerr << "can't push without a cell\n";
+ lyxerr << "can't push without a cell\n";
}
{
return
x >= xo_ &&
- x <= xo_ + width_ &&
- y >= yo_ - ascent_ &&
- y <= yo_ + descent_;
+ x <= xo_ + width() &&
+ y >= yo_ - ascent() &&
+ y <= yo_ + descent();
+}
+
+
+void MathInset::validate(LaTeXFeatures &) const
+{}
+
+
+std::vector<int> MathInset::idxBetween(int from, int to) const
+{
+ std::vector<int> res;
+ for (int i = from; i <= to; ++i)
+ res.push_back(i);
+ return res;
+}
+
+
+void MathInset::metrics(MathStyles st) const
+{
+ lyxerr << "MathInset::metrics() called directly!\n";
+ size_ = st;
}
+
+void MathInset::draw(Painter &, int, int) const
+{
+ lyxerr << "MathInset::draw() called directly!\n";
+}
+
+
+void MathInset::write(std::ostream &, bool) const
+{
+ lyxerr << "MathInset::write() called directly!\n";
+}