Jürgen Spitzmüller wrote: > > I won't have time to work further on this the next weeks, so please take > > over as you are deep enough in this business as well as I am. > > I don't have time either.
I couldn't resist. Attached a patch that implements the glue length for texted. Maybe you can do the file format/lyx2lyx stuff. Jürgen
Index: src/insets/InsetSpace.cpp =================================================================== --- src/insets/InsetSpace.cpp (Revision 30712) +++ src/insets/InsetSpace.cpp (Arbeitskopie) @@ -53,7 +53,7 @@ } -Length InsetSpace::length() const +GlueLength InsetSpace::length() const { return params_.length; } @@ -130,12 +130,14 @@ message = _("Horizontal Fill (Down Brace)"); break; case InsetSpaceParams::CUSTOM: + // FIXME unicode message = support::bformat(_("Horizontal Space (%1$s)"), - params_.length.asDocstring()); + from_ascii(params_.length.asString())); break; case InsetSpaceParams::CUSTOM_PROTECTED: + // FIXME unicode message = support::bformat(_("Protected Horizontal Space (%1$s)"), - params_.length.asDocstring()); + from_ascii(params_.length.asString())); break; } return message; @@ -238,7 +240,7 @@ case InsetSpaceParams::CUSTOM: case InsetSpaceParams::CUSTOM_PROTECTED: { int const w = - params_.length.inPixels(mi.base.textwidth, + params_.length.len().inPixels(mi.base.textwidth, fm.width(char_type('M'))); int const minw = (w < 0) ? 3 * arrow_size : 4; dim.wid = max(minw, abs(w)); @@ -264,7 +266,7 @@ { Dimension const dim = dimension(*pi.base.bv); - if (isStretchableSpace() || params_.length.value() < 0) { + if (isStretchableSpace() || params_.length.len().value() < 0) { int const asc = theFontMetrics(pi.base.font).ascent('M'); int const desc = theFontMetrics(pi.base.font).descent('M'); // Pixel height divisible by 2 for prettier fill graphics: @@ -450,7 +452,7 @@ break; } - if (!length.empty()) + if (!length.len().empty()) os << "\n\\length " << length.asString(); } Index: src/insets/InsetSpace.h =================================================================== --- src/insets/InsetSpace.h (Revision 30712) +++ src/insets/InsetSpace.h (Arbeitskopie) @@ -81,7 +81,7 @@ /// Kind kind; /// - Length length; + GlueLength length; /** * Whether these params are to be used in mathed. * This determines the set of valid kinds. @@ -110,7 +110,7 @@ /// static std::string params2string(InsetSpaceParams const &); /// - Length length() const; + GlueLength length() const; /// docstring toolTip(BufferView const & bv, int x, int y) const; Index: src/mathed/InsetMathSpace.cpp =================================================================== --- src/mathed/InsetMathSpace.cpp (Revision 30712) +++ src/mathed/InsetMathSpace.cpp (Arbeitskopie) @@ -214,7 +214,7 @@ LASSERT(space_info[space_].visible, /**/); InsetSpaceParams isp(true); isp.kind = space_info[space_].kind; - isp.length = length_; + isp.length = GlueLength(length_); return InsetSpace::params2string(isp); } Index: src/frontends/qt4/GuiHSpace.cpp =================================================================== --- src/frontends/qt4/GuiHSpace.cpp (Revision 30712) +++ src/frontends/qt4/GuiHSpace.cpp (Arbeitskopie) @@ -57,7 +57,10 @@ connect(fillPatternCO, SIGNAL(activated(int)), this, SLOT(patternChanged())); - valueLE->setValidator(unsignedLengthValidator(valueLE)); + if (params_.math) + valueLE->setValidator(unsignedLengthValidator(valueLE)); + else + valueLE->setValidator(unsignedGlueLengthValidator(valueLE)); // Manage the ok, apply, restore and cancel/close buttons bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy); @@ -245,9 +248,10 @@ keep->setChecked(protect); Length::UNIT const default_unit = Length::defaultUnit(); - if (item == (params.math ? 9 : 7)) - lengthToWidgets(value, unit, params.length, default_unit); - else + if (item == (params.math ? 9 : 7)) { + string length = params.length.asString(); + lengthToWidgets(value, unit, length, default_unit); + } else lengthToWidgets(value, unit, "", default_unit); } @@ -269,7 +273,7 @@ case 8: params.kind = InsetSpaceParams::QQUAD; break; case 9: params.kind = InsetSpaceParams::CUSTOM; - params.length = Length(widgetsToLength(value, unit)); + params.length = GlueLength(widgetsToLength(value, unit)); break; } return params; @@ -323,7 +327,7 @@ params.kind = InsetSpaceParams::CUSTOM_PROTECTED; else params.kind = InsetSpaceParams::CUSTOM; - params.length = Length(widgetsToLength(value, unit)); + params.length = GlueLength(widgetsToLength(value, unit)); break; } return params; Index: src/factory.cpp =================================================================== --- src/factory.cpp (Revision 30712) +++ src/factory.cpp (Arbeitskopie) @@ -387,22 +387,22 @@ else if (name == "hrulefill") isp.kind = InsetSpaceParams::HRULEFILL; else if (name == "hspace") { - if (len.empty() || !isValidLength(len)) { + if (len.empty() || !isValidGlueLength(len)) { lyxerr << "LyX function 'space-insert hspace' " << "needs a valid length argument." << endl; break; } isp.kind = InsetSpaceParams::CUSTOM; - isp.length = Length(len); + isp.length = GlueLength(len); } else if (name == "hspace*") { - if (len.empty() || !isValidLength(len)) { + if (len.empty() || !isValidGlueLength(len)) { lyxerr << "LyX function 'space-insert hspace*' " << "needs a valid length argument." << endl; break; } isp.kind = InsetSpaceParams::CUSTOM_PROTECTED; - isp.length = Length(len); + isp.length = GlueLength(len); } else { lyxerr << "Wrong argument for LyX function 'space-insert'." << endl;