- delete[] ws;
-
- MathedRowSt * r = row;
- while (r) {
- MathedRowSt * q = r->getNext();
- delete r;
- r = q;
- }
-}
-
-
-MathedInset * MathMatrixInset::Clone()
-{
- return new MathMatrixInset(this);
-}
-
-
-void MathMatrixInset::SetAlign(char vv, string const & hh)
-{
- v_align = vv;
- h_align = hh.substr(0, nc); // usr just h_align = hh; perhaps
-}
-
-
-// Check the number of tabs and crs
-void MathMatrixInset::SetData(MathedArray * a)
-{
- if (!a) return;
- MathedIter it(a);
- int nn = nc - 1;
- nr = 1;
- // count tabs per row
- while (it.OK()) {
- if (it.IsTab()) {
- if (nn < 0) {
- it.Delete();
- continue;
- } else {
-// it.Next();
- --nn;
- }
- }
- if (it.IsCR()) {
- while (nn > 0) {
- it.Insert(' ', LM_TC_TAB);
- --nn;
- }
- nn = nc - 1;
- ++nr;
- }
- it.Next();
- }
- it.Reset();
-
- // Automatically inserts tabs around bops
- // DISABLED because it's very easy to insert tabs
- array = a;
-}
-
-
-void MathMatrixInset::draw(Painter & pain, int x, int baseline)
-{
- MathParInset::draw(pain, x, baseline);
-}
-
-
-void MathMatrixInset::Metrics()
-{
- int i, hl, h = 0;
- MathedRowSt * cprow= 0;
-
- if (!row) {
-// lyxerr << " MIDA ";
- MathedXIter it(this);
- row = it.adjustVerticalSt();
- }
-
- // Clean the arrays
- MathedRowSt * cxrow = row;
- while (cxrow) {
- for (i = 0; i <= nc; ++i) cxrow->setTab(i, 0);
- cxrow = cxrow->getNext();
- }
-
- // Basic metrics
- MathParInset::Metrics();
-
- if (nc <= 1 && !row->getNext()) {
- row->ascent(ascent);
- row->descent(descent);
- }
-
- // Vertical positions of each row
- cxrow = row;
- while (cxrow) {
- for (i = 0; i < nc; ++i) {
- if (cxrow == row || ws[i] < cxrow->getTab(i))
- ws[i] = cxrow->getTab(i);
- if (cxrow->getNext() == 0 && ws[i] == 0) ws[i] = df_width;
- }
-
- cxrow->setBaseline((cxrow == row) ?
- cxrow->ascent() :
- cxrow->ascent() + cprow->descent()
- + MATH_ROWSEP + cprow->getBaseline());
- h += cxrow->ascent() + cxrow->descent() + MATH_ROWSEP;
- cprow = cxrow;
- cxrow = cxrow->getNext();
- }
-
- hl = Descent();
- h -= MATH_ROWSEP;
-
- // Compute vertical align
- switch (v_align) {
- case 't': ascent = row->getBaseline(); break;
- case 'b': ascent = h - hl; break;
- default: ascent = (row->getNext()) ? h / 2: h - hl; break;
- }
- descent = h - ascent + 2;
-
- // Increase ws[i] for 'R' columns (except the first one)
- for (i = 1; i < nc; ++i)
- if (h_align[i] == 'R')
- ws[i] += 10*df_width;
- // Increase ws[i] for 'C' column
- if (h_align[0] == 'C')
- if (ws[0] < 7*workWidth/8)
- ws[0] = 7*workWidth/8;
-
- // Adjust local tabs
- cxrow = row;
- width = MATH_COLSEP;
- while (cxrow) {
- int rg = MATH_COLSEP, ww, lf = 0; //, * w = cxrow->w;
- for (i = 0; i < nc; ++i) {
- bool isvoid = false;
- if (cxrow->getTab(i) <= 0) {
- cxrow->setTab(i, df_width);
- isvoid = true;
- }
- switch (h_align[i]) {
- case 'l':
- lf = 0;
- break;
- case 'c':
- lf = (ws[i] - cxrow->getTab(i))/2;
- break;
- case 'r':
- case 'R':
- lf = ws[i] - cxrow->getTab(i);
- break;
- case 'C':
- if (cxrow == row)
- lf = 0;
- else if (!cxrow->getNext())
- lf = ws[i] - cxrow->getTab(i);
- else
- lf = (ws[i] - cxrow->getTab(i))/2;
- break;
- }
- ww = (isvoid) ? lf : lf + cxrow->getTab(i);
- cxrow->setTab(i, lf + rg);
- rg = ws[i] - ww + MATH_COLSEP;
- if (cxrow == row) width += ws[i] + MATH_COLSEP;
- }
- cxrow->setBaseline(cxrow->getBaseline() - ascent);
- cxrow = cxrow->getNext();
- }
-}
-
-
-MathAccentInset::MathAccentInset(byte cx, MathedTextCodes f, int cd, short st)
- : MathedInset("", LM_OT_ACCENT, st), c(cx), fn(f), code(cd)
-{
- inset = 0;
-}
-
-
-MathAccentInset::MathAccentInset(MathedInset *ins, int cd, short st)
- : MathedInset("", LM_OT_ACCENT, st),
- c(0), fn(LM_TC_MIN), code(cd), inset(ins) {}
-
-
-MathAccentInset::~MathAccentInset()
-{
- delete inset;
-}
-
-
-MathedInset * MathAccentInset::Clone()
-{
- MathAccentInset * p;
-
- if (inset)
- p = new MathAccentInset(inset->Clone(), code, GetStyle());
- else
- p = new MathAccentInset(c, fn, code, GetStyle());
-
- return p;
-}
-
-
-MathBigopInset::MathBigopInset(string const & nam, int id, short st)
- : MathedInset(nam, LM_OT_BIGOP, st), sym(id)