]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_gridinset.h
further code uglification to make Jean-Marc's compiler happy
[lyx.git] / src / mathed / math_gridinset.h
index cb58ebfd2d8687a10f7b209ab3d9b66c11705602..2bea095771d9df82a58ca7a7f813d99570319937 100644 (file)
@@ -2,7 +2,9 @@
 #ifndef MATH_GRID_H
 #define MATH_GRID_H
 
-#include "math_inset.h"
+#include "math_nestinset.h"
+#include "vspace.h"
+#include "LString.h"
 
 #ifdef __GNUG__
 #pragma interface
     \author André Pönitz 2001
 */
 
-class MathGridInset : public MathInset {
+class MathGridInset : public MathNestInset {
 
        /// additional per-row information
        struct RowInfo {
                ///
                RowInfo();
                ///
-               int descent_;
-               ///
-               int ascent_;
-               /// 
-               int offset_;
-               ///
+               int skipPixels() const;
+               /// cached descent
+               mutable int descent_;
+               /// cached ascent
+               mutable int ascent_;
+               /// cached offset
+               mutable int offset_;
+               /// hline abow this row?
                bool upperline_;
-               ///
+               /// hline below this row?
                bool lowerline_;
+               /// distance
+               LyXLength skip_;
        };
 
        // additional per-row information
        struct ColInfo {
                ///     
                ColInfo();
-               ///
-               char h_align_;
+               /// currently possible: 'l', 'c', 'r'
+               char align_;
                /// cache for drawing
                int h_offset;
-               ///
-               int width_;
-               ///
-               int offset_;
-               ///
+               /// cached width
+               mutable int width_;
+               /// cached offset
+               mutable int offset_;
+               /// do we need a line to the left? 
                bool leftline_;
-               ///
+               /// do we need a line to the right?
                bool rightline_;
+               /// additional amount to be skipped when drawing
+               int skip_;
        };
 
 public: 
        ///
-       MathGridInset(int m, int n, string const & nm, MathInsetTypes ot);
-       ///
-       virtual MathInset * clone() const = 0;
+       MathGridInset(unsigned int m, unsigned int n);
        ///
-       void Write(std::ostream &, bool fragile) const;
+       void write(std::ostream &, bool fragile) const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void metrics(MathStyles st) const;
        ///
-       void draw(Painter &, int, int);
+       void draw(Painter &, int x, int y) const;
        ///
        void halign(string const &);
        ///
-       void halign(char c, int col);
+       void halign(char c, unsigned int col);
        ///
-       char halign(int col) const;
+       char halign(unsigned int col) const;
        ///
        void valign(char c);
        ///
        char valign() const;
        ///
-       void resize(short int type, int cols);
+       void vskip(LyXLength const &, unsigned int row);
        ///
-       const RowInfo & rowinfo(int row) const;
+       LyXLength vskip(unsigned int row) const;
        ///
-       RowInfo & rowinfo(int row);
+       void resize(short int type, unsigned int cols);
+       ///
+       const RowInfo & rowinfo(unsigned int row) const;
+       ///
+       RowInfo & rowinfo(unsigned int row);
+       ///
+       bool isGrid() const { return true; }
 
        ///
-       int ncols() const { return colinfo_.size(); }
+       unsigned int ncols() const { return colinfo_.size(); }
+       ///
+       unsigned int nrows() const { return rowinfo_.size(); }
+       ///
+       unsigned int col(unsigned int idx) const { return idx % ncols(); }
        ///
-       int nrows() const { return rowinfo_.size(); }
+       unsigned int row(unsigned int idx) const { return idx / ncols(); }
        ///
-       int col(int idx) const { return idx % ncols(); }
+       int cellXOffset(unsigned int idx) const;
        ///
-       int row(int idx) const { return idx / ncols(); }
+       int cellYOffset(unsigned int idx) const;
 
        ///
-       bool idxUp(int &, int &) const;
+       bool idxUp(unsigned int &, unsigned int &) const;
        ///
-       bool idxDown(int &, int &) const;
+       bool idxDown(unsigned int &, unsigned int &) const;
        ///
-       bool idxLeft(int &, int &) const;
+       bool idxLeft(unsigned int &, unsigned int &) const;
        ///
-       bool idxRight(int &, int &) const;
+       bool idxRight(unsigned int &, unsigned int &) const;
        ///
-       bool idxFirst(int &, int &) const;
+       bool idxFirst(unsigned int &, unsigned int &) const;
        ///
-       bool idxLast(int &, int &) const;
+       bool idxLast(unsigned int &, unsigned int &) const;
        ///
-       void idxDelete(int &, bool &, bool &);
+       void idxDelete(unsigned int &, bool &, bool &);
        ///
-       void idxDeleteRange(int, int);
+       void idxDeleteRange(unsigned int, unsigned int);
                        
        ///
-       void addRow(int);
+       void addRow(unsigned int);
        ///
-       void delRow(int);
+       void delRow(unsigned int);
        ///
-       void addCol(int);
+       void addCol(unsigned int);
        ///
-       void delCol(int);
+       void delCol(unsigned int);
        ///
        virtual void appendRow();
        ///
-       int index(int row, int col) const;
+       unsigned int index(unsigned int row, unsigned int col) const;
        ///
-       std::vector<int> idxBetween(int from, int to) const;
+       std::vector<unsigned int> idxBetween(unsigned int from, unsigned int to) const;
+       ///
+       virtual int defaultColSpace(unsigned int) { return 10; }
+       ///
+       virtual char defaultColAlign(unsigned int) { return 'c'; }
+       ///
+       void setDefaults();
 
 protected:
+       /// returns proper 'end of line' code for LaTeX
+       string eolString(unsigned int row) const;
+       /// returns proper 'end of column' code for LaTeX
+       string eocString(unsigned int col) const;
+
        /// row info
        std::vector<RowInfo> rowinfo_;
        /// column info