please apply (cvs), it removes the hardcoded choices for the lengths, which are now build from lengthcommon.C in frontend/controllers/helper_funcs.C
removes also some double written code Herbert -- http://www.lyx.org/help/
Index: src/frontends/controllers/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/ChangeLog,v retrieving revision 1.204 diff -u -r1.204 ChangeLog --- src/frontends/controllers/ChangeLog 22 Jul 2002 12:36:40 -0000 1.204 +++ src/frontends/controllers/ChangeLog 23 Jul 2002 13:06:49 -0000 @@ -1,3 +1,8 @@ +2002-07-23 Herbert Voss <[EMAIL PROTECTED]> + + * helper_funcs.[Ch]: adding two functions for building the + lengths choices + 2002-07-22 Herbert Voss <[EMAIL PROTECTED]> * ControlGraphics.C: small changes Index: src/frontends/controllers/helper_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/helper_funcs.C,v retrieving revision 1.17 diff -u -r1.17 helper_funcs.C --- src/frontends/controllers/helper_funcs.C 15 Apr 2002 12:05:07 -0000 1.17 +++ src/frontends/controllers/helper_funcs.C 23 Jul 2002 13:06:49 -0000 @@ -1,14 +1,10 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2001 The LyX Team. - * - * ====================================================== - * +/* * \file helper_funcs.C - * \author Angus Leeming <[EMAIL PROTECTED]> + * Copyright 2002 the LyX Team + * Read the file COPYING + * + * \author Angus Leeming, [EMAIL PROTECTED] + * \author Herbert Voss, [EMAIL PROTECTED] */ #include <vector> @@ -30,6 +26,7 @@ using std::pair; using std::vector; using std::make_pair; +using std::bind2nd; string const browseFile(LyXView * lv, string const & filename, string const & title, @@ -96,3 +93,24 @@ return units; } + + +string const getAllLengthChoice() +{ + string const choice_str(getStringFromVector(getLatexUnits(), "|")); + // replace % with %% + return subst(choice_str, "%", "%%"); +} + + +string const getUnitLengthChoice() +{ + // get all absolute units + vector<string> units_vec = getLatexUnits(); + vector<string>::iterator ret = std::remove_if(units_vec.begin(), + units_vec.end(), bind2nd(contains_functor(), "%")); + units_vec.erase(ret, units_vec.end()); + + return getStringFromVector(units_vec, "|"); +} + Index: src/frontends/controllers/helper_funcs.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/controllers/helper_funcs.h,v retrieving revision 1.9 diff -u -r1.9 helper_funcs.h --- src/frontends/controllers/helper_funcs.h 15 Apr 2002 12:05:07 -0000 1.9 +++ src/frontends/controllers/helper_funcs.h 23 Jul 2002 13:06:49 -0000 @@ -52,7 +52,10 @@ /// Returns a vector of units that can be used to create a valid LaTeX length. std::vector<string> const getLatexUnits(); - +/// Returns a choice of all available units defined in lengthcommon.C +string const getAllLengthChoice(); +/// Returns a choice of all non relative units defined in lengthcommon.C +string const getUnitLengthChoice(); /** Functions to extract vectors of the first and second elems from a vector<pair<A,B> > Index: src/frontends/xforms/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v retrieving revision 1.488 diff -u -r1.488 ChangeLog --- src/frontends/xforms/ChangeLog 22 Jul 2002 20:57:58 -0000 1.488 +++ src/frontends/xforms/ChangeLog 23 Jul 2002 13:06:51 -0000 @@ -1,3 +1,15 @@ +2002-07-23 Herbert Voss <[EMAIL PROTECTED]> + + * xforms_helpers.h: remove hardcoded length-choices + + * FormDocument.C: + * FormGraphics.C: + * FormMinipage.C: + * FormParagraph: + * FormTabular.C: simplify the code for using the length-choice + which is now build in controllers/helper_funcs from that what is + defined in lebgthcommon.C + 2002-07-22 Lars Gullik Bjønnes <[EMAIL PROTECTED]> * XMiniBuffer.h: add connection objects, and use them Index: src/frontends/xforms/FormDocument.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormDocument.C,v retrieving revision 1.108 diff -u -r1.108 FormDocument.C --- src/frontends/xforms/FormDocument.C 3 Jul 2002 14:18:32 -0000 1.108 +++ src/frontends/xforms/FormDocument.C 23 Jul 2002 13:06:51 -0000 @@ -52,7 +52,6 @@ #include <functional> -using std::bind2nd; using Liason::setMinibuffer; using std::vector; @@ -134,26 +133,17 @@ setPrehandler(paper_->input_head_sep); setPrehandler(paper_->input_foot_skip); - // Create the contents of the unit choices - // Don't include the "%" terms... - vector<string> units_vec = getLatexUnits(); - vector<string>::iterator ret = - std::remove_if(units_vec.begin(), - units_vec.end(), - bind2nd(contains_functor(), "%")); - units_vec.erase(ret, units_vec.end()); - - string units = getStringFromVector(units_vec, "|"); - - fl_addto_choice(paper_->choice_custom_width_units, units.c_str()); - fl_addto_choice(paper_->choice_custom_height_units, units.c_str()); - fl_addto_choice(paper_->choice_top_margin_units, units.c_str()); - fl_addto_choice(paper_->choice_bottom_margin_units, units.c_str()); - fl_addto_choice(paper_->choice_inner_margin_units, units.c_str()); - fl_addto_choice(paper_->choice_outer_margin_units, units.c_str()); - fl_addto_choice(paper_->choice_head_height_units, units.c_str()); - fl_addto_choice(paper_->choice_head_sep_units, units.c_str()); - fl_addto_choice(paper_->choice_foot_skip_units, units.c_str()); + // all absolute lengths (no text%, ...) + string const lengthChoice(getUnitLengthChoice()); + fl_addto_choice(paper_->choice_custom_width_units, lengthChoice.c_str()); + fl_addto_choice(paper_->choice_custom_height_units, lengthChoice.c_str()); + fl_addto_choice(paper_->choice_top_margin_units, lengthChoice.c_str()); + fl_addto_choice(paper_->choice_bottom_margin_units, lengthChoice.c_str()); + fl_addto_choice(paper_->choice_inner_margin_units, lengthChoice.c_str()); + fl_addto_choice(paper_->choice_outer_margin_units, lengthChoice.c_str());; + fl_addto_choice(paper_->choice_head_height_units, lengthChoice.c_str()); + fl_addto_choice(paper_->choice_head_sep_units, lengthChoice.c_str());; + fl_addto_choice(paper_->choice_foot_skip_units, lengthChoice.c_str()); bc().addReadOnly (paper_->choice_paperpackage); bc().addReadOnly (paper_->radio_portrait); @@ -199,7 +189,8 @@ "default|empty|plain|headings|fancy"); fl_addto_choice(class_->choice_doc_skip, _(" Smallskip | Medskip | Bigskip | Length ")); - fl_addto_choice(class_->choice_default_skip_units, units.c_str()); + fl_addto_choice(class_->choice_default_skip_units, + getAllLengthChoice().c_str()); fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED); fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED); fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED); Index: src/frontends/xforms/FormGraphics.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormGraphics.C,v retrieving revision 1.77 diff -u -r1.77 FormGraphics.C --- src/frontends/xforms/FormGraphics.C 22 Jul 2002 12:36:40 -0000 1.77 +++ src/frontends/xforms/FormGraphics.C 23 Jul 2002 13:06:52 -0000 @@ -152,8 +152,10 @@ setPrehandler(lyxview_->input_lyxheight); setPrehandler(lyxview_->input_lyxscale); - fl_addto_choice(lyxview_->choice_lyxwidth, choice_Length_WithUnit.c_str()); - fl_addto_choice(lyxview_->choice_lyxheight, choice_Length_WithUnit.c_str()); + // get all lengths with an absolut unit (no relative one) + string const choice_abs(getUnitLengthChoice()); + fl_addto_choice(lyxview_->choice_lyxwidth, choice_abs.c_str()); + fl_addto_choice(lyxview_->choice_lyxheight, choice_abs.c_str()); bc().addReadOnly(lyxview_->radio_pref); bc().addReadOnly(lyxview_->radio_mono); @@ -218,8 +220,10 @@ fl_set_input_filter(size_->input_scale, fl_unsigned_float_filter); - fl_addto_choice(size_->choice_width, choice_Length_All.c_str()); - fl_addto_choice(size_->choice_height, choice_Length_All.c_str()); + // get all lengths + string const choice_all = getAllLengthChoice(); + fl_addto_choice(size_->choice_width, choice_all.c_str()); + fl_addto_choice(size_->choice_height, choice_all.c_str()); bc().addReadOnly(size_->radio_asis); bc().addReadOnly(size_->radio_wh); Index: src/frontends/xforms/FormMinipage.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormMinipage.C,v retrieving revision 1.26 diff -u -r1.26 FormMinipage.C --- src/frontends/xforms/FormMinipage.C 21 Jul 2002 15:51:06 -0000 1.26 +++ src/frontends/xforms/FormMinipage.C 23 Jul 2002 13:06:52 -0000 @@ -38,9 +38,8 @@ fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED); setPrehandler(dialog_->input_width); - - string const choice = getStringFromVector(getLatexUnits(), "|"); - fl_addto_choice(dialog_->choice_width_units, subst(choice, "%", "%%").c_str()); + fl_addto_choice(dialog_->choice_width_units, + getAllLengthChoice().c_str()); // Manage the ok, apply and cancel/close buttons bc().setOK(dialog_->button_ok); Index: src/frontends/xforms/FormParagraph.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormParagraph.C,v retrieving revision 1.76 diff -u -r1.76 FormParagraph.C --- src/frontends/xforms/FormParagraph.C 21 Jul 2002 15:51:06 -0000 1.76 +++ src/frontends/xforms/FormParagraph.C 23 Jul 2002 13:06:52 -0000 @@ -71,19 +71,10 @@ setPrehandler(dialog_->input_labelwidth); setPrehandler(dialog_->input_linespacing); - // Create the contents of the unit choices // Don't include the "%" terms... - vector<string> units_vec = getLatexUnits(); - - vector<string>::iterator del = - remove_if(units_vec.begin(), units_vec.end(), - bind2nd(contains_functor(), "%")); - units_vec.erase(del, units_vec.end()); - - string units = getStringFromVector(units_vec, "|"); - - fl_addto_choice(dialog_->choice_value_space_above, units.c_str()); - fl_addto_choice(dialog_->choice_value_space_below, units.c_str()); + string const choice_str(getUnitLengthChoice()); + fl_addto_choice(dialog_->choice_value_space_above, choice_str.c_str()); + fl_addto_choice(dialog_->choice_value_space_below, choice_str.c_str()); // Manage the ok, apply, restore and cancel/close buttons bc().setOK(dialog_->button_ok); Index: src/frontends/xforms/FormTabular.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormTabular.C,v retrieving revision 1.51 diff -u -r1.51 FormTabular.C --- src/frontends/xforms/FormTabular.C 24 Jun 2002 20:28:10 -0000 1.51 +++ src/frontends/xforms/FormTabular.C 23 Jul 2002 13:06:52 -0000 @@ -146,18 +146,11 @@ // Create the contents of the unit choices // Don't include the "%" terms... - vector<string> units_vec = getLatexUnits(); - vector<string>::iterator ret = - remove_if(units_vec.begin(), units_vec.end(), - bind2nd(contains_functor(), "%")); - units_vec.erase(ret, units_vec.end()); - - string units = getStringFromVector(units_vec, "|"); - - fl_addto_choice(column_options_->choice_value_column_width, - units.c_str()); - fl_addto_choice(cell_options_->choice_value_mcolumn_width, - units.c_str()); + string const choice_str(getAllLengthChoice()); + fl_addto_choice(column_options_->choice_value_column_width, + choice_str.c_str()); + fl_addto_choice(cell_options_->choice_value_mcolumn_width, + choice_str.c_str()); } Index: src/frontends/xforms/xforms_helpers.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/xforms_helpers.h,v retrieving revision 1.26 diff -u -r1.26 xforms_helpers.h --- src/frontends/xforms/xforms_helpers.h 21 Jul 2002 15:51:06 -0000 1.26 +++ src/frontends/xforms/xforms_helpers.h 23 Jul 2002 13:06:52 -0000 @@ -24,11 +24,6 @@ class LyXLength; -// what we always need for lengths -string const choice_Length_All = - "cm|mm|in|text%%|col%%|page%%|line%%|ex|em|pt|sp|bp|dd|pc|cc|mu"; -string const choice_Length_WithUnit = - "cm|mm|in|ex|em|pt|sp|bp|dd|pc|cc|mu"; // all with a Unit /// Set an FL_OBJECT to activated or deactivated void setEnabled(FL_OBJECT *, bool enable);