From: Jürgen Vigna Date: Wed, 8 Aug 2001 13:29:13 +0000 (+0000) Subject: More fixes to various bug reports. X-Git-Tag: 1.6.10~20892 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=86e4a9bc8aadab907061da24ca6c0f4b05198f7c;p=features.git More fixes to various bug reports. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2453 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView2.C b/src/BufferView2.C index acef2517b3..c7f58f9bf6 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -407,7 +407,7 @@ bool BufferView::lockInset(UpdatableInset * inset) void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc) { - if (theLockingInset() && available()) { + if (available() && theLockingInset()) { LyXCursor cursor = text->cursor; if ((cursor.pos() - 1 >= 0) && (cursor.par()->getChar(cursor.pos() - 1) == @@ -415,7 +415,7 @@ void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc) (cursor.par()->getInset(cursor.pos() - 1) == theLockingInset()->getLockingInset())) text->setCursor(this, cursor, - cursor.par(), cursor.pos() - 1); + cursor.par(), cursor.pos() - 1); LyXScreen::Cursor_Shape shape = LyXScreen::BAR_SHAPE; LyXText * txt = getLyXText(); if (theLockingInset()->getLockingInset()->lyxCode() == diff --git a/src/ChangeLog b/src/ChangeLog index f4cabfd318..e8775d62e8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2001-08-08 Juergen Vigna + + * tabular.C (SetWidthOfCell): fixed special case where the width + was not updated! + (LeftLine): handle '|' in align_special. + (RightLine): ditto + (LeftAlreadyDrawed): ditto + (SetWidthOfCell): ditto + 2001-08-07 Juergen Vigna * lyx_main.C (readUIFile): fixed some forgotten lowercase! diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index f3840715a6..86e9b6df5b 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,23 @@ +2001-08-08 Juergen Vigna + + * insettabular.C (setPos): fixed wrong actrow < rows() check. + + * insettext.C (insetUnlock): remove double-space on inset unlock. + + * insetcollapsable.C (draw): fix returned x when label > inset-width. + + * insettabular.C (update): fixed cursor positon after an insert. + (insetAllowed): do not allow to insert insets when not inside the + inset! + (draw): clear below an inset too as it could have changed height. + + * inset.C (getMaxWidth): fixed width for inset in inset. + + * insettext.C (update): small fix. + + * insettabular.C (tabularFeatures): added selection support to + DELETE_ROW/DELETE_COLUMN. + 2001-08-07 Juergen Vigna * inset.C (getMaxWidth): recoded and all it's implementations! diff --git a/src/insets/inset.C b/src/insets/inset.C index 88a40ce70f..93e47e3114 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -320,11 +320,6 @@ int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const if (w < 0) { return -1; } - if (owner()) { - if (topx_set) // this makes only sense if we have a top_x - w = w - top_x + owner()->x(); - return w; - } // check for margins left/right and extra right margin "const 5" if ((w - ((2 * TEXT_TO_INSET_OFFSET) + 5)) >= 0) w -= (2 * TEXT_TO_INSET_OFFSET) + 5; @@ -333,6 +328,9 @@ int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const w = 10; // minimum I require!!! } else { w -= top_x; + if (owner()) { + w += owner()->x(); + } } } else if (w < 10) { w = 10; diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 91938ae654..2bbf5d79d9 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -226,6 +226,8 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, inset.draw(bv, f, bl + descent_collapsed() + inset.ascent(bv, f), x, cleared); + if (x < (top_x + button_length + TEXT_TO_INSET_OFFSET)) + x = top_x + button_length + TEXT_TO_INSET_OFFSET; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index b3f049963b..2a4cca3120 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -249,7 +249,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, x += static_cast(scroll()); #endif if (!cleared && ((need_update == INIT) || (need_update == FULL) || - (top_x != int(x)) || (top_baseline != baseline))) { + (top_x != int(x)) || (top_baseline != baseline))) + { int h = ascent(bv, font) + descent(bv, font); int const tx = display() || !owner() ? 0 : top_x; int w = tx ? width(bv, font) : pain.paperWidth(); @@ -314,11 +315,12 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, Inset * inset = tabular->GetCellInset(cell); for (i = 0; inset != the_locking_inset && i < tabular->rows(); - ++i) { + ++i) + { for (j = 0; - inset != the_locking_inset - && j < tabular->columns(); - ++j) { + inset != the_locking_inset && j < tabular->columns(); + ++j) + { if (tabular->IsPartOfMultiColumn(i, j)) continue; nx += tabular->GetWidthOfColumn(cell); @@ -355,14 +357,9 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, } float dx = nx + tabular->GetBeginningOfTextInCell(cell); float cx = dx; - //cx = dx = nx + tabular->GetBeginningOfTextInCell(cell); tabular->GetCellInset(cell)->draw(bv, font, baseline, dx, false); -#if 0 - if (bv->text->status == LyXText::CHANGED_IN_DRAW) - return; -#endif // clear only if we didn't have a change - if (need_update == CELL) { + if (bv->text->status() != LyXText::CHANGED_IN_DRAW) { // clear before the inset pain.fillRectangle( nx + 1, @@ -382,6 +379,18 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, tabular->GetAscentOfRow(i) + tabular->GetDescentOfRow(i) - 1, backgroundColor()); + // clear below the inset + pain.fillRectangle( + nx + 1, + baseline + the_locking_inset->descent(bv, font) + 1, + tabular->GetWidthOfColumn(cell) - + tabular->GetAdditionalWidth(cell) - 1, + tabular->GetAscentOfRow(i) + + tabular->GetDescentOfRow(i) - + the_locking_inset->ascent(bv, font) - + the_locking_inset->descent(bv, font) - + TEXT_TO_INSET_OFFSET - 1, + backgroundColor()); } } x -= ADD_TO_TABULAR_WIDTH; @@ -461,15 +470,18 @@ void InsetTabular::drawCellSelection(Painter & pain, int x, int baseline, void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit) { if (in_update) { - if (reinit && owner()) { - owner()->update(bv, font, true); + if (reinit) { + resetPos(bv); + if (owner()) + owner()->update(bv, font, true); } return; } in_update = true; if (reinit) { need_update = INIT; - calculate_dimensions_of_cells(bv, font, true); + if (calculate_dimensions_of_cells(bv, font, true)) + resetPos(bv); if (owner()) owner()->update(bv, font, true); in_update = false; @@ -596,14 +608,10 @@ bool InsetTabular::lockInsetInInset(BufferView * bv, UpdatableInset * inset) lyxerr[Debug::INSETS] << "OK" << endl; the_locking_inset = tabular->GetCellInset(actcell); resetPos(bv); - inset_x = cursor_.x() - top_x + tabular->GetBeginningOfTextInCell(actcell); - inset_y = cursor_.y(); return true; } else if (the_locking_inset && (the_locking_inset == inset)) { lyxerr[Debug::INSETS] << "OK" << endl; resetPos(bv); - inset_x = cursor_.x() - top_x + tabular->GetBeginningOfTextInCell(actcell); - inset_y = cursor_.y(); } else if (the_locking_inset) { lyxerr[Debug::INSETS] << "MAYBE" << endl; return the_locking_inset->lockInsetInInset(bv, inset); @@ -1156,8 +1164,8 @@ void InsetTabular::validate(LaTeXFeatures & features) const bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, - LyXFont const & font, - bool reinit) const + LyXFont const & font, + bool reinit) const { int cell = -1; int maxAsc = 0; @@ -1180,9 +1188,6 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, changed = tabular->SetDescentOfRow(actrow, maxDesc + ADD_TO_HEIGHT) || changed; return changed; } -#if 0 - cur_cell = -1; -#endif for (int i = 0; i < tabular->rows(); ++i) { maxAsc = 0; maxDesc = 0; @@ -1281,7 +1286,7 @@ void InsetTabular::setPos(BufferView * bv, int x, int y) const int ly = tabular->GetDescentOfRow(actrow); // first search the right row - while((ly < y) && (actrow < tabular->rows())) { + while((ly < y) && ((actrow+1) < tabular->rows())) { cursor_.y(cursor_.y() + tabular->GetDescentOfRow(actrow) + tabular->GetAscentOfRow(actrow + 1) + tabular->GetAdditionalHeight(actrow + 1)); @@ -1293,22 +1298,10 @@ void InsetTabular::setPos(BufferView * bv, int x, int y) const // now search the right column int lx = tabular->GetWidthOfColumn(actcell) - tabular->GetAdditionalWidth(actcell); -#if 0 -#ifdef WITH_WARNINGS -#warning Jürgen, can you rewrite this to _not_ use the sequencing operator. (Lgb) -#endif - for (; !tabular->IsLastCellInRow(actcell) && (lx < x); - ++actcell,lx += tabular->GetWidthOfColumn(actcell) + - tabular->GetAdditionalWidth(actcell - 1)); -#else - // Jürgen, you should check that this is correct. (Lgb) -#warning Jürgen, please check. (Lgb) for (; !tabular->IsLastCellInRow(actcell) && lx < x; ++actcell) { lx += tabular->GetWidthOfColumn(actcell + 1) + tabular->GetAdditionalWidth(actcell); } - -#endif cursor_.x(lx - tabular->GetWidthOfColumn(actcell) + top_x + 2); resetPos(bv); } @@ -1384,6 +1377,10 @@ void InsetTabular::resetPos(BufferView * bv) const scroll(bv, old_x - cursor_.x()); updateLocal(bv, FULL, false); } + if (the_locking_inset) { + inset_x = cursor_.x() - top_x + tabular->GetBeginningOfTextInCell(actcell); + inset_y = cursor_.y(); + } if ((!the_locking_inset || !the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)) && actcell != oldcell) { @@ -1592,8 +1589,8 @@ bool InsetTabular::tabularFeatures(BufferView * bv, string const & what) void InsetTabular::tabularFeatures(BufferView * bv, - LyXTabular::Feature feature, - string const & value) + LyXTabular::Feature feature, + string const & value) { int sel_col_start; int sel_col_end; @@ -1675,6 +1672,7 @@ void InsetTabular::tabularFeatures(BufferView * bv, case LyXTabular::SET_SPECIAL_COLUMN: case LyXTabular::SET_SPECIAL_MULTI: tabular->SetAlignSpecial(actcell,value,feature); + updateLocal(bv, FULL, true); break; case LyXTabular::APPEND_ROW: // append the row into the tabular @@ -1691,19 +1689,23 @@ void InsetTabular::tabularFeatures(BufferView * bv, break; case LyXTabular::DELETE_ROW: unlockInsetInInset(bv, the_locking_inset); - tabular->DeleteRow(tabular->row_of_cell(actcell)); - if ((row+1) > tabular->rows()) - --row; - actcell = tabular->GetCellNumber(row, column); + for(int i = sel_row_start; i <= sel_row_end; ++i) { + tabular->DeleteRow(sel_row_start); + } + if ((sel_row_start) > tabular->rows()) + --sel_row_start; + actcell = tabular->GetCellNumber(sel_row_start, column); clearSelection(); updateLocal(bv, INIT, true); break; case LyXTabular::DELETE_COLUMN: unlockInsetInInset(bv, the_locking_inset); - tabular->DeleteColumn(tabular->column_of_cell(actcell)); - if ((column+1) > tabular->columns()) - --column; - actcell = tabular->GetCellNumber(row, column); + for(int i = sel_col_start; i <= sel_col_end; ++i) { + tabular->DeleteColumn(sel_col_start); + } + if ((sel_col_start+1) > tabular->columns()) + --sel_col_start; + actcell = tabular->GetCellNumber(row, sel_col_start); clearSelection(); updateLocal(bv, INIT, true); break; @@ -2596,3 +2598,11 @@ bool InsetTabular::searchBackward(BufferView * bv, string const & str, return searchBackward(bv, str, cs, mw); #endif } + + +bool InsetTabular::insetAllowed(Inset::Code code) const +{ + if (the_locking_inset) + return the_locking_inset->insetAllowed(code); + return false; +} diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 2d7a61b4f6..4c4b64a81b 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -125,9 +125,7 @@ public: /// bool insertInset(BufferView *, Inset *); /// - bool insetAllowed(Inset::Code) const { - return the_locking_inset != 0; - } + bool insetAllowed(Inset::Code code) const; /// bool isTextInset() const { return true; } /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index c34e618e2c..afb5c52623 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -515,6 +515,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit) { if (in_update) { if (reinit && owner()) { + reinitLyXText(); owner()->update(bv, font, true); } return; @@ -522,11 +523,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit) in_update = true; if (reinit || need_update == INIT) { need_update |= FULL; -#if 0 - resizeLyXText(bv); -#else reinitLyXText(); -#endif if (owner()) owner()->update(bv, font, true); in_update = false; @@ -743,6 +740,8 @@ void InsetText::insetUnlock(BufferView * bv) ->cursor.par()->getLayout()); } else bv->owner()->setLayout(bv->text->cursor.par()->getLayout()); + // hack for deleteEmptyParMech + lt->setCursor(bv, par, 0); updateLocal(bv, code, false); if (clear) lt = 0; diff --git a/src/tabular.C b/src/tabular.C index 6f936a041c..833997d9fc 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -16,6 +16,9 @@ #pragma implementation #endif +// temporary until verified (08/08/2001 Jug) +#define SPECIAL_COLUM_HANDLING 1 + #include #include @@ -435,17 +438,43 @@ bool LyXTabular::BottomLine(int cell, bool onlycolumn) const bool LyXTabular::LeftLine(int cell, bool onlycolumn) const { - if (!onlycolumn && IsMultiColumn(cell)) + if (!onlycolumn && IsMultiColumn(cell)) { +#ifdef SPECIAL_COLUM_HANDLING + if (cellinfo_of_cell(cell)->align_special.empty()) + return cellinfo_of_cell(cell)->left_line; + return prefixIs(frontStrip(cellinfo_of_cell(cell)->align_special), "|"); +#else return cellinfo_of_cell(cell)->left_line; +#endif + } +#ifdef SPECIAL_COLUM_HANDLING + if (column_info[column_of_cell(cell)].align_special.empty()) + return column_info[column_of_cell(cell)].left_line; + return prefixIs(frontStrip(column_info[column_of_cell(cell)].align_special), "|"); +#else return column_info[column_of_cell(cell)].left_line; +#endif } bool LyXTabular::RightLine(int cell, bool onlycolumn) const { - if (!onlycolumn && IsMultiColumn(cell)) + if (!onlycolumn && IsMultiColumn(cell)) { +#ifdef SPECIAL_COLUM_HANDLING + if (cellinfo_of_cell(cell)->align_special.empty()) + return cellinfo_of_cell(cell)->right_line; + return suffixIs(strip(cellinfo_of_cell(cell)->align_special), "|"); +#else return cellinfo_of_cell(cell)->right_line; +#endif + } +#ifdef SPECIAL_COLUM_HANDLING + if (column_info[column_of_cell(cell)].align_special.empty()) + return column_info[right_column_of_cell(cell)].right_line; + return suffixIs(strip(column_info[column_of_cell(cell)].align_special), "|"); +#else return column_info[right_column_of_cell(cell)].right_line; +#endif } @@ -478,7 +507,11 @@ bool LyXTabular::LeftAlreadyDrawed(int cell) const LyXTabular::CELL_PART_OF_MULTICOLUMN)); if (GetAdditionalWidth(cell_info[row][column].cellno)) return false; +#ifdef SPECIAL_COLUM_HANDLING return column_info[column].right_line; +#else + return RightLine(cell_info[row][column].cellno, true); +#endif } return false; } @@ -527,11 +560,14 @@ int LyXTabular::GetAdditionalWidth(int cell) const // internally already set in SetWidthOfCell // used to get it back in text.C int const col = right_column_of_cell(cell); - if (col < columns_ - 1 && column_info[col].right_line && - column_info[col+1].left_line) + int const row = row_of_cell(cell); + if (col < columns_ - 1 && RightLine(cell, true) && + LeftLine(cell_info[row][col+1].cellno, true)) // column_info[col+1].left_line) + { return WIDTH_OF_LINE; - else + } else { return 0; + } } @@ -608,17 +644,28 @@ bool LyXTabular::SetWidthOfCell(int cell, int new_width) int const column1 = column_of_cell(cell); bool tmp = false; int width = 0; + int add_width = 0; - if (GetWidthOfCell(cell) == (new_width+2*WIDTH_OF_LINE)) +#ifdef SPECIAL_COLUM_HANDLING + if (RightLine(cell_info[row][column1].cellno, true) && + (column1 < columns_-1) && + LeftLine(cell_info[row][column1+1].cellno, true)) +#else + if (column_info[column1].right_line && (column1 < columns_-1) && + column_info[column1+1].left_line) // additional width +#endif + { + // additional width + add_width = WIDTH_OF_LINE; + } + if (GetWidthOfCell(cell) == (new_width+2*WIDTH_OF_LINE+add_width)) { return false; + } if (IsMultiColumn(cell, true)) { tmp = SetWidthOfMulticolCell(cell, new_width); } else { - width = (new_width + 2*WIDTH_OF_LINE); + width = (new_width + 2*WIDTH_OF_LINE + add_width); cell_info[row][column1].width_of_cell = width; - if (column_info[column1].right_line && (column1 < columns_-1) && - column_info[column1+1].left_line) // additional width - cell_info[row][column1].width_of_cell += WIDTH_OF_LINE; tmp = calculate_width_of_column_NMC(column1); } if (tmp) { @@ -2100,40 +2147,42 @@ int LyXTabular::Latex(Buffer const * buf, else os << "\\begin{tabular}{"; for (int i = 0; i < columns_; ++i) { - if (column_info[i].left_line) - os << '|'; if (!column_info[i].align_special.empty()) { os << column_info[i].align_special; - } else if (!column_info[i].p_width.empty()) { - switch (column_info[i].valignment) { - case LYX_VALIGN_TOP: - os << "p"; - break; - case LYX_VALIGN_CENTER: - os << "m"; - break; - case LYX_VALIGN_BOTTOM: - os << "b"; - break; + } else { + if (column_info[i].left_line) + os << '|'; + if (!column_info[i].p_width.empty()) { + switch (column_info[i].valignment) { + case LYX_VALIGN_TOP: + os << "p"; + break; + case LYX_VALIGN_CENTER: + os << "m"; + break; + case LYX_VALIGN_BOTTOM: + os << "b"; + break; } - os << "{" - << column_info[i].p_width - << '}'; - } else { - switch (column_info[i].alignment) { - case LYX_ALIGN_LEFT: - os << 'l'; - break; - case LYX_ALIGN_RIGHT: + os << "{" + << column_info[i].p_width + << '}'; + } else { + switch (column_info[i].alignment) { + case LYX_ALIGN_LEFT: + os << 'l'; + break; + case LYX_ALIGN_RIGHT: os << 'r'; break; - default: - os << 'c'; - break; + default: + os << 'c'; + break; + } } + if (column_info[i].right_line) + os << '|'; } - if (column_info[i].right_line) - os << '|'; } os << "}\n"; ++ret; diff --git a/src/text2.C b/src/text2.C index 186c7739a8..d7a122f79b 100644 --- a/src/text2.C +++ b/src/text2.C @@ -2038,8 +2038,8 @@ bool LyXText::updateInset(BufferView * bview, Inset * inset) void LyXText::setCursor(BufferView * bview, Paragraph * par, - Paragraph::size_type pos, - bool setfont, bool boundary) const + Paragraph::size_type pos, + bool setfont, bool boundary) const { LyXCursor old_cursor = cursor; setCursorIntern(bview, par, pos, setfont, boundary);