simplify InsetTabular::calculate_dimensions_of_cells a bit

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7302 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-07-17 09:25:06 +00:00
parent b853229344
commit bb0175e906
2 changed files with 15 additions and 17 deletions

View File

@ -257,7 +257,7 @@ void InsetTabular::read(Buffer const * buf, LyXLex & lex)
void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
if (mi.base.bv) { if (mi.base.bv) {
calculate_dimensions_of_cells(mi.base.bv, true); calculate_dimensions_of_cells(mi.base.bv);
//lyxerr << "InsetTabular::metrics, bv: " << mi.base.bv << endl; //lyxerr << "InsetTabular::metrics, bv: " << mi.base.bv << endl;
for (int i = 0; i < tabular.getNumberOfCells(); ++i) { for (int i = 0; i < tabular.getNumberOfCells(); ++i) {
tabular.cellinfo_of_cell(i)->inset.text_.bv_owner = mi.base.bv; tabular.cellinfo_of_cell(i)->inset.text_.bv_owner = mi.base.bv;
@ -437,7 +437,7 @@ void InsetTabular::insetUnlock(BufferView * bv)
void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what) const void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what) const
{ {
if (what == INIT) { if (what == INIT) {
calculate_dimensions_of_cells(bv, true); calculate_dimensions_of_cells(bv);
} }
if (!locked && what == CELL) if (!locked && what == CELL)
what = FULL; what = FULL;
@ -1228,22 +1228,18 @@ void InsetTabular::validate(LaTeXFeatures & features) const
} }
bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, bool reinit) const void InsetTabular::calculate_dimensions_of_cells(BufferView * bv) const
{ {
int cell = -1;
int maxAsc = 0;
int maxDesc = 0;
InsetText * inset;
bool changed = false;
// FIXME: since InsetText ignores this anyway, it doesn't // FIXME: since InsetText ignores this anyway, it doesn't
// matter what we pass it. Ugly // matter what we pass it. Ugly
LyXFont font; LyXFont font;
// if we have a locking_inset we should have to check only this cell for // if we have a locking_inset we should have to check only this cell for
// change so I'll try this to have a boost, but who knows ;) // change so I'll try this to have a boost, but who knows ;)
if ((need_update != INIT) && if (need_update != INIT &&
(the_locking_inset == tabular.getCellInset(actcell))) { the_locking_inset == tabular.getCellInset(actcell)) {
int maxAsc = 0;
int maxDesc = 0;
for(int i = 0; i < tabular.columns(); ++i) { for(int i = 0; i < tabular.columns(); ++i) {
Dimension dim; Dimension dim;
MetricsInfo mi(bv, font); MetricsInfo mi(bv, font);
@ -1251,11 +1247,14 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, bool reinit) c
maxAsc = max(dim.asc, maxAsc); maxAsc = max(dim.asc, maxAsc);
maxDesc = max(dim.des, maxDesc); maxDesc = max(dim.des, maxDesc);
} }
changed = tabular.setWidthOfCell(actcell, the_locking_inset->width(bv, font)); tabular.setWidthOfCell(actcell, the_locking_inset->width(bv, font));
changed = tabular.setAscentOfRow(actrow, maxAsc + ADD_TO_HEIGHT) || changed; tabular.setAscentOfRow(actrow, maxAsc + ADD_TO_HEIGHT);
changed = tabular.setDescentOfRow(actrow, maxDesc + ADD_TO_HEIGHT) || changed; tabular.setDescentOfRow(actrow, maxDesc + ADD_TO_HEIGHT);
return changed; return;
} }
int cell = -1;
bool changed = false;
for (int i = 0; i < tabular.rows(); ++i) { for (int i = 0; i < tabular.rows(); ++i) {
maxAsc = 0; maxAsc = 0;
maxDesc = 0; maxDesc = 0;
@ -1275,7 +1274,6 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, bool reinit) c
} }
if (changed) if (changed)
tabular.reinit(); tabular.reinit();
return changed;
} }

View File

@ -240,7 +240,7 @@ private:
/// ///
void lfunMouseMotion(FuncRequest const &); void lfunMouseMotion(FuncRequest const &);
/// ///
bool calculate_dimensions_of_cells(BufferView *, bool = false) const; void calculate_dimensions_of_cells(BufferView *) const;
/// ///
void drawCellLines(Painter &, int x, int baseline, void drawCellLines(Painter &, int x, int baseline,
int row, int cell) const; int row, int cell) const;