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-cell information
25 /// a dummy cell before a multicolumn cell
27 /// special multi colums alignment
31 /// additional per-row information
36 int skipPixels() const;
43 /// how many hlines above this row?
45 /// parameter to the line break
47 /// extra distance between lines
51 // additional per-row information
55 /// currently possible: 'l', 'c', 'r'
63 /// do we need a line to the left?
65 /// do we need a line to the right?
67 /// how many lines to the left of this column?
69 /// additional amount to be skipped when drawing
74 /// sets nrows and ncols to 1
76 /// constructor from columns description, creates one row
77 MathGridInset(char valign, string const & halign);
78 /// Note: columns first!
79 MathGridInset(col_type m, row_type n);
81 MathGridInset(col_type m, row_type n, char valign, string const & halign);
83 MathInset * clone() const;
85 void metrics(MathMetricsInfo & st) const;
87 void draw(MathPainterInfo &, int x, int y) const;
89 void metricsT(TextMetricsInfo const & st) const;
91 void drawT(TextPainter &, int x, int y) const;
93 void halign(string const &);
95 void halign(char c, col_type col);
97 char halign(col_type col) const;
99 string halign() const;
105 void vcrskip(LyXLength const &, row_type row);
107 LyXLength vcrskip(row_type row) const;
109 void resize(short int type, col_type cols);
111 const RowInfo & rowinfo(row_type row) const;
112 /// returns topmost row if passed (-1)
113 RowInfo & rowinfo(row_type row);
115 const CellInfo & cellinfo(idx_type idx) const { return cellinfo_[idx]; }
117 CellInfo & cellinfo(idx_type idx) { return cellinfo_[idx]; }
118 /// identifies GridInset
119 virtual MathGridInset * asGridInset() { return this; }
122 col_type ncols() const;
124 row_type nrows() const;
126 col_type col(idx_type idx) const;
128 row_type row(idx_type idx) const;
130 int cellXOffset(idx_type idx) const;
132 int cellYOffset(idx_type idx) const;
135 bool idxUpDown(idx_type & idx, pos_type & pos, bool) const;
137 bool idxLeft(idx_type & idx, pos_type & pos) const;
139 bool idxRight(idx_type & idx, pos_type & pos) const;
141 bool idxFirst(idx_type & idx, pos_type & pos) const;
143 bool idxLast(idx_type & idx, pos_type & pos) const;
145 bool idxHome(idx_type & idx, pos_type & pos) const;
147 bool idxEnd(idx_type & idx, pos_type & pos) const;
149 bool idxDelete(idx_type & idx);
150 /// pulls cell after pressing erase
151 void idxGlue(idx_type idx);
154 virtual void addRow(row_type r);
156 virtual void delRow(row_type r);
158 virtual void addFancyRow(row_type r) { addRow(r); }
160 virtual void delFancyRow(row_type r) { addRow(r); }
162 virtual void addCol(col_type c);
164 virtual void delCol(col_type c);
166 virtual void addFancyCol(col_type c) { addCol(c); }
168 virtual void delFancyCol(col_type c) { addCol(c); }
170 virtual void appendRow();
172 idx_type index(row_type r, col_type c) const;
174 std::vector<idx_type> idxBetween(idx_type from, idx_type to) const;
176 virtual int defaultColSpace(col_type) { return 0; }
178 virtual char defaultColAlign(col_type) { return 'c'; }
183 virtual int colsep() const;
185 virtual int rowsep() const;
187 virtual int hlinesep() const;
189 virtual int vlinesep() const;
191 virtual int border() const;
194 void write(WriteStream & os) const;
196 void normalize(NormalStream &) const;
198 //void maplize(MapleStream &) const;
200 void mathmlize(MathMLStream &) const;
202 //void octavize(OctaveStream &) const;
205 /// returns proper 'end of line' code for LaTeX
206 string eolString(row_type row, bool fragile = false) const;
207 /// returns proper 'end of column' code for LaTeX
208 string eocString(col_type col) const;
209 /// extract number of columns from alignment string
210 col_type guessColumns(string const & halign) const;
213 std::vector<RowInfo> rowinfo_;
215 std::vector<ColInfo> colinfo_;
217 std::vector<CellInfo> cellinfo_;
219 char v_align_; // add approp. type