X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_parinset.C;h=ae43ae750f15dc9641ea2f0641e91bcca957c7d3;hb=a7bfe9d7f1c112e4d502aaa9e7262f1866d723f7;hp=53d1befdf8907c2292607a0a943e557f0eec8f83;hpb=4203d759adcd9bdcd726c9b5b54f9cbd520c74b1;p=lyx.git diff --git a/src/mathed/math_parinset.C b/src/mathed/math_parinset.C index 53d1befdf8..ae43ae750f 100644 --- a/src/mathed/math_parinset.C +++ b/src/mathed/math_parinset.C @@ -1,5 +1,9 @@ #include +#ifdef __GNUG__ +#pragma implementation +#endif + #include "math_parinset.h" #include "math_iter.h" #include "array.h" @@ -80,67 +84,66 @@ MathParInset::draw(Painter & pain, int x, int y) data.GoBegin(); while (data.OK()) { data.GetPos(x, y); - byte cx = data.GetChar(); + byte const cx = data.GetChar(); if (cx >= ' ') { string const s = data.GetString(); drawStr(pain, data.fcode(), size(), x, y, s); mathed_char_height(LM_TC_CONST, size(), 'y', asc, des); limits = false; - } else { - if (cx == 0) - break; - if (MathIsInset(cx)) { - int yy = y; - MathedInset * p = data.GetInset(); - if (cx == LM_TC_UP) { - if (limits) { - x -= (xp > p->Width()) ? - p->Width() + (xp - p->Width()) / 2 : xp; - yy -= (asc + p->Descent() + 4); - } else - yy -= (p->Descent() > asc) ? - p->Descent() + 4 : asc; - } else if (cx == LM_TC_DOWN) { - if (limits) { - x -= (xp > p->Width()) ? - p->Width() + (xp - p->Width()) / 2 : xp; - yy += des + p->Ascent() + 2; - } else - yy += des + p->Ascent() / 2; - } else { - asc = p->Ascent(); - des = p->Descent(); - } - p->draw(pain, x, yy); - if (cx != LM_TC_UP && cx != LM_TC_DOWN) { - limits = p->GetLimits(); - if (limits) - xp = p->Width(); - } - data.Next(); - } else if (cx == LM_TC_TAB) { - if (cxp == cx - || cxp == LM_TC_CR || data.IsFirst()) { - pain.rectangle(x, y - df_asc, - df_width, df_asc, - LColor::mathline); - } - data.Next(); - limits = false; - } else if (cx == LM_TC_CR) { - if (cxp == LM_TC_TAB - || cxp == LM_TC_CR || data.IsFirst()) { - pain.rectangle(x, y - df_asc, - df_width, df_asc, - LColor::mathline); - } - data.Next(); - limits = false; - } else { - lyxerr << "GMathed Error: Unrecognized code[" << cx << "]" << endl; - break; + } else if (cx == 0) { + break; + } else if (MathIsInset(cx)) { + int yy = y; + MathedInset * p = data.GetInset(); + if (cx == LM_TC_UP) { + if (limits) { + x -= (xp > p->Width()) ? + p->Width() + (xp - p->Width()) / 2 : xp; + yy -= (asc + p->Descent() + 4); + } else + yy -= (p->Descent() > asc) ? + p->Descent() + 4 : asc; + } else if (cx == LM_TC_DOWN) { + if (limits) { + x -= (xp > p->Width()) ? + p->Width() + (xp - p->Width()) / 2 : xp; + yy += des + p->Ascent() + 2; + } else + yy += des + p->Ascent() / 2; + } else { + asc = p->Ascent(); + des = p->Descent(); } + p->draw(pain, x, yy); + if (cx != LM_TC_UP && cx != LM_TC_DOWN) { + limits = p->GetLimits(); + if (limits) + xp = p->Width(); + } + data.Next(); + } else if (cx == LM_TC_TAB) { + if (cxp == cx + || cxp == LM_TC_CR || data.IsFirst()) { + pain.rectangle(x, y - df_asc, + df_width, df_asc, + LColor::mathline); + } + data.Next(); + limits = false; + } else if (cx == LM_TC_CR) { + if (cxp == LM_TC_TAB + || cxp == LM_TC_CR || data.IsFirst()) { + pain.rectangle(x, y - df_asc, + df_width, df_asc, + LColor::mathline); + } + data.Next(); + limits = false; + } else { + lyxerr << "GMathed Error: Unrecognized code[" << cx << "]" << endl; + break; } + cxp = cx; } if (cxp == LM_TC_TAB || cxp == LM_TC_CR) { @@ -175,73 +178,72 @@ MathParInset::Metrics() while (data.OK()) { cx = data.GetChar(); if (cx >= ' ') { - string s = data.GetString(); + string const s = data.GetString(); mathed_string_height(data.fcode(), size(), s, asc, des); if (asc > ascent) ascent = asc; if (des > descent) descent = des; limits = false; mathed_char_height(LM_TC_CONST, size(), 'y', asc, des); - } else - if (MathIsInset(cx)) { - MathedInset * p = data.GetInset(); - p->SetStyle(size()); - p->Metrics(); - if (cx == LM_TC_UP) { - asc += (limits) ? p->Height() + 4: p->Ascent() + - ((p->Descent()>asc) ? p->Descent() - asc + 4: 0); - } else - if (cx == LM_TC_DOWN) { - des += ((limits) ? p->Height() + 4: p->Height() - p->Ascent() / 2); - } else { - asc = p->Ascent(); - des = p->Descent(); - } - if (asc > ascent) ascent = asc; - if (des > descent) descent = des; - if (cx!= LM_TC_UP && cx!= LM_TC_DOWN) - limits = p->GetLimits(); - data.Next(); - } else - if (cx == LM_TC_TAB) { - int x, y; - data.GetIncPos(x, y); - if (data.IsFirst() || cxp == LM_TC_TAB || cxp == LM_TC_CR) { - if (ascentSetStyle(size()); + p->Metrics(); + if (cx == LM_TC_UP) { + asc += (limits) ? p->Height() + 4: p->Ascent() + + ((p->Descent()>asc) ? p->Descent() - asc + 4: 0); + } else if (cx == LM_TC_DOWN) { + des += (limits ? p->Height() + 4 : p->Height() - p->Ascent() / 2); + } else { + asc = p->Ascent(); + des = p->Descent(); + } + if (asc > ascent) ascent = asc; + if (des > descent) descent = des; + if (cx!= LM_TC_UP && cx!= LM_TC_DOWN) + limits = p->GetLimits(); + data.Next(); + } else if (cx == LM_TC_TAB) { + int x; + int y; + data.GetIncPos(x, y); + if (data.IsFirst() || cxp == LM_TC_TAB || cxp == LM_TC_CR) { + if (ascent < df_asc) ascent = df_asc; + tb = x; + } + data.setTab(x - tb, tab); + tb = x; + ++tab; + limits = false; + data.Next(); + } else if (cx == LM_TC_CR) { + if (tb > 0) { + int x; + int y; + data.GetIncPos(x, y); + if (data.IsFirst() || cxp == LM_TC_TAB || cxp == LM_TC_CR) { + if (ascent < df_asc) ascent = df_asc; tb = x; - ++tab; - limits = false; - data.Next(); - } else - if (cx == LM_TC_CR) { - if (tb > 0) { - int x, y; - data.GetIncPos(x, y); - if (data.IsFirst() || cxp == LM_TC_TAB || cxp == LM_TC_CR) { - if (ascent