5 #include "math_nestinset.h"
13 /** Gridded math inset base class.
14 This is the base to all grid-like editable math objects
15 like array and eqnarray.
16 \author André Pönitz 2001
19 class MathGridInset : public MathNestInset {
21 /// additional per-row information
26 int skipPixels() const;
33 /// how many hlines above this row?
35 /// parameter to the line break
37 /// extra distance between lines
41 // additional per-row information
45 /// currently possible: 'l', 'c', 'r'
53 /// do we need a line to the left?
55 /// do we need a line to the right?
57 /// how many lines to the left of this column?
59 /// additional amount to be skipped when drawing
64 /// constructor from columns description, creates one row
65 MathGridInset(char valign, string const & halign);
66 /// Note: columns first!
67 MathGridInset(col_type m, row_type n);
69 MathGridInset(col_type m, row_type n, char valign, string const & halign);
71 MathInset * clone() const;
73 void metrics(MathMetricsInfo const & st) const;
75 void draw(Painter &, int x, int y) const;
77 void halign(string const &);
79 void halign(char c, col_type col);
81 char halign(col_type col) const;
83 string halign() const;
89 void vcrskip(LyXLength const &, row_type row);
91 LyXLength vcrskip(row_type row) const;
93 void resize(short int type, col_type cols);
95 const RowInfo & rowinfo(row_type row) const;
96 /// returns topmost row if passed (-1)
97 RowInfo & rowinfo(row_type row);
98 /// identifies GridInset
99 virtual MathGridInset * asGridInset() { return this; }
102 col_type ncols() const;
104 row_type nrows() const;
106 col_type col(idx_type idx) const;
108 row_type row(idx_type idx) const;
110 int cellXOffset(idx_type idx) const;
112 int cellYOffset(idx_type idx) const;
115 bool idxUp(idx_type &) const;
117 bool idxDown(idx_type &) const;
119 bool idxLeft(idx_type &, pos_type &) const;
121 bool idxRight(idx_type &, pos_type &) const;
123 bool idxFirst(idx_type &, pos_type &) const;
125 bool idxLast(idx_type &, pos_type &) const;
127 bool idxHome(idx_type &, pos_type &) const;
129 bool idxEnd(idx_type &, pos_type &) const;
131 void idxDelete(idx_type &, bool &, bool &);
134 virtual void addRow(row_type);
136 virtual void delRow(row_type);
138 virtual void addCol(col_type);
140 virtual void delCol(col_type);
142 virtual void appendRow();
144 idx_type index(row_type row, col_type col) const;
146 std::vector<idx_type> idxBetween(idx_type from, idx_type to) const;
148 virtual int defaultColSpace(col_type) { return 0; }
150 virtual char defaultColAlign(col_type) { return 'c'; }
155 virtual int colsep() const;
157 virtual int rowsep() const;
159 virtual int hlinesep() const;
161 virtual int vlinesep() const;
163 virtual int border() const;
166 void write(WriteStream & os) const;
168 void normalize(NormalStream &) const;
170 //void maplize(MapleStream &) const;
172 void mathmlize(MathMLStream &) const;
174 //void octavize(OctaveStream &) const;
177 /// returns proper 'end of line' code for LaTeX
178 string eolString(row_type row) const;
179 /// returns proper 'end of column' code for LaTeX
180 string eocString(col_type col) const;
181 /// extract number of columns from alignment string
182 col_type guessColumns(string const & halign) const;
185 std::vector<RowInfo> rowinfo_;
187 std::vector<ColInfo> colinfo_;
189 char v_align_; // add approp. type