]> git.lyx.org Git - lyx.git/commitdiff
The VSpace fixes (removal of VSPACE::NONE) from Michael and myself
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 1 Dec 2003 14:16:27 +0000 (14:16 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 1 Dec 2003 14:16:27 +0000 (14:16 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8168 a592a061-630c-0410-9148-cb99ea01b6c8

13 files changed:
src/ChangeLog
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlVSpace.C
src/frontends/qt2/ChangeLog
src/frontends/qt2/QVSpace.C
src/frontends/qt2/QVSpaceDialog.C
src/frontends/qt2/ui/QVSpaceDialogBase.ui
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormVSpace.C
src/insets/ChangeLog
src/insets/insetvspace.C
src/vspace.C
src/vspace.h

index 8308bbacee6fe8f60378662ef5424b346e35fbc6..083e00ff8c69a75f9678338faf27855fc7b9aad9 100644 (file)
@@ -1,3 +1,6 @@
+2003-12-01  Michael Schmitt  <michael.schmitt@teststep.org>
+
+       * vspace.[Ch]: remove VSpace::NONE
 
 2003-12-01  André Pönitz  <poenitz@gmx.net>
 
index 2062907e99be766a44bfe8bbcd5904948bb9b77f..497deeb54ef394820fb826752134e04fd3a5139a 100644 (file)
@@ -1,3 +1,6 @@
+2003-12-01  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * ControlVSpace.C: enable the buttons for new insets.
 
 2003-11-28  André Pönitz  <poenitz@gmx.net>
 
index 2a7599d970c1935698ca27bfba7957e56b1a68e1..eab3a8ebd8faa55b52c96dae2474fc91331ffd2a 100644 (file)
@@ -12,6 +12,7 @@
 #include <config.h>
 
 #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;
 }
 
index 1f52a161ed97bad0cb0f53ccfedcb64fa050d064..1cbb50a83845e971e129c885d2e054982d2f0f1e 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-01  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * QVSpace.C: remove VSPACE::NONE, remove restore button.
+       * ui/QVSpaceDialogBase.ui: remove restore button, fix tooltip.
+
 2003-12-01  Juergen Spitzmueller  <j.spitzmueller@gmx.de>
 
        * QDocumentDialog.[Ch]: (branches) don't insert a coloritem
index 642d7a33827c3b5829c6e77ce57a89d2163f3fdc..9fa7e46fddf813bc0570aac2a3491b81fd1b4a66 100644 (file)
@@ -50,26 +50,23 @@ void setWidgetsFromVSpace(VSpace const & space,
 {
        int item = 0;
        switch (space.kind()) {
-       case VSpace::NONE:
-               item = 0;
-               break;
        case VSpace::DEFSKIP:
-               item = 1;
+               item = 0;
                break;
        case VSpace::SMALLSKIP:
-               item = 2;
+               item = 1;
                break;
        case VSpace::MEDSKIP:
-               item = 3;
+               item = 2;
                break;
        case VSpace::BIGSKIP:
-               item = 4;
+               item = 3;
                break;
        case VSpace::VFILL:
-               item = 5;
+               item = 4;
                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(),
index 33305a9f09378329a75ec36e7a17b59ea4de5a51..bc2f6a3eb04fcbf39529e483710ed8bb66ef508c 100644 (file)
@@ -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);
 }
index 4fc0bca3609a653fdcbfd6ba977ad7cfcca59f81..f9626c2f4e511cd91c09dcaed414d4a3bcd1affd 100644 (file)
@@ -13,7 +13,7 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>335</width>
+            <width>233</width>
             <height>140</height>
         </rect>
     </property>
@@ -95,7 +95,7 @@
             </property>
             <property>
                 <name>toolTip</name>
-                <string>Do not reset the spacing on page break</string>
+                <string>Insert the spacing even after a page break</string>
             </property>
         </widget>
         <widget row="1"  column="1" >
         </widget>
         <widget row="0"  column="1" >
             <class>QComboBox</class>
-            <item>
-                <property>
-                    <name>text</name>
-                    <string>None</string>
-                </property>
-            </item>
             <item>
                 <property>
                     <name>text</name>
                 <string>Supported spacing types</string>
             </property>
         </widget>
-        <spacer row="0"  column="2"  rowspan="1"  colspan="2" >
-            <property>
-                <name>name</name>
-                <cstring>Spacer8</cstring>
-            </property>
-            <property stdset="1">
-                <name>orientation</name>
-                <enum>Horizontal</enum>
-            </property>
+        <widget row="1"  column="2" >
+            <class>LengthCombo</class>
             <property stdset="1">
-                <name>sizeType</name>
-                <enum>Expanding</enum>
-            </property>
-            <property>
-                <name>sizeHint</name>
-                <size>
-                    <width>20</width>
-                    <height>20</height>
-                </size>
+                <name>name</name>
+                <cstring>unitCO</cstring>
             </property>
-        </spacer>
-        <spacer row="2"  column="2"  rowspan="1"  colspan="2" >
+        </widget>
+        <spacer row="3"  column="1" >
             <property>
                 <name>name</name>
-                <cstring>Spacer9</cstring>
+                <cstring>Spacer28</cstring>
             </property>
             <property stdset="1">
                 <name>orientation</name>
-                <enum>Horizontal</enum>
+                <enum>Vertical</enum>
             </property>
             <property stdset="1">
                 <name>sizeType</name>
                 </size>
             </property>
         </spacer>
-        <widget row="4"  column="0"  rowspan="1"  colspan="4" >
+        <widget row="4"  column="0"  rowspan="1"  colspan="3" >
             <class>QLayoutWidget</class>
             <property stdset="1">
                 <name>name</name>
                     <name>spacing</name>
                     <number>6</number>
                 </property>
-                <widget>
-                    <class>QPushButton</class>
-                    <property stdset="1">
-                        <name>name</name>
-                        <cstring>restorePB</cstring>
-                    </property>
-                    <property stdset="1">
-                        <name>text</name>
-                        <string>&amp;Restore</string>
-                    </property>
-                    <property stdset="1">
-                        <name>autoDefault</name>
-                        <bool>false</bool>
-                    </property>
-                </widget>
-                <spacer>
-                    <property>
-                        <name>name</name>
-                        <cstring>Spacer1</cstring>
-                    </property>
-                    <property stdset="1">
-                        <name>orientation</name>
-                        <enum>Horizontal</enum>
-                    </property>
-                    <property stdset="1">
-                        <name>sizeType</name>
-                        <enum>Expanding</enum>
-                    </property>
-                    <property>
-                        <name>sizeHint</name>
-                        <size>
-                            <width>20</width>
-                            <height>20</height>
-                        </size>
-                    </property>
-                </spacer>
                 <widget>
                     <class>QPushButton</class>
                     <property stdset="1">
                 </widget>
             </hbox>
         </widget>
-        <spacer row="3"  column="1" >
+        <spacer row="0"  column="2" >
             <property>
                 <name>name</name>
-                <cstring>Spacer28</cstring>
+                <cstring>Spacer8</cstring>
             </property>
             <property stdset="1">
                 <name>orientation</name>
-                <enum>Vertical</enum>
+                <enum>Horizontal</enum>
             </property>
             <property stdset="1">
                 <name>sizeType</name>
                 </size>
             </property>
         </spacer>
-        <widget row="1"  column="2" >
-            <class>LengthCombo</class>
-            <property stdset="1">
-                <name>name</name>
-                <cstring>unitCO</cstring>
-            </property>
-        </widget>
-        <spacer row="1"  column="3" >
+        <spacer row="2"  column="2" >
             <property>
                 <name>name</name>
-                <cstring>Spacer5</cstring>
+                <cstring>Spacer9</cstring>
             </property>
             <property stdset="1">
                 <name>orientation</name>
     <slot access="protected">enableCustom(int)</slot>
 </connections>
 <tabstops>
-    <tabstop>restorePB</tabstop>
     <tabstop>okPB</tabstop>
     <tabstop>applyPB</tabstop>
     <tabstop>closePB</tabstop>
index 496d7fc89187591f17cb05947fc155385f652374..04b97713c64a737fbf3e19c97b2a44f4387b95db 100644 (file)
@@ -1,3 +1,7 @@
+2003-12-01  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * FormVSpace.C: remove VSPACE::NONE.
+
 2003-11-29  Angus Leeming  <leeming@lyx.org>
 
        * Makefile.am (stamp-forms, stamp-xpm): don't use "if test return
index 648ed57c8843f438b17a1bb3286f136f94ff8b2d..143ada2f31257666d6ea0150a69bde8f01ca4f98 100644 (file)
@@ -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:
-               pos = 1;
-               break;
        case VSpace::DEFSKIP:
-               pos = 2;
+               pos = 1;
                break;
        case VSpace::SMALLSKIP:
-               pos = 3;
+               pos = 2;
                break;
        case VSpace::MEDSKIP:
-               pos = 4;
+               pos = 3;
                break;
        case VSpace::BIGSKIP:
-               pos = 5;
+               pos = 4;
                break;
        case VSpace::VFILL:
-               pos = 6;
+               pos = 5;
                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);
        }
index c9abe1fe3837b1fd8b2d493056fbd7f4ab1a3bbb..7e2de7d13ce237562fac9fe3c78b2e15eb84b1e5 100644 (file)
@@ -1,3 +1,6 @@
+2003-12-01  Michael Schmitt  <michael.schmitt@teststep.org>
+
+       * insetvspace.C: remove VSpace::NONE; increase inset width
 
 2003-12-01  André Pönitz  <poenitz@gmx.net>
 
index 132d94a10926f765770206a9c4de673b9e3839d5..469d65589ddd720c898f0b2bdb1602cd88cebed6 100644 (file)
@@ -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);
-
-               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);
-       }
+       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));
+
+       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
index 84bcbc845e5f89c3060f4f528e9a5cf9a18828ba..030af3d6473ef894648891b927dda3ada10df140 100644 (file)
@@ -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;
index 6e0bf5ff8dbf675ceb26baf1996c4cfbf4e2195f..c37e77e66491db37cfbf7fd7faf1336777a4c20f 100644 (file)
@@ -24,7 +24,6 @@ class VSpace {
 public:
        /// The different kinds of spaces.
        enum vspace_kind {
-               NONE, ///< no added vertical space
                DEFSKIP,
                SMALLSKIP,
                MEDSKIP,