]> git.lyx.org Git - lyx.git/commitdiff
mathed44.diff
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 6 Mar 2001 17:13:12 +0000 (17:13 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 6 Mar 2001 17:13:12 +0000 (17:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1693 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/math_matrixinset.C
src/mathed/math_matrixinset.h
src/mathed/math_parinset.h
src/mathed/math_rowst.h

index 7d87037d9ecb5c7312351009bfd1ef5aaca4149f..ef6f8866497d93bf3796d2e9b3846f0208179280 100644 (file)
@@ -2,11 +2,14 @@
        * 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  <poenitz@htwm.de>
   * math_macrotemplate.[Ch]:
     math_macro.C: move update() functionality to the macro
index 8e6fbdc4b56a8fcabbb0653280aed6aaabecd4a3..21ad67b89cc6103823e3b1334ccaa214ef08583e 100644 (file)
@@ -40,9 +40,9 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset const & mt)
          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(MathMatrixInset const & mt)
 
 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 & pain, int x, int baseline)
 
 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 caf23ea3c1ce6b2aba7f1512da5aadf55824a8ba..c8c7cc45b7315022c4155f69d45246eb820db0db 100644 (file)
@@ -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 c8797ebd47c18b8cc29e4d29e691ce8c083b7550..c5af2cfb5c0aafdbdac4c201be407e0d28747315 100644 (file)
@@ -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 dba14517a7b7e8953c0ca6ed0145be28022f29be..5c9c59383bd79d4c071738d269f0ab68533dcbae 100644 (file)
@@ -72,12 +72,55 @@ 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
 MathedRowSt * MathedRowSt::getNext() const
 {