Starting fixing multicolumns draw on screen.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3629 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Vigna 2002-03-01 16:04:10 +00:00
parent 681da65923
commit 57bb1b916c
4 changed files with 41 additions and 26 deletions

View File

@ -9,6 +9,7 @@ src/converter.C
src/CutAndPaste.C src/CutAndPaste.C
src/debug.C src/debug.C
src/exporter.C src/exporter.C
src/ext_l10n.h
src/FontLoader.C src/FontLoader.C
src/frontends/controllers/biblio.C src/frontends/controllers/biblio.C
src/frontends/controllers/ButtonController.h src/frontends/controllers/ButtonController.h

View File

@ -1,3 +1,11 @@
2002-03-01 Juergen Vigna <jug@sad.it>
* tabular.C (SetWidthOfMulticolCell): changed to something better
I hope but still work in progress.
(recalculateMulticolumnsOfColumn): renamed function from
recalculateMulticolCells as it is more appropriate now.
(SetWidthOfCell): calculate multicols better.
2002-03-01 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr> 2002-03-01 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* minibuffer.C (MiniBuffer): reset timout to 6000, as it was before. * minibuffer.C (MiniBuffer): reset timout to 6000, as it was before.

View File

@ -3,7 +3,7 @@
* *
* LyX, The Document Processor * LyX, The Document Processor
* *
* Copyright 2000-2001 The LyX Team. * Copyright 2000-2002 The LyX Team.
* *
* @author: Jürgen Vigna * @author: Jürgen Vigna
* *
@ -620,6 +620,7 @@ bool LyXTabular::SetWidthOfMulticolCell(int cell, int new_width)
int const row = row_of_cell(cell); int const row = row_of_cell(cell);
int const column1 = column_of_cell(cell); int const column1 = column_of_cell(cell);
int const column2 = right_column_of_cell(cell); int const column2 = right_column_of_cell(cell);
int const old_val = cell_info[row][column2].width_of_cell;
// first set columns to 0 so we can calculate the right width // first set columns to 0 so we can calculate the right width
for (int i = column1; i <= column2; ++i) { for (int i = column1; i <= column2; ++i) {
@ -627,7 +628,6 @@ bool LyXTabular::SetWidthOfMulticolCell(int cell, int new_width)
} }
// set the width to MAX_WIDTH until width > 0 // set the width to MAX_WIDTH until width > 0
int width = (new_width + 2 * WIDTH_OF_LINE); int width = (new_width + 2 * WIDTH_OF_LINE);
int i = column1; int i = column1;
for (; i < column2 && width > column_info[i].width_of_column; ++i) { for (; i < column2 && width > column_info[i].width_of_column; ++i) {
cell_info[row][i].width_of_cell = column_info[i].width_of_column; cell_info[row][i].width_of_cell = column_info[i].width_of_column;
@ -636,25 +636,36 @@ bool LyXTabular::SetWidthOfMulticolCell(int cell, int new_width)
if (width > 0) { if (width > 0) {
cell_info[row][i].width_of_cell = width; cell_info[row][i].width_of_cell = width;
} }
if (old_val != cell_info[row][column2].width_of_cell) {
// in this case we have to recalculate all multicolumn cells which
// have this column as one of theirs but not as last one
recalculateMulticolumnsOfColumn(i);
}
return true; return true;
} }
void LyXTabular::recalculateMulticolCells(int cell, int new_width) void LyXTabular::recalculateMulticolumnsOfColumn(int column)
{ {
int const row = row_of_cell(cell); // the last column does not have to be recalculated because all
int const column1 = column_of_cell(cell); // multicolumns will have here there last multicolumn cell which
int const column2 = right_column_of_cell(cell); // always will have the whole rest of the width of the cell.
if (column > (columns_ - 2))
// first set columns to 0 so we can calculate the right width return;
int i = column1; for(int row = 0; row < rows_; ++row) {
for (; i <= column2; ++i) int mc = cell_info[row][column].multicolumn;
cell_info[row][i].width_of_cell = 0; int nmc = cell_info[row][column+1].multicolumn;
for (i = cell + 1; (i < numberofcells) && (!IsMultiColumn(i)); ++i) // we only have to update multicolumns which do not have this
; // column as their last column!
if (i < numberofcells) if (mc == CELL_BEGIN_OF_MULTICOLUMN ||
recalculateMulticolCells(i, GetWidthOfCell(i) - (2 * WIDTH_OF_LINE)); ((mc == CELL_PART_OF_MULTICOLUMN) &&
SetWidthOfMulticolCell(cell, new_width); (nmc == CELL_PART_OF_MULTICOLUMN)))
{
int const cellno = cell_info[row][column].cellno;
SetWidthOfMulticolCell(cellno,
GetWidthOfCell(cellno)-(2 * WIDTH_OF_LINE));
}
}
} }
@ -688,16 +699,11 @@ bool LyXTabular::SetWidthOfCell(int cell, int new_width)
width = (new_width + 2*WIDTH_OF_LINE + add_width); width = (new_width + 2*WIDTH_OF_LINE + add_width);
cell_info[row][column1].width_of_cell = width; cell_info[row][column1].width_of_cell = width;
tmp = calculate_width_of_column_NMC(column1); tmp = calculate_width_of_column_NMC(column1);
if (tmp)
recalculateMulticolumnsOfColumn(column1);
} }
if (tmp) { if (tmp) {
int i = 0; for (int i = 0; i < columns_; ++i)
for (; i<columns_; ++i)
calculate_width_of_column_NMC(i);
for (i = 0; (i < numberofcells) && !IsMultiColumn(i); ++i)
;
if (i < numberofcells)
recalculateMulticolCells(i, GetWidthOfCell(i)-(2 * WIDTH_OF_LINE));
for (i = 0; i < columns_; ++i)
calculate_width_of_column(i); calculate_width_of_column(i);
calculate_width_of_tabular(); calculate_width_of_tabular();
return true; return true;

View File

@ -533,7 +533,7 @@ private:
/// Returns true if a complete update is necessary, otherwise false /// Returns true if a complete update is necessary, otherwise false
bool SetWidthOfMulticolCell(int cell, int new_width); bool SetWidthOfMulticolCell(int cell, int new_width);
/// ///
void recalculateMulticolCells(int cell, int new_width); void recalculateMulticolumnsOfColumn(int column);
/// Returns true if change /// Returns true if change
bool calculate_width_of_column(int column); bool calculate_width_of_column(int column);
/// ///