]> git.lyx.org Git - features.git/commitdiff
Squash bug 1345 in the 14x tree: xforms frontend doesn't have
authorAngus Leeming <leeming@lyx.org>
Mon, 5 Apr 2004 14:05:03 +0000 (14:05 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 5 Apr 2004 14:05:03 +0000 (14:05 +0000)
%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
src/frontends/qt2/ChangeLog
src/frontends/qt2/QGraphics.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormExternal.C
src/frontends/xforms/FormGraphics.C
src/frontends/xforms/xforms_helpers.C
src/frontends/xforms/xforms_helpers.h
src/lengthcommon.C
src/lengthcommon.h

index 97a2e75fac023abd4161d253ba64beb9742f12a2..21caf701852ac376c6e6c1a55dde1a3fcd517e40 100644 (file)
@@ -1,4 +1,8 @@
-2004-05-04  Angus Leeming  <leeming@lyx.org>
+2004-04-05  Angus Leeming  <leeming@lyx.org>
+
+       * lyxlength.[Ch] (unit_name et al.): const-correct.
+
+2004-04-05  Angus Leeming  <leeming@lyx.org>
 
        * BufferView_pimpl.C:
        * buffer.C:
index 0456cc24e1f8108ac5995879db20efa8b975286b..4e41133d5ac349694340f6dd4c02d63ee1a3aa32 100644 (file)
@@ -1,3 +1,7 @@
+2004-04-05  Angus Leeming  <leeming@lyx.org>
+
+       * QGraphics.C (getUnitNo): const-correct.
+
 2004-04-05  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * floatplacement.[Ch]: check whether we are in the float or
index cd117c32672b92e32f8eed61c3e7cc910ee293f8..7b691f6cff5b78514e3da4a7d2d045c3cbaaff8c 100644 (file)
@@ -109,7 +109,7 @@ int getItemNo(vector<string> 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;
index fafc14590b655f48d36bf7c60cedca8552c33a5d..edbcf9c5049154a312993bdb59a42a79846daabc 100644 (file)
@@ -1,3 +1,14 @@
+2004-05-04  Angus Leeming  <leeming@lyx.org>
+
+       * 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  <leeming@lyx.org>
 
        * Dialogs2.C:
index 4ce8a69ffbed80df6602f4d650b18e01200d5dc8..e1fcb2a9456e47c91b7f842cd2777869ddf67343 100644 (file)
@@ -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.");
index af3f41d5cccedf081fc626648ca5f27369ac51d5..7063625e96204a6b9870892cafbd3d0ba9dda1aa 100644 (file)
@@ -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.");
index 4fafa0127c61feb13907db86ed42541fa7d1351b..1901b372366a6cbc390bdc41648682544a2edeb7 100644 (file)
@@ -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;
index 119233df6d63b0c5b4bb4f1e1e31ab1b61dadcd2..7a514945d5b3049e5031609191f53273ee3efd2f 100644 (file)
@@ -29,11 +29,10 @@ std::pair<std::string, std::string> 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);
index c8e89ed5a5b75b666d77611281c53e45ca9faa70..af25532d02b34ba43d96f208baf4d806d2d477b1 100644 (file)
@@ -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%"),
index 23d7bf69f703a94aa45fbeec0eb6e34dd439237f..ef74e411b7bc1ab7931eab69dfd86ad46feffa81 100644 (file)
@@ -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);