From 57920ce17b8d23173834015d87a67de2621254cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Vigna?= Date: Fri, 10 Aug 2001 14:00:48 +0000 Subject: [PATCH] Small fixes + hfill display/draw bug (seen with minipages!). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2487 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 2 + src/insets/ChangeLog | 7 +++ src/insets/inset.C | 13 ++---- src/insets/insetcollapsable.C | 6 +-- src/insets/insetminipage.C | 3 +- src/insets/insettabular.C | 2 +- src/text.C | 86 ++++++++++++++++++----------------- 7 files changed, 65 insertions(+), 54 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 16dcba7583..0b81d6116b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2001-08-10 Juergen Vigna + * text.C (prepareToPrint): fixed hfill-width in draw! + * BufferView2.C (selectLastWord): save the selection cursor as this now is cleared in the function LyXText::clearSelection! diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 99385c50a2..a4dbca50ce 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,5 +1,12 @@ 2001-08-10 Juergen Vigna + * insettabular.C (selectNextWordInt): use the front using edit call. + + * insetcollapsable.C (getMaxWidth): rename inset to in to not have + the parameter overwrite class variable inset. + + * inset.C (getMaxWidth): fix the setting of the minwidth = 10. + * insettext.C (saveLyXTextState): check for invalid cursor-par. (reinitLyXText): remove wrong_cursor bool as not needed anymore! diff --git a/src/insets/inset.C b/src/insets/inset.C index 93e47e3114..483d9bea1e 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -324,15 +324,12 @@ int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const if ((w - ((2 * TEXT_TO_INSET_OFFSET) + 5)) >= 0) w -= (2 * TEXT_TO_INSET_OFFSET) + 5; if (topx_set) { - if ((w - top_x) < 10) { - w = 10; // minimum I require!!! - } else { - w -= top_x; - if (owner()) { - w += owner()->x(); - } + w -= top_x; + if (owner()) { + w += owner()->x(); } - } else if (w < 10) { + } + if (w < 10) { w = 10; } return w; diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 2bbf5d79d9..b5c7cb0212 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -377,10 +377,10 @@ int InsetCollapsable::latex(Buffer const * buf, ostream & os, int InsetCollapsable::getMaxWidth(BufferView * bv, - UpdatableInset const * inset) const + UpdatableInset const * in) const { #if 0 - int const w = UpdatableInset::getMaxWidth(bv, inset); + int const w = UpdatableInset::getMaxWidth(bv, in); if (w < 0) { // What does a negative max width signify? (Lgb) @@ -390,7 +390,7 @@ int InsetCollapsable::getMaxWidth(BufferView * bv, // should be at least 30 pixels !!! return max(30, w - width_collapsed()); #else - return UpdatableInset::getMaxWidth(bv, inset); + return UpdatableInset::getMaxWidth(bv, in); #endif } diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index b4085bfc0d..81523d353c 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -341,8 +341,9 @@ int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset) if (!width_.empty()) { int ww1 = VSpace(width_).inPixels(bv); int ww2 = InsetCollapsable::getMaxWidth(bv, inset); - if (ww2 > 0 && ww2 < ww1) + if (ww2 > 0 && ww2 < ww1) { return ww2; + } return ww1; } // this should not happen! diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index b750e139de..67cee87f16 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -2524,7 +2524,7 @@ string InsetTabular::selectNextWordInt(BufferView * bv, float & value) const // otherwise we have to lock the next inset and ask for it's selecttion UpdatableInset * inset = static_cast(tabular->GetCellInset(++actcell)); - inset->edit(bv, 0, 0, 0); + inset->edit(bv); return selectNextWordInt(bv, value); } diff --git a/src/text.C b/src/text.C index 6a80460c7a..ace479038f 100644 --- a/src/text.C +++ b/src/text.C @@ -138,7 +138,7 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par, int LyXText::singleWidth(BufferView * bview, Paragraph * par, - Paragraph::size_type pos, char c) const + Paragraph::size_type pos, char c) const { LyXFont const font = getFont(bview->buffer(), par, pos); @@ -1134,7 +1134,7 @@ int LyXText::numberOfLabelHfills(Buffer const * buf, Row const * row) const // returns true, if a expansion is needed. // Rules are given by LaTeX bool LyXText::hfillExpansion(Buffer const * buf, Row const * row_ptr, - Paragraph::size_type pos) const + Paragraph::size_type pos) const { // by the way, is it a hfill? if (!row_ptr->par()->isHfill(pos)) @@ -1991,11 +1991,11 @@ void LyXText::charInserted() void LyXText::prepareToPrint(BufferView * bview, - Row * row, float & x, - float & fill_separator, - float & fill_hfill, - float & fill_label_hfill, - bool bidi) const + Row * row, float & x, + float & fill_separator, + float & fill_hfill, + float & fill_label_hfill, + bool bidi) const { float nlh; float ns; @@ -2030,45 +2030,49 @@ void LyXText::prepareToPrint(BufferView * bview, // are there any hfills in the row? float const nh = numberOfHfills(bview->buffer(), row); - if (nh) - fill_hfill = w / nh; - else { + if (nh) { + if (w > 0) + fill_hfill = w / nh; + } else { // is it block, flushleft or flushright? // set x how you need it - int align; - if (row->par()->params().align() == LYX_ALIGN_LAYOUT) - align = textclasslist.Style(bview->buffer()->params.textclass, row->par()->getLayout()).align; - else - align = row->par()->params().align(); - - // center displayed insets - Inset * inset; - if (row->par()->getChar(row->pos()) == Paragraph::META_INSET - && (inset=row->par()->getInset(row->pos())) - && (inset->display())) // || (inset->scroll() < 0))) - align = (inset->lyxCode() == Inset::MATHMACRO_CODE) - ? LYX_ALIGN_BLOCK : LYX_ALIGN_CENTER; - - switch (align) { + int align; + if (row->par()->params().align() == LYX_ALIGN_LAYOUT) { + align = textclasslist.Style(bview->buffer()->params.textclass, row->par()->getLayout()).align; + } else { + align = row->par()->params().align(); + } + + // center displayed insets + Inset * inset; + if (row->par()->getChar(row->pos()) == Paragraph::META_INSET + && (inset=row->par()->getInset(row->pos())) + && (inset->display())) // || (inset->scroll() < 0))) + align = (inset->lyxCode() == Inset::MATHMACRO_CODE) + ? LYX_ALIGN_BLOCK : LYX_ALIGN_CENTER; + + switch (align) { case LYX_ALIGN_BLOCK: - ns = numberOfSeparators(bview->buffer(), row); - if (ns && row->next() && row->next()->par() == row->par() && - !(row->next()->par()->isNewline(row->next()->pos() - 1)) - && !(row->next()->par()->getChar(row->next()->pos()) == Paragraph::META_INSET - && row->next()->par()->getInset(row->next()->pos()) - && row->next()->par()->getInset(row->next()->pos())->display()) - ) - fill_separator = w / ns; - else if (is_rtl) - x += w; - break; + ns = numberOfSeparators(bview->buffer(), row); + if (ns && row->next() && row->next()->par() == row->par() && + !(row->next()->par()->isNewline(row->next()->pos() - 1)) + && !(row->next()->par()->getChar(row->next()->pos()) == Paragraph::META_INSET + && row->next()->par()->getInset(row->next()->pos()) + && row->next()->par()->getInset(row->next()->pos())->display()) + ) + { + fill_separator = w / ns; + } else if (is_rtl) { + x += w; + } + break; case LYX_ALIGN_RIGHT: - x += w; - break; + x += w; + break; case LYX_ALIGN_CENTER: - x += w / 2; - break; - } + x += w / 2; + break; + } } if (!bidi) return;