From 8ccdbef7a0d4f7f09cf4de4ca1873d8a497231cb Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Mon, 12 Feb 2001 11:56:08 +0000 Subject: [PATCH] Correct drawing of the multline environment. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1485 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 6 ++++++ src/mathed/formula.C | 7 +++++-- src/mathed/math_cursor.C | 2 +- src/mathed/math_defs.h | 2 ++ src/mathed/math_inset.C | 12 ++++++++++++ 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 4a9e426728..4535c63426 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,9 @@ +2001-02-12 Dekel Tsur + + * formula.C (LocalDispatch): Change the default action of + break-line to create an align* environment instead of eqnarray*. + + * math_inset.C (Metrics): Correct drawing of the multline environment. 2001-02-12 André Pönitz * array.[hC]: replace private variable maxsize_ with call diff --git a/src/mathed/formula.C b/src/mathed/formula.C index ac6d2aa752..0e4b64c45d 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -76,6 +76,7 @@ MathedCursor * InsetFormula::mathcursor = 0; int MathedInset::df_asc; int MathedInset::df_des; int MathedInset::df_width; +int MathedInset::workWidth; static @@ -407,8 +408,9 @@ int InsetFormula::descent(BufferView *, LyXFont const &) const } -int InsetFormula::width(BufferView *, LyXFont const & f) const +int InsetFormula::width(BufferView * bv, LyXFont const & f) const { + MathedInset::workWidth = bv->workWidth(); lfont_size = f.size(); par->Metrics(); return par->Width(); //+2; @@ -418,6 +420,7 @@ int InsetFormula::width(BufferView *, LyXFont const & f) const void InsetFormula::draw(BufferView * bv, LyXFont const & f, int baseline, float & x, bool) const { + MathedInset::workWidth = bv->workWidth(); Painter & pain = bv->painter(); // Seems commenting out solves a problem. LyXFont font = mathed_get_font(LM_TC_TEXTRM, LM_ST_TEXT); @@ -790,7 +793,7 @@ InsetFormula::LocalDispatch(BufferView * bv, case LFUN_BREAKLINE: { bv->lockedInsetStoreUndo(Undo::INSERT); - byte c = arg.empty() ? 'e' : arg[0]; + byte c = arg.empty() ? '1' : arg[0]; mathcursor->Insert(c, LM_TC_CR); if (!label.empty()) { mathcursor->setLabel(label); diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index e8d48803a2..f05d9eb291 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -352,7 +352,7 @@ MathMatrixInset * create_multiline(short int type, int cols) case LM_OT_MULTLINE: case LM_OT_MULTLINEN: columns = 1; - align = "c"; // This is incorrect! + align = "C"; break; case LM_OT_MPAR: case LM_OT_MPARN: diff --git a/src/mathed/math_defs.h b/src/mathed/math_defs.h index 2a01d91fd2..47dd114357 100644 --- a/src/mathed/math_defs.h +++ b/src/mathed/math_defs.h @@ -263,6 +263,8 @@ class MathedInset { virtual void SetStyle(short st) { size = st; } // Metrics(); /// virtual void SetName(string const & n) { name = n; } + /// + static int workWidth; protected: /// string name; diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index d09a80d01e..58af303bb7 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -468,6 +468,10 @@ void MathMatrixInset::Metrics() 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; @@ -491,6 +495,14 @@ void MathMatrixInset::Metrics() 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);