]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_inset.C
mathed108.diff
[lyx.git] / src / mathed / math_inset.C
index b9903f2f4d2a8a51f9f883f262b3c6c54cba27e0..b5980fc019530eeea4bbb7a63ff6fdc26233793b 100644 (file)
  *   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, short ot, int nargs)
+MathInset::MathInset(int nargs, string const & name, MathInsetTypes ot)
        : name_(name), objtype(ot), width_(0), ascent_(0), descent_(0),
-               size_(LM_ST_TEXT), cells_(nargs), xo_(0), yo_(0)
+               size_(LM_ST_DISPLAY), cells_(nargs), xo_(0), yo_(0)
 {}
 
 
@@ -60,14 +56,15 @@ int MathInset::height() const
 }
 
 
-bool MathInset::GetLimits() const
+int MathInset::limits() const
 {
        return false;
 }
 
 
-void MathInset::SetLimits(bool) {}   
-
+void MathInset::limits(int)
+{
+}
 
 string const & MathInset::name() const
 {
@@ -75,13 +72,13 @@ string const & MathInset::name() const
 }
 
 
-short MathInset::GetType() const
+MathInsetTypes MathInset::GetType() const
 {
        return objtype;
 }
 
 
-void  MathInset::SetType(short t)
+void MathInset::SetType(MathInsetTypes t)
 {
        objtype = t;
 }
@@ -165,15 +162,9 @@ MathArray const & MathInset::cell(int i) const
 }
 
 
-void MathInset::setData(MathArray const & a, int idx)
-{
-       cells_[idx].data_ = a;
-}
-
-
 void MathInset::substitute(MathArray & array, MathMacro const & m) const
 {
-       MathInset * p = Clone();
+       MathInset * p = clone();
        for (int i = 0; i < nargs(); ++i)
                p->cell(i).substitute(m);
        array.push_back(p);
@@ -195,7 +186,7 @@ void MathInset::draw(Painter & pain, int x, int y)
 }
 
 
-bool MathInset::idxRight(int & idx, int & pos) const
+bool MathInset::idxNext(int & idx, int & pos) const
 {
        if (idx + 1 >= nargs())
                return false;
@@ -205,7 +196,13 @@ bool MathInset::idxRight(int & idx, int & pos) const
 }
 
 
-bool MathInset::idxLeft(int & idx, int & pos) const
+bool MathInset::idxRight(int & idx, int & pos) const
+{
+       return idxNext(idx, pos);
+}
+
+
+bool MathInset::idxPrev(int & idx, int & pos) const
 {
        if (idx == 0)
                return false;
@@ -215,6 +212,11 @@ bool MathInset::idxLeft(int & idx, int & pos) const
 }
 
 
+bool MathInset::idxLeft(int & idx, int & pos) const
+{
+       return idxPrev(idx, pos);
+}
+
 bool MathInset::idxUp(int &, int &) const
 {
        return false;
@@ -246,7 +248,7 @@ bool MathInset::idxLast(int & i, int & pos) const
 }
 
 
-bool MathInset::idxHome(int & i, int & pos) const
+bool MathInset::idxHome(int & /* idx */, int & pos) const
 {
        if (pos == 0)
                return false;
@@ -265,6 +267,39 @@ bool MathInset::idxEnd(int & idx, int & pos) const
 }
 
 
+bool MathInset::idxFirstUp(int &, int &) const
+{
+       return false;
+}
+
+
+bool MathInset::idxFirstDown(int &, int &) const
+{
+       return false;
+}
+
+void MathInset::idxDelete(int &, bool & popit, bool & deleteit)
+{
+       popit    = false;
+       deleteit = false;
+}
+
+void MathInset::idxDeleteRange(int, int)
+{}
+
+
+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();
@@ -299,7 +334,7 @@ void MathInset::dump() const
 }
 
 
-void MathInset::push_back(byte ch, MathTextCodes fcode)
+void MathInset::push_back(unsigned char ch, MathTextCodes fcode)
 {
        if (nargs())
                cells_.back().data_.push_back(ch, fcode);
@@ -326,3 +361,16 @@ bool MathInset::covers(int x, int y) const
                y <= yo_ + descent_;
 }
 
+void MathInset::Validate(LaTeXFeatures & features) const
+{
+       for (int i = 0; i < nargs(); ++i)
+               cell(i).Validate(features);
+}
+
+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;
+}