From 57bb1b916ccf60ea4120e83cc20192300c83c7f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Fri, 1 Mar 2002 16:04:10 +0000 Subject: [PATCH] Starting fixing multicolumns draw on screen. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3629 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 1 + src/ChangeLog | 8 ++++++++ src/tabular.C | 56 ++++++++++++++++++++++++++++---------------------- src/tabular.h | 2 +- 4 files changed, 41 insertions(+), 26 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index fc7dae139a..eda8242397 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -9,6 +9,7 @@ src/converter.C src/CutAndPaste.C src/debug.C src/exporter.C +src/ext_l10n.h src/FontLoader.C src/frontends/controllers/biblio.C src/frontends/controllers/ButtonController.h diff --git a/src/ChangeLog b/src/ChangeLog index 405652395d..8864bbaa6c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2002-03-01 Juergen Vigna + + * 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 * minibuffer.C (MiniBuffer): reset timout to 6000, as it was before. diff --git a/src/tabular.C b/src/tabular.C index e0ce764917..de046eab70 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -3,7 +3,7 @@ * * LyX, The Document Processor * - * Copyright 2000-2001 The LyX Team. + * Copyright 2000-2002 The LyX Team. * * @author: Jürgen Vigna * @@ -620,14 +620,14 @@ bool LyXTabular::SetWidthOfMulticolCell(int cell, int new_width) int const row = row_of_cell(cell); int const column1 = 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 for (int i = column1; i <= column2; ++i) { cell_info[row][i].width_of_cell = 0; } // set the width to MAX_WIDTH until width > 0 int width = (new_width + 2 * WIDTH_OF_LINE); - int i = column1; for (; i < column2 && width > column_info[i].width_of_column; ++i) { 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) { 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; } -void LyXTabular::recalculateMulticolCells(int cell, int new_width) +void LyXTabular::recalculateMulticolumnsOfColumn(int column) { - int const row = row_of_cell(cell); - int const column1 = column_of_cell(cell); - int const column2 = right_column_of_cell(cell); - - // first set columns to 0 so we can calculate the right width - int i = column1; - for (; i <= column2; ++i) - cell_info[row][i].width_of_cell = 0; - for (i = cell + 1; (i < numberofcells) && (!IsMultiColumn(i)); ++i) - ; - if (i < numberofcells) - recalculateMulticolCells(i, GetWidthOfCell(i) - (2 * WIDTH_OF_LINE)); - SetWidthOfMulticolCell(cell, new_width); + // the last column does not have to be recalculated because all + // multicolumns will have here there last multicolumn cell which + // always will have the whole rest of the width of the cell. + if (column > (columns_ - 2)) + return; + for(int row = 0; row < rows_; ++row) { + int mc = cell_info[row][column].multicolumn; + int nmc = cell_info[row][column+1].multicolumn; + // we only have to update multicolumns which do not have this + // column as their last column! + if (mc == CELL_BEGIN_OF_MULTICOLUMN || + ((mc == CELL_PART_OF_MULTICOLUMN) && + (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); cell_info[row][column1].width_of_cell = width; tmp = calculate_width_of_column_NMC(column1); + if (tmp) + recalculateMulticolumnsOfColumn(column1); } if (tmp) { - int i = 0; - for (; i