From b06de5044f596153a0639e7515d0ea9686f22bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Mon, 1 Dec 2003 14:16:27 +0000 Subject: [PATCH] The VSpace fixes (removal of VSPACE::NONE) from Michael and myself git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8168 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 3 + src/frontends/controllers/ChangeLog | 3 + src/frontends/controllers/ControlVSpace.C | 5 ++ src/frontends/qt2/ChangeLog | 5 ++ src/frontends/qt2/QVSpace.C | 35 +++----- src/frontends/qt2/QVSpaceDialog.C | 2 +- src/frontends/qt2/ui/QVSpaceDialogBase.ui | 100 ++++------------------ src/frontends/xforms/ChangeLog | 4 + src/frontends/xforms/FormVSpace.C | 44 ++++------ src/insets/ChangeLog | 3 + src/insets/insetvspace.C | 33 +++---- src/vspace.C | 13 +-- src/vspace.h | 1 - 13 files changed, 96 insertions(+), 155 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 8308bbacee..083e00ff8c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,6 @@ +2003-12-01 Michael Schmitt + + * vspace.[Ch]: remove VSpace::NONE 2003-12-01 André Pönitz diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 2062907e99..497deeb54e 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,6 @@ +2003-12-01 Jürgen Spitzmüller + + * ControlVSpace.C: enable the buttons for new insets. 2003-11-28 André Pönitz diff --git a/src/frontends/controllers/ControlVSpace.C b/src/frontends/controllers/ControlVSpace.C index 2a7599d970..eab3a8ebd8 100644 --- a/src/frontends/controllers/ControlVSpace.C +++ b/src/frontends/controllers/ControlVSpace.C @@ -12,6 +12,7 @@ #include #include "ControlVSpace.h" +#include "ButtonController.h" #include "funcrequest.h" #include "insets/insetvspace.h" @@ -29,6 +30,10 @@ ControlVSpace::ControlVSpace(Dialog & parent) bool ControlVSpace::initialiseParams(string const & data) { InsetVSpaceMailer::string2params(data, params_); + + // so that the user can press Ok + dialog().bc().valid(); + return true; } diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 1f52a161ed..1cbb50a838 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2003-12-01 Jürgen Spitzmüller + + * QVSpace.C: remove VSPACE::NONE, remove restore button. + * ui/QVSpaceDialogBase.ui: remove restore button, fix tooltip. + 2003-12-01 Juergen Spitzmueller * QDocumentDialog.[Ch]: (branches) don't insert a coloritem diff --git a/src/frontends/qt2/QVSpace.C b/src/frontends/qt2/QVSpace.C index 642d7a3382..9fa7e46fdd 100644 --- a/src/frontends/qt2/QVSpace.C +++ b/src/frontends/qt2/QVSpace.C @@ -50,26 +50,23 @@ void setWidgetsFromVSpace(VSpace const & space, { int item = 0; switch (space.kind()) { - case VSpace::NONE: + case VSpace::DEFSKIP: item = 0; break; - case VSpace::DEFSKIP: + case VSpace::SMALLSKIP: item = 1; break; - case VSpace::SMALLSKIP: + case VSpace::MEDSKIP: item = 2; break; - case VSpace::MEDSKIP: + case VSpace::BIGSKIP: item = 3; break; - case VSpace::BIGSKIP: + case VSpace::VFILL: item = 4; break; - case VSpace::VFILL: - item = 5; - break; case VSpace::LENGTH: - item = 6; + item = 5; break; } spacing->setCurrentItem(item); @@ -96,28 +93,25 @@ VSpace setVSpaceFromWidgets(int spacing, LengthCombo * unit, bool keep) { - VSpace space = VSpace(VSpace::NONE); + VSpace space = VSpace(VSpace::DEFSKIP); switch (spacing) { case 0: - space = VSpace(VSpace::NONE); - break; - case 1: space = VSpace(VSpace::DEFSKIP); break; - case 2: + case 1: space = VSpace(VSpace::SMALLSKIP); break; - case 3: + case 2: space = VSpace(VSpace::MEDSKIP); break; - case 4: + case 3: space = VSpace(VSpace::BIGSKIP); break; - case 5: + case 4: space = VSpace(VSpace::VFILL); break; - case 6: + case 5: space = VSpace(LyXGlueLength( widgetsToLength(value, unit))); break; @@ -146,7 +140,6 @@ void QVSpace::build_dialog() bcview().setOK(dialog_->okPB); bcview().setApply(dialog_->applyPB); bcview().setCancel(dialog_->closePB); - bcview().setRestore(dialog_->restorePB); // disable for read-only documents bcview().addReadOnly(dialog_->spacingCO); @@ -163,10 +156,10 @@ void QVSpace::apply() { // spacing // If a vspace choice is "Length" but there's no text in - // the input field, reset the choice to "None". + // the input field, do not insert a vspace at all. if (dialog_->spacingCO->currentItem() == 6 && dialog_->valueLE->text().isEmpty()) - dialog_->spacingCO->setCurrentItem(0); + return; VSpace const space = setVSpaceFromWidgets(dialog_->spacingCO->currentItem(), diff --git a/src/frontends/qt2/QVSpaceDialog.C b/src/frontends/qt2/QVSpaceDialog.C index 33305a9f09..bc2f6a3eb0 100644 --- a/src/frontends/qt2/QVSpaceDialog.C +++ b/src/frontends/qt2/QVSpaceDialog.C @@ -52,7 +52,7 @@ void QVSpaceDialog::change_adaptor() void QVSpaceDialog::enableCustom(int) { - bool const enable = spacingCO->currentItem()==6; + bool const enable = spacingCO->currentItem()==5; valueLE->setEnabled(enable); unitCO->setEnabled(enable); } diff --git a/src/frontends/qt2/ui/QVSpaceDialogBase.ui b/src/frontends/qt2/ui/QVSpaceDialogBase.ui index 4fc0bca360..f9626c2f4e 100644 --- a/src/frontends/qt2/ui/QVSpaceDialogBase.ui +++ b/src/frontends/qt2/ui/QVSpaceDialogBase.ui @@ -13,7 +13,7 @@ 0 0 - 335 + 233 140 @@ -95,7 +95,7 @@ toolTip - Do not reset the spacing on page break + Insert the spacing even after a page break @@ -115,12 +115,6 @@ QComboBox - - - text - None - - text @@ -166,14 +160,21 @@ Supported spacing types - + + LengthCombo + + name + unitCO + + + name - Spacer8 + Spacer28 orientation - Horizontal + Vertical sizeType @@ -187,28 +188,7 @@ - - - name - Spacer9 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - + QLayoutWidget name @@ -223,42 +203,6 @@ spacing 6 - - QPushButton - - name - restorePB - - - text - &Restore - - - autoDefault - false - - - - - name - Spacer1 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - QPushButton @@ -310,14 +254,14 @@ - + name - Spacer28 + Spacer8 orientation - Vertical + Horizontal sizeType @@ -331,17 +275,10 @@ - - LengthCombo - - name - unitCO - - - + name - Spacer5 + Spacer9 orientation @@ -419,7 +356,6 @@ enableCustom(int) - restorePB okPB applyPB closePB diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 496d7fc891..04b97713c6 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,7 @@ +2003-12-01 Jürgen Spitzmüller + + * FormVSpace.C: remove VSPACE::NONE. + 2003-11-29 Angus Leeming * Makefile.am (stamp-forms, stamp-xpm): don't use "if test return diff --git a/src/frontends/xforms/FormVSpace.C b/src/frontends/xforms/FormVSpace.C index 648ed57c88..143ada2f31 100644 --- a/src/frontends/xforms/FormVSpace.C +++ b/src/frontends/xforms/FormVSpace.C @@ -54,14 +54,14 @@ void validateVSpaceWidgets(FL_OBJECT * choice_type, FL_OBJECT * input_length) BOOST_ASSERT(choice_type && choice_type->objclass == FL_CHOICE && input_length && input_length->objclass == FL_INPUT); - if (fl_get_choice(choice_type) != 7) + if (fl_get_choice(choice_type) != 6) return; // If a vspace kind is "Length" but there's no text in - // the input field, reset the kind to "None". + // the input field, insert nothing. string const input = rtrim(getString(input_length)); if (input.empty()) - fl_set_choice(choice_type, 1); + return; } @@ -75,28 +75,25 @@ VSpace const setVSpaceFromWidgets(FL_OBJECT * choice_type, input_length && input_length->objclass == FL_INPUT && choice_length && choice_length->objclass == FL_CHOICE); - VSpace space = VSpace(VSpace::NONE); + VSpace space = VSpace(VSpace::DEFSKIP); switch (fl_get_choice(choice_type)) { case 1: - space = VSpace(VSpace::NONE); - break; - case 2: space = VSpace(VSpace::DEFSKIP); break; - case 3: + case 2: space = VSpace(VSpace::SMALLSKIP); break; - case 4: + case 3: space = VSpace(VSpace::MEDSKIP); break; - case 5: + case 4: space = VSpace(VSpace::BIGSKIP); break; - case 6: + case 5: space = VSpace(VSpace::VFILL); break; - case 7: + case 6: space = VSpace(LyXGlueLength( getLengthFromWidgets(input_length, choice_length))); break; @@ -121,26 +118,23 @@ void setWidgetsFromVSpace(VSpace const & space, int pos = 1; switch (space.kind()) { - case VSpace::NONE: + case VSpace::DEFSKIP: pos = 1; break; - case VSpace::DEFSKIP: + case VSpace::SMALLSKIP: pos = 2; break; - case VSpace::SMALLSKIP: + case VSpace::MEDSKIP: pos = 3; break; - case VSpace::MEDSKIP: + case VSpace::BIGSKIP: pos = 4; break; - case VSpace::BIGSKIP: + case VSpace::VFILL: pos = 5; break; - case VSpace::VFILL: - pos = 6; - break; case VSpace::LENGTH: - pos = 7; + pos = 6; break; } fl_set_choice(choice_type, pos); @@ -195,7 +189,7 @@ void FormVSpace::build() fl_set_input_return(dialog_->input_space, FL_RETURN_CHANGED); string const spacing = - _("None|DefSkip|SmallSkip|MedSkip|BigSkip|VFill|Length"); + _("DefSkip|SmallSkip|MedSkip|BigSkip|VFill|Length"); fl_addto_choice(dialog_->choice_space, spacing.c_str()); // Create the contents of the unit choices; don't include the "%" terms. @@ -237,7 +231,7 @@ void FormVSpace::apply() // spacing // If a vspace choice is "Length" but there's no text in - // the input field, reset the choice to "None". + // the input field, insert nothing. validateVSpaceWidgets(dialog_->choice_space, dialog_->input_space); VSpace const space = @@ -259,7 +253,7 @@ void FormVSpace::update() dialog_->check_keep); bool const custom_length = - fl_get_choice(dialog_->choice_space) == 7; + fl_get_choice(dialog_->choice_space) == 6; setEnabled(dialog_->input_space, custom_length); setEnabled(dialog_->choice_unit_space, custom_length); } @@ -271,7 +265,7 @@ ButtonPolicy::SMInput FormVSpace::input(FL_OBJECT * ob, long) // disable 'keep' when no space is choosen if (ob == dialog_->choice_space) { bool const custom_length = - fl_get_choice(dialog_->choice_space) == 7; + fl_get_choice(dialog_->choice_space) == 6; setEnabled(dialog_->input_space, custom_length); setEnabled(dialog_->choice_unit_space, custom_length); } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index c9abe1fe38..7e2de7d13c 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,6 @@ +2003-12-01 Michael Schmitt + + * insetvspace.C: remove VSpace::NONE; increase inset width 2003-12-01 André Pönitz diff --git a/src/insets/insetvspace.C b/src/insets/insetvspace.C index 132d94a109..469d65589d 100644 --- a/src/insets/insetvspace.C +++ b/src/insets/insetvspace.C @@ -35,6 +35,12 @@ using std::string; using std::max; +namespace { + +int const ADD_TO_VSPACE_WIDTH = 5; + +} // namespace anon + InsetVSpace::InsetVSpace(VSpace const & space) : space_(space) @@ -92,23 +98,21 @@ void InsetVSpace::write(Buffer const &, ostream & os) const void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const { int size = 10; - if (space_.kind() != VSpace::NONE) { - int const arrow_size = 4; - int const space_size = space_.inPixels(*mi.base.bv); + int const arrow_size = 4; + int const space_size = space_.inPixels(*mi.base.bv); - LyXFont font; - font.decSize(); - int const min_size = max(3 * arrow_size, font_metrics::maxHeight(font)); + LyXFont font; + font.decSize(); + int const min_size = max(3 * arrow_size, font_metrics::maxHeight(font)); - if (space_.length().len().value() < 0.0) - size = min_size; - else - size = max(min_size, space_size); - } + if (space_.length().len().value() < 0.0) + size = min_size; + else + size = max(min_size, space_size); dim.asc = size / 2; dim.des = size / 2; - dim.wid = 10; + dim.wid = 10 + 2 * ADD_TO_VSPACE_WIDTH; dim_ = dim; } @@ -121,8 +125,7 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const xo_ = x; yo_ = y; - //if (space_.kind() == VSpace::NONE) - // return 0; + x += ADD_TO_VSPACE_WIDTH; int const arrow_size = 4; int const start = y - dim_.asc; @@ -150,7 +153,7 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const by2 = added ? end : (end - arrow_size); } - int const midx = xo_ + arrow_size; + int const midx = x + arrow_size; int const rightx = midx + arrow_size; // first the string diff --git a/src/vspace.C b/src/vspace.C index 84bcbc845e..030af3d647 100644 --- a/src/vspace.C +++ b/src/vspace.C @@ -337,7 +337,7 @@ bool isValidLength(string const & data, LyXLength * result) // VSpace::VSpace() - : kind_(NONE), len_(), keep_(false) + : kind_(DEFSKIP), len_(), keep_(false) {} @@ -357,7 +357,7 @@ VSpace::VSpace(LyXGlueLength const & l) VSpace::VSpace(string const & data) - : kind_(NONE), len_(), keep_(false) + : kind_(DEFSKIP), len_(), keep_(false) { if (data.empty()) return; @@ -436,7 +436,6 @@ string const VSpace::asLyXCommand() const { string result; switch (kind_) { - case NONE: break; case DEFSKIP: result = "defskip"; break; case SMALLSKIP: result = "smallskip"; break; case MEDSKIP: result = "medskip"; break; @@ -444,7 +443,7 @@ string const VSpace::asLyXCommand() const case VFILL: result = "vfill"; break; case LENGTH: result = len_.asString(); break; } - if (keep_ && kind_ != NONE && kind_ != DEFSKIP) + if (keep_) result += '*'; return result; } @@ -472,9 +471,6 @@ string const VSpace::asLatexCommand(BufferParams const & params) const return keep_ ? "\\vspace*{" + len_.asLatexString() + '}' : "\\vspace{" + len_.asLatexString() + '}'; - case NONE: - return string(); - default: BOOST_ASSERT(false); return string(); @@ -511,9 +507,6 @@ int VSpace::inPixels(BufferView const & bv) const case LENGTH: return len_.len().inPixels(bv.workWidth()); - case NONE: - return 0; - default: BOOST_ASSERT(false); return 0; diff --git a/src/vspace.h b/src/vspace.h index 6e0bf5ff8d..c37e77e664 100644 --- a/src/vspace.h +++ b/src/vspace.h @@ -24,7 +24,6 @@ class VSpace { public: /// The different kinds of spaces. enum vspace_kind { - NONE, ///< no added vertical space DEFSKIP, SMALLSKIP, MEDSKIP,