mathed45.diff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1695 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-03-06 17:44:53 +00:00
parent c7aeeae2cb
commit 2338154427

View File

@ -40,7 +40,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset const & mt)
v_align_(mt.v_align_), h_align_(mt.h_align_) v_align_(mt.v_align_), h_align_(mt.h_align_)
{ {
array = mt.GetData(); array = mt.GetData();
if (mt.row_.data_ != 0) { if (!mt.row_.empty()) {
MathedRowSt * ro = 0; MathedRowSt * ro = 0;
MathedRowSt * mrow = mt.row_.data_; MathedRowSt * mrow = mt.row_.data_;
@ -74,6 +74,7 @@ MathMatrixInset::~MathMatrixInset()
} }
MathedInset * MathMatrixInset::Clone() MathedInset * MathMatrixInset::Clone()
{ {
return new MathMatrixInset(*this); return new MathMatrixInset(*this);
@ -132,47 +133,43 @@ void MathMatrixInset::draw(Painter & pain, int x, int baseline)
void MathMatrixInset::Metrics() void MathMatrixInset::Metrics()
{ {
if (!row_.data_) { if (row_.empty()) {
// lyxerr << " MIDA "; // lyxerr << " MIDA ";
MathedXIter it(this); MathedXIter it(this);
row_ = it.adjustVerticalSt(); row_ = it.adjustVerticalSt();
} }
// Clean the arrays // Clean the arrays
MathedRowSt * cxrow = row_.data_; for (MathedRowContainer::iterator it = row_.begin(); it; ++it)
while (cxrow) {
for (int i = 0; i <= nc_; ++i) for (int i = 0; i <= nc_; ++i)
cxrow->setTab(i, 0); it->setTab(i, 0);
cxrow = cxrow->getNext();
}
// Basic metrics // Basic metrics
MathParInset::Metrics(); MathParInset::Metrics();
if (nc_ <= 1 && !row_.data_->getNext()) { MathedRowContainer::iterator cxrow = row_.begin();
row_.data_->ascent(ascent); if (nc_ <= 1 && cxrow.is_last()) {
row_.data_->descent(descent); cxrow->ascent(ascent);
cxrow->descent(descent);
} }
// Vertical positions of each row // Vertical positions of each row
cxrow = row_.data_; MathedRowContainer::iterator cprow = cxrow;
MathedRowSt * cprow = 0;
int h = 0; int h = 0;
while (cxrow) { for ( ; cxrow; ++cxrow) {
for (int i = 0; i < nc_; ++i) { for (int i = 0; i < nc_; ++i) {
if (cxrow == row_.data_ || ws_[i] < cxrow->getTab(i)) if (cxrow == row_.begin() || ws_[i] < cxrow->getTab(i))
ws_[i] = cxrow->getTab(i); ws_[i] = cxrow->getTab(i);
if (cxrow->getNext() == 0 && ws_[i] == 0) if (cxrow.is_last() && ws_[i] == 0)
ws_[i] = df_width; ws_[i] = df_width;
} }
cxrow->setBaseline((cxrow == row_.data_) ? cxrow->setBaseline((cxrow == row_.begin()) ?
cxrow->ascent() : cxrow->ascent() :
cxrow->ascent() + cprow->descent() cxrow->ascent() + cprow->descent()
+ MATH_ROWSEP + cprow->getBaseline()); + MATH_ROWSEP + cprow->getBaseline());
h += cxrow->ascent() + cxrow->descent() + MATH_ROWSEP; h += cxrow->ascent() + cxrow->descent() + MATH_ROWSEP;
cprow = cxrow; cprow = cxrow;
cxrow = cxrow->getNext();
} }
int const hl = Descent(); int const hl = Descent();
@ -181,7 +178,7 @@ void MathMatrixInset::Metrics()
// Compute vertical align // Compute vertical align
switch (v_align_) { switch (v_align_) {
case 't': case 't':
ascent = row_.data_->getBaseline(); ascent = row_.begin()->getBaseline();
break; break;
case 'b': case 'b':
ascent = h - hl; ascent = h - hl;
@ -202,9 +199,8 @@ void MathMatrixInset::Metrics()
ws_[0] = 7 * workWidth / 8; ws_[0] = 7 * workWidth / 8;
// Adjust local tabs // Adjust local tabs
cxrow = row_.data_;
width = MATH_COLSEP; width = MATH_COLSEP;
while (cxrow) { for (cxrow = row_.begin(); cxrow; ++cxrow) {
int rg = MATH_COLSEP; int rg = MATH_COLSEP;
int lf = 0; int lf = 0;
for (int i = 0; i < nc_; ++i) { for (int i = 0; i < nc_; ++i) {
@ -225,9 +221,9 @@ void MathMatrixInset::Metrics()
lf = ws_[i] - cxrow->getTab(i); lf = ws_[i] - cxrow->getTab(i);
break; break;
case 'C': case 'C':
if (cxrow == row_.data_) if (cxrow == row_.begin())
lf = 0; lf = 0;
else if (!cxrow->getNext()) else if (cxrow.is_last())
lf = ws_[i] - cxrow->getTab(i); lf = ws_[i] - cxrow->getTab(i);
else else
lf = (ws_[i] - cxrow->getTab(i))/2; lf = (ws_[i] - cxrow->getTab(i))/2;
@ -236,11 +232,10 @@ void MathMatrixInset::Metrics()
int const ww = (isvoid) ? lf : lf + cxrow->getTab(i); int const ww = (isvoid) ? lf : lf + cxrow->getTab(i);
cxrow->setTab(i, lf + rg); cxrow->setTab(i, lf + rg);
rg = ws_[i] - ww + MATH_COLSEP; rg = ws_[i] - ww + MATH_COLSEP;
if (cxrow == row_.data_) if (cxrow == row_.begin())
width += ws_[i] + MATH_COLSEP; width += ws_[i] + MATH_COLSEP;
} }
cxrow->setBaseline(cxrow->getBaseline() - ascent); cxrow->setBaseline(cxrow->getBaseline() - ascent);
cxrow = cxrow->getNext();
} }
} }