From 90e427465da12620f4da72fd568224b21ae67346 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Mon, 5 Apr 2004 14:05:03 +0000 Subject: [PATCH] Squash bug 1345 in the 14x tree: xforms frontend doesn't have %theight or %pheight as a graphics sizing choice. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8603 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 6 +++++- src/frontends/qt2/ChangeLog | 4 ++++ src/frontends/qt2/QGraphics.C | 2 +- src/frontends/xforms/ChangeLog | 11 +++++++++++ src/frontends/xforms/FormExternal.C | 8 ++++---- src/frontends/xforms/FormGraphics.C | 7 ++++--- src/frontends/xforms/xforms_helpers.C | 13 +++++++++++++ src/frontends/xforms/xforms_helpers.h | 9 ++++----- src/lengthcommon.C | 6 +++--- src/lengthcommon.h | 6 +++--- 10 files changed, 52 insertions(+), 20 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 97a2e75fac..21caf70185 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,8 @@ -2004-05-04 Angus Leeming +2004-04-05 Angus Leeming + + * lyxlength.[Ch] (unit_name et al.): const-correct. + +2004-04-05 Angus Leeming * BufferView_pimpl.C: * buffer.C: diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 0456cc24e1..4e41133d5a 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,7 @@ +2004-04-05 Angus Leeming + + * QGraphics.C (getUnitNo): const-correct. + 2004-04-05 Jürgen Spitzmüller * floatplacement.[Ch]: check whether we are in the float or diff --git a/src/frontends/qt2/QGraphics.C b/src/frontends/qt2/QGraphics.C index cd117c3267..7b691f6cff 100644 --- a/src/frontends/qt2/QGraphics.C +++ b/src/frontends/qt2/QGraphics.C @@ -109,7 +109,7 @@ int getItemNo(vector v, string const & s) { // returns the number of the unit in the array unit_name, // which is defined in lengthcommon.C -int getUnitNo(char const * c[], string const & s) { +int getUnitNo(char const * const c[], string const & s) { int i = 0; while (i < num_units && s != c[i]) ++i; diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index fafc14590b..edbcf9c504 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,14 @@ +2004-05-04 Angus Leeming + + * FormExternal.C (build): + * FormGraphics.C (build): use buildChoiceLengthString rather than + choice_Length_All. + + * xforms_helpers.[Ch]: remove choice_Length_WithUnit (unused). + Replace choice_Length_All with buildChoiceLengthString, + which builds the string dynamically from lengthcommon.h's + unit_name_gui. + 2004-03-31 Angus Leeming * Dialogs2.C: diff --git a/src/frontends/xforms/FormExternal.C b/src/frontends/xforms/FormExternal.C index 4ce8a69ffb..e1fcb2a945 100644 --- a/src/frontends/xforms/FormExternal.C +++ b/src/frontends/xforms/FormExternal.C @@ -422,11 +422,11 @@ void FormExternal::build() fl_addto_choice(rotate_->choice_origin, external::origin_gui_str(i).c_str()); - string const width_list = bformat(_("Scale%%%%|%1$s"), - choice_Length_All); - fl_addto_choice(scale_->choice_width, width_list.c_str()); + string const height_list = buildChoiceLengthString(); + string const width_list = bformat(_("Scale%%%%|%1$s"), height_list); - fl_addto_choice(scale_->choice_height, choice_Length_All.c_str()); + fl_addto_choice(scale_->choice_width, width_list.c_str()); + fl_addto_choice(scale_->choice_height, height_list.c_str()); // Set up the tooltips. string str = _("The file you want to insert."); diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index af3f41d5cc..7063625e96 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -130,10 +130,11 @@ void FormGraphics::build() _("Default|Monochrome|Grayscale|Color|Do not display"); fl_addto_choice(file_->choice_display, display_List.c_str()); - string const width_list = bformat(_("Scale%%%%|%1$s"), choice_Length_All); - fl_addto_choice(file_->choice_width, width_list.c_str()); + string const height_list = buildChoiceLengthString(); + string const width_list = bformat(_("Scale%%%%|%1$s"), height_list); - fl_addto_choice(file_->choice_height, choice_Length_All.c_str()); + fl_addto_choice(file_->choice_width, width_list.c_str()); + fl_addto_choice(file_->choice_height, height_list.c_str()); // set up the tooltips for the filesection string str = _("The file you want to insert."); diff --git a/src/frontends/xforms/xforms_helpers.C b/src/frontends/xforms/xforms_helpers.C index 4fafa0127c..1901b37236 100644 --- a/src/frontends/xforms/xforms_helpers.C +++ b/src/frontends/xforms/xforms_helpers.C @@ -14,6 +14,7 @@ #include "debug.h" #include "gettext.h" +#include "lengthcommon.h" #include "lyxgluelength.h" #include "lyxlex.h" @@ -43,6 +44,18 @@ using std::vector; using std::string; +std::string const buildChoiceLengthString() +{ + string data; + for (int i = 0; i != num_units; ++i) { + if (i != 0) + data += "|"; + data += subst(unit_name_gui[i], "%", "%%"); + } + return data; +} + + bool isActive(FL_OBJECT * ob) { return ob && ob->active > 0; diff --git a/src/frontends/xforms/xforms_helpers.h b/src/frontends/xforms/xforms_helpers.h index 119233df6d..7a514945d5 100644 --- a/src/frontends/xforms/xforms_helpers.h +++ b/src/frontends/xforms/xforms_helpers.h @@ -29,11 +29,10 @@ std::pair parse_shortcut(std::string const & str); unsigned long fl_getmcolor(int i, unsigned int * r, unsigned int * g, unsigned int * b); -// what we always need for lengths -std::string const choice_Length_All = - "cm|mm|in|text%%|col%%|page%%|line%%|ex|em|pt|sp|bp|dd|pc|cc|mu"; -std::string const choice_Length_WithUnit = - "cm|mm|in|ex|em|pt|sp|bp|dd|pc|cc|mu"; // all with a Unit +/** Generate a string of available length units with which to + * populate a choice widget. + */ +std::string const buildChoiceLengthString(); /// return the (in)active state of the object bool isActive(FL_OBJECT * ob); diff --git a/src/lengthcommon.C b/src/lengthcommon.C index c8e89ed5a5..af25532d02 100644 --- a/src/lengthcommon.C +++ b/src/lengthcommon.C @@ -26,14 +26,14 @@ int const num_units = LyXLength::UNIT_NONE; // unit_name is for compatibility. Can be deleted when all works well. // means, when we have full language support for the lengths // in all gui's (Herbert 2002-11-01) -char const * unit_name[num_units + 1] = { +char const * const unit_name[num_units + 1] = { "sp", "pt", "bp", "dd", "mm", "pc", "cc", "cm", "in", "ex", "em", "mu", "text%", "col%", "page%", "line%", "theight%", "pheight%", "" }; // the latex units -char const * unit_name_ltx[num_units + 1] = { +char const * const unit_name_ltx[num_units + 1] = { "sp", "pt", "bp", "dd", "mm", "pc", "cc", "cm", "in", "ex", "em", "mu", // in 1.4 the following names should be used. then no @@ -44,7 +44,7 @@ char const * unit_name_ltx[num_units + 1] = { "theight%", "pheight%", "" }; // the LyX gui units -char const * unit_name_gui[num_units + 1] = { +char const * const unit_name_gui[num_units + 1] = { N_("sp"), N_("pt"), N_("bp"), N_("dd"), N_("mm"), N_("pc"), N_("cc"), N_("cm"), N_("in"), N_("ex"), N_("em"), N_("mu"), N_("text%"), N_("col%"), N_("page%"), N_("line%"), diff --git a/src/lengthcommon.h b/src/lengthcommon.h index 23d7bf69f7..ef74e411b7 100644 --- a/src/lengthcommon.h +++ b/src/lengthcommon.h @@ -26,9 +26,9 @@ extern int const num_units; * * FIXME: I am not sure if "mu" should be possible to select (Lgb) */ -extern char const * unit_name[]; -extern char const * unit_name_gui[]; -extern char const * unit_name_ltx[]; +extern char const * const unit_name[]; +extern char const * const unit_name_gui[]; +extern char const * const unit_name_ltx[]; /// return the unit given a string representation such as "cm" LyXLength::UNIT unitFromString(std::string const & data); -- 2.39.2