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
63 MathGridInset(unsigned int m, unsigned int n);
65 void write(std::ostream &, bool fragile) const;
67 void metrics(MathStyles st) const;
69 void draw(Painter &, int x, int y) const;
71 void halign(string const &);
73 void halign(char c, unsigned int col);
75 char halign(unsigned int col) const;
81 void vskip(LyXLength const &, unsigned int row);
83 LyXLength vskip(unsigned int row) const;
85 void resize(short int type, unsigned int cols);
87 const RowInfo & rowinfo(unsigned int row) const;
89 RowInfo & rowinfo(unsigned int row);
91 bool isGrid() const { return true; }
94 unsigned int ncols() const { return colinfo_.size(); }
96 unsigned int nrows() const { return rowinfo_.size(); }
98 unsigned int col(unsigned int idx) const { return idx % ncols(); }
100 unsigned int row(unsigned int idx) const { return idx / ncols(); }
102 int cellXOffset(unsigned int idx) const;
104 int cellYOffset(unsigned int idx) const;
107 bool idxUp(unsigned int &, unsigned int &) const;
109 bool idxDown(unsigned int &, unsigned int &) const;
111 bool idxLeft(unsigned int &, unsigned int &) const;
113 bool idxRight(unsigned int &, unsigned int &) const;
115 bool idxFirst(unsigned int &, unsigned int &) const;
117 bool idxLast(unsigned int &, unsigned int &) const;
119 void idxDelete(unsigned int &, bool &, bool &);
121 void idxDeleteRange(unsigned int, unsigned int);
124 void addRow(unsigned int);
126 void delRow(unsigned int);
128 void addCol(unsigned int);
130 void delCol(unsigned int);
132 virtual void appendRow();
134 unsigned int index(unsigned int row, unsigned int col) const;
136 std::vector<unsigned int> idxBetween(unsigned int from, unsigned int to) const;
138 virtual int defaultColSpace(unsigned int) { return 10; }
140 virtual char defaultColAlign(unsigned int) { return 'c'; }
145 /// returns proper 'end of line' code for LaTeX
146 string eolString(unsigned int row) const;
147 /// returns proper 'end of column' code for LaTeX
148 string eocString(unsigned int col) const;
151 std::vector<RowInfo> rowinfo_;
153 std::vector<ColInfo> colinfo_;
155 char v_align_; // add approp. type