First step the the process of changing MathRowSt into a proper list.

This basically introduces a new class (MathRowContainer). Currently this
is just a wrapper around a  * MathRowSt, later it will provide a list-like
interface.  In the end it will be replaced by a proper list<MathRowStruct>
(and then MathRowSt of course could be scrapped).

This allows us to move the "client code" in small steps to the new
interface. 

Andre'

-- 
André Pönitz ........................................ [EMAIL PROTECTED]
Index: ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/ChangeLog,v
retrieving revision 1.56
diff -u -p -r1.56 ChangeLog
--- ChangeLog   2001/03/06 11:13:14     1.56
+++ ChangeLog   2001/03/06 17:03:19
@@ -2,10 +2,13 @@
        * array.[Ch]: factor out deep_copy,
          remove third argument from raw_pointer_insert 
 
-       * mathiter.[Ch]: remove unused function Clear() 
+       * math_iter.[Ch]: remove unused function Clear()        
 
-       * mathcursor.C: change signature of MathStackXIter:push()
+       * math_cursor.C: change signature of MathStackXIter:push()
          whitespace changes
+
+       * math_rowst.h: introduction of MathRowContainer
+         several files: corresponding changes
 
 2001-03-04  André Pönitz  <[EMAIL PROTECTED]>
   * math_macrotemplate.[Ch]:
Index: math_matrixinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_matrixinset.C,v
retrieving revision 1.9
diff -u -p -r1.9 math_matrixinset.C
--- math_matrixinset.C  2001/02/28 17:21:16     1.9
+++ math_matrixinset.C  2001/03/06 17:03:19
@@ -40,9 +40,9 @@ MathMatrixInset::MathMatrixInset(MathMat
          v_align_(mt.v_align_), h_align_(mt.h_align_)
 {
        array = mt.GetData();
-       if (mt.row_ != 0) {
+       if (mt.row_.data_ != 0) {
                MathedRowSt * ro = 0;
-               MathedRowSt * mrow = mt.row_;
+               MathedRowSt * mrow = mt.row_.data_;
 
                while (mrow) {
                        MathedRowSt * r = new MathedRowSt(nc_ + 1);
@@ -65,7 +65,7 @@ MathMatrixInset::MathMatrixInset(MathMat
 
 MathMatrixInset::~MathMatrixInset()
 {
-       MathedRowSt * r = row_;
+       MathedRowSt * r = row_.data_;
        while (r) {
                MathedRowSt * q = r->getNext();
                delete r;
@@ -132,14 +132,14 @@ void MathMatrixInset::draw(Painter & pai
 
 void MathMatrixInset::Metrics()
 {
-       if (!row_) {
+       if (!row_.data_) {
                // lyxerr << " MIDA ";
                MathedXIter it(this);
                row_ = it.adjustVerticalSt();
        } 
        
        // Clean the arrays      
-       MathedRowSt * cxrow = row_;
+       MathedRowSt * cxrow = row_.data_;
        while (cxrow) {   
                for (int i = 0; i <= nc_; ++i)
                        cxrow->setTab(i, 0);
@@ -149,24 +149,24 @@ void MathMatrixInset::Metrics()
        // Basic metrics
        MathParInset::Metrics();
        
-       if (nc_ <= 1 && !row_->getNext()) {
-               row_->ascent(ascent);
-               row_->descent(descent);
+       if (nc_ <= 1 && !row_.data_->getNext()) {
+               row_.data_->ascent(ascent);
+               row_.data_->descent(descent);
        }
        
        // Vertical positions of each row
-       cxrow = row_;     
+       cxrow = row_.data_;     
        MathedRowSt * cprow = 0;
        int h = 0;
        while (cxrow) {
                for (int i = 0; i < nc_; ++i) {
-                       if (cxrow == row_ || ws_[i] < cxrow->getTab(i))
+                       if (cxrow == row_.data_ || ws_[i] < cxrow->getTab(i))
                                ws_[i] = cxrow->getTab(i);
                        if (cxrow->getNext() == 0 && ws_[i] == 0)
                                ws_[i] = df_width;
                }
                
-               cxrow->setBaseline((cxrow == row_) ?
+               cxrow->setBaseline((cxrow == row_.data_) ?
                                   cxrow->ascent() :
                                   cxrow->ascent() + cprow->descent()
                                   + MATH_ROWSEP + cprow->getBaseline());
@@ -181,13 +181,13 @@ void MathMatrixInset::Metrics()
        //  Compute vertical align
        switch (v_align_) {
        case 't':
-               ascent = row_->getBaseline();
+               ascent = row_.data_->getBaseline();
                break;
        case 'b':
                ascent = h - hl;
                break;
        default:
-               ascent = (row_->getNext()) ? h / 2 : h - hl;
+               ascent = (row_.data_->getNext()) ? h / 2 : h - hl;
                break;
        }
        descent = h - ascent + 2;
@@ -202,7 +202,7 @@ void MathMatrixInset::Metrics()
                        ws_[0] = 7 * workWidth / 8;
        
        // Adjust local tabs
-       cxrow = row_;
+       cxrow = row_.data_;
        width = MATH_COLSEP;
        while (cxrow) {   
                int rg = MATH_COLSEP;
@@ -225,7 +225,7 @@ void MathMatrixInset::Metrics()
                                lf = ws_[i] - cxrow->getTab(i);
                                break;
                        case 'C':
-                               if (cxrow == row_)
+                               if (cxrow == row_.data_)
                                        lf = 0;
                                else if (!cxrow->getNext())
                                        lf = ws_[i] - cxrow->getTab(i);
@@ -236,7 +236,7 @@ void MathMatrixInset::Metrics()
                        int const ww = (isvoid) ? lf : lf + cxrow->getTab(i);
                        cxrow->setTab(i, lf + rg);
                        rg = ws_[i] - ww + MATH_COLSEP;
-                       if (cxrow == row_)
+                       if (cxrow == row_.data_)
                                width += ws_[i] + MATH_COLSEP;
                }
                cxrow->setBaseline(cxrow->getBaseline() - ascent);
Index: math_matrixinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_matrixinset.h,v
retrieving revision 1.5
diff -u -p -r1.5 math_matrixinset.h
--- math_matrixinset.h  2001/02/28 17:21:16     1.5
+++ math_matrixinset.h  2001/03/06 17:03:20
@@ -61,7 +61,7 @@ private:
        //std::vector<char> h_align;
        string h_align_; // a vector would perhaps be more correct
        /// Vertical structure
-       MathedRowSt * row_;
+       MathedRowContainer row_;
 };
 
 
@@ -89,7 +89,7 @@ bool MathMatrixInset::isMatrix() const
 inline
 MathedRowSt * MathMatrixInset::getRowSt() const
 {
-       return row_;
+       return row_.data_;
 }
 
 
Index: math_parinset.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_parinset.h,v
retrieving revision 1.9
diff -u -p -r1.9 math_parinset.h
--- math_parinset.h     2001/03/01 13:37:48     1.9
+++ math_parinset.h     2001/03/06 17:03:20
@@ -5,12 +5,12 @@
 #include "array.h"
 #include "math_inset.h"
 #include "math_defs.h"
+#include "math_rowst.h"
 
 #ifdef __GNUG__
 #pragma interface
 #endif
 
-class MathedRowSt;
 class MathedArray;
 
 
Index: math_rowst.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_rowst.h,v
retrieving revision 1.3
diff -u -p -r1.3 math_rowst.h
--- math_rowst.h        2001/03/05 10:23:55     1.3
+++ math_rowst.h        2001/03/06 17:03:23
@@ -72,10 +72,53 @@ public:
        MathedRowSt * getNext() const;
        /// ...we couldn't use this.
        void setNext(MathedRowSt * n);
-private:
+//private:
        ///
        MathedRowSt * next_;
 };
+
+
+// The idea is to change this  MathedRowContainer  to mimic the behaviour
+// of std::list<MathedRowStruct> in several small steps.  In the end it
+// could be replaced by such a list and MathedRowSt can go as well. 
+ 
+struct MathedRowContainer {
+       ///
+       struct iterator {
+               ///
+               iterator(MathedRowContainer * m) : st_(m->data_) {}
+               /// "better" conversion to bool
+               operator void *() const { return st_; }
+               ///
+               MathedRowStruct & operator*() { return *st_; }
+               ///
+               MathedRowStruct * operator->() { return st_; }
+               ///
+               void operator++() { st_ = st_->next_; }
+               ///
+               bool is_last() const { return st_->next_ == 0; }
+               ///
+               bool operator==(const iterator & it) const { return st_ == it.st_; }
+
+       private:
+               ///
+               MathedRowSt * st_;
+       };
+
+       ///
+       MathedRowContainer() : data_(0) {}
+       ///
+       MathedRowContainer(MathedRowSt * data) : data_(data) {}
+
+       ///
+       iterator begin() { return iterator(this); }
+       ///
+       bool empty() const { return data_ == 0; }
+
+       ///
+       MathedRowSt * data_;
+};
+
 
 
 inline

Reply via email to