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 /// hline abow this row?
35 /// hline below this row?
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 /// additional amount to be skipped when drawing
62 /// Note: columns first!
63 MathGridInset(col_type m, row_type n);
65 MathGridInset(int m, int n, char valign, string const & halign);
67 void metrics(MathMetricsInfo const & st) const;
69 void draw(Painter &, int x, int y) const;
71 void halign(string const &);
73 void halign(char c, col_type col);
75 char halign(col_type col) const;
81 void vskip(LyXLength const &, row_type row);
83 LyXLength vskip(row_type row) const;
85 void resize(short int type, col_type cols);
87 const RowInfo & rowinfo(row_type row) const;
89 RowInfo & rowinfo(row_type row);
90 /// identifies GridInset
91 virtual MathGridInset * asGridInset() { return this; }
94 col_type ncols() const { return colinfo_.size(); }
96 row_type nrows() const { return rowinfo_.size(); }
98 col_type col(idx_type idx) const { return idx % ncols(); }
100 row_type row(idx_type idx) const { return idx / ncols(); }
102 int cellXOffset(idx_type idx) const;
104 int cellYOffset(idx_type idx) const;
107 bool idxUp(idx_type &, pos_type &) const;
109 bool idxDown(idx_type &, pos_type &) const;
111 bool idxLeft(idx_type &, pos_type &) const;
113 bool idxRight(idx_type &, pos_type &) const;
115 bool idxFirst(idx_type &, pos_type &) const;
117 bool idxLast(idx_type &, pos_type &) const;
119 bool idxHome(idx_type &, pos_type &) const;
121 bool idxEnd(idx_type &, pos_type &) const;
123 void idxDelete(idx_type &, bool &, bool &);
125 void idxDeleteRange(idx_type, idx_type);
128 void addRow(row_type);
130 void delRow(row_type);
132 void addCol(col_type);
134 void delCol(col_type);
136 virtual void appendRow();
138 idx_type index(row_type row, col_type col) const;
140 std::vector<idx_type> idxBetween(idx_type from, idx_type to) const;
142 virtual int defaultColSpace(col_type) { return 10; }
144 virtual char defaultColAlign(col_type) { return 'c'; }
149 void write(WriteStream & os) const;
151 void normalize(NormalStream &) const;
153 //void maplize(MapleStream &) const;
155 void mathmlize(MathMLStream &) const;
157 //void octavize(OctaveStream &) const;
160 /// returns proper 'end of line' code for LaTeX
161 string eolString(row_type row) const;
162 /// returns proper 'end of column' code for LaTeX
163 string eocString(col_type col) const;
166 std::vector<RowInfo> rowinfo_;
168 std::vector<ColInfo> colinfo_;
170 char v_align_; // add approp. type