]> git.lyx.org Git - features.git/commitdiff
Try and minimize the use of LColor::getFromGUIName. In fact, the only
authorAngus Leeming <leeming@lyx.org>
Mon, 15 Dec 2003 09:17:04 +0000 (09:17 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 15 Dec 2003 09:17:04 +0000 (09:17 +0000)
place still using it is mathed's MathColorInset.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8249 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/frontends/xforms/ChangeLog
src/frontends/xforms/Color.h
src/frontends/xforms/Dialogs2.C
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/FormPreferences.h
src/metricsinfo.C

index 9052b6a2380fc882bfa78ece9427c3d1fdfde7dd..e18e98afec398c552e6b6c9002542c57129cc4c6 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-15  Angus Leeming  <leeming@lyx.org>
+
+       * metricsinfo.C (ColorChanger): use LColor::getFromLyXName rather
+       than getFromGUIName to manipulate the color.
+
 2003-12-14  Angus Leeming  <leeming@lyx.org>
 
        BranchList.[Ch]: minimize the API.
index 919ebf601ecfd4a78724d601c0e0dba3c480d75a..8475f9eb13ffd4064492f77bb42a27e940486e3b 100644 (file)
@@ -1,3 +1,16 @@
+2003-12-15  Angus Leeming  <leeming@lyx.org>
+
+       * Color.h (NamedColor): store both the LyX and the GUI name.
+
+       * FormPreferences.h: Remove unused structs SortColorsByName,
+       SortColorsByColor. Remove unused #include "xforms_helpers.h".
+
+       * Dialogs2.C: add #include "xforms_helpers.h".
+
+       * FormPreferences.C: when manipulating the colors of the GUI use the
+       LyX name, rather than the translated GUI name, to identify the
+       associated LColor::color.
+
 2003-12-14  Angus Leeming  <leeming@lyx.org>
 
        * FormBranch.C: use the List interface to BranchList, simplifying the
index 79458b33bb7d1d70509e9968f2317cdd6a6d7b9a..a297ae0765c3cf97f640ec7df7182e9cbc561701 100644 (file)
@@ -55,12 +55,13 @@ struct RGBColor {
 };
 
 struct NamedColor : public RGBColor {
-       std::string name;
+       std::string lyxname;
+       std::string guiname;
        NamedColor() : RGBColor() {}
-       NamedColor(std::string const & n, RGBColor const & c)
-               : RGBColor(c), name(n) {}
+       NamedColor(std::string const & lyx, std::string const & gui,
+                  RGBColor const & c)
+               : RGBColor(c), lyxname(lyx), guiname(gui) {}
        RGBColor const & color() const { return *this; }
-       std::string const & getname() const { return name; }
 };
 
 inline
index 24d301f3bb627f1c47ddff3361af6f611a7a12d3..11ad084acad0fb05b6848b7c51881e952f450330 100644 (file)
@@ -16,6 +16,7 @@
 #include "ButtonController.h"
 
 #include "xformsBC.h"
+#include "xforms_helpers.h"
 
 #include "ControlDocument.h"
 #include "FormDocument.h"
index 42965a99a5d9c00cc911b058313d422d3710fafa..3833d512e48969586a85188c4edd802d2f426b4f 100644 (file)
 #include <config.h>
 
 #include "FormPreferences.h"
-#include "ControlPrefs.h"
 #include "forms/form_preferences.h"
 
 #include "FormColorpicker.h"
 #include "forms_gettext.h"
 #include "input_validators.h"
 #include "xformsBC.h"
+#include "xforms_helpers.h"
 
-#include "controllers/helper_funcs.h" // getSecond
+#include "controllers/ControlPrefs.h"
 #include "controllers/frnt_lang.h"
+#include "controllers/helper_funcs.h" // getSecond
 
 #include "buffer.h"
 #include "converter.h"
@@ -460,7 +461,7 @@ void FormPreferences::Colors::apply()
        // Now do the same for the LyX LColors...
        for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
             cit != lyxColorDB.end(); ++cit) {
-               LColor::color lc = lcolor.getFromGUIName(cit->getname());
+               LColor::color lc = lcolor.getFromLyXName(cit->lyxname);
                if (lc == LColor::inherit) continue;
 
                // Create a valid X11 name of the form "#rrggbb"
@@ -572,25 +573,29 @@ void FormPreferences::Colors::LoadBrowserLyX()
        xformsColorDB.clear();
        XformsColor xcol;
 
-       xcol.name = _("GUI background");
+       xcol.lyxname = "GUI background";
+       xcol.guiname = _("GUI background");
        xcol.colorID = FL_COL1;
        fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
 
        xformsColorDB.push_back(xcol);
 
-       xcol.name = _("GUI text");
+       xcol.lyxname = "GUI text";
+       xcol.guiname = _("GUI text");
        xcol.colorID = FL_BLACK;
        fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
 
        xformsColorDB.push_back(xcol);
 
-       xcol.name = _("GUI selection");
+       xcol.lyxname = "GUI selection";
+       xcol.guiname = _("GUI selection");
        xcol.colorID = FL_YELLOW;
        fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
 
        xformsColorDB.push_back(xcol);
 
-       xcol.name = _("GUI pointer");
+       xcol.lyxname = "GUI pointer";
+       xcol.guiname = _("GUI pointer");
        xcol.colorID = GUI_COLOR_CURSOR;
        fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
 
@@ -639,7 +644,7 @@ void FormPreferences::Colors::LoadBrowserLyX()
                }
 
                // Finally, push the color onto the database
-               NamedColor ncol(lcolor.getGUIName(lc), col);
+               NamedColor ncol(lcolor.getLyXName(lc), lcolor.getGUIName(lc), col);
                lyxColorDB.push_back(ncol);
        }
 
@@ -649,11 +654,11 @@ void FormPreferences::Colors::LoadBrowserLyX()
        fl_clear_browser(colbr);
        for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
             cit != xformsColorDB.end(); ++cit) {
-               fl_addto_browser(colbr, cit->getname().c_str());
+               fl_addto_browser(colbr, cit->guiname.c_str());
        }
        for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
             cit != lyxColorDB.end(); ++cit) {
-               fl_addto_browser(colbr, cit->getname().c_str());
+               fl_addto_browser(colbr, cit->guiname.c_str());
        }
 
        // just to be safe...
index d9d76dfd4d1e9faf0cfb540d003e82e5d6ad2d05..689ac758a6576330c3b6a7b283848f180d482e44 100644 (file)
@@ -14,7 +14,6 @@
 #define FORMPREFERENCES_H
 
 #include "FormBase.h"
-#include "xforms_helpers.h" // XformColor
 
 #include "lyx_forms.h"
 
 class ControlPrefs;
 
 class Dialogs;
+class FormColorpicker;
 class LyXRC;
 class LyXView;
 class NamedColor;
 class RGBColor;
-class FormColorpicker;
+class XformsColor;
 
 struct FD_preferences;
 struct FD_preferences_colors;
@@ -505,24 +505,6 @@ private:
        ScreenFonts screen_fonts_;
        ///
        SpellOptions spelloptions_;
-
-       /** A couple of helper structs to enable colors to be sorted by name
-           and by color */
-       ///
-       struct SortColorsByName {
-               ///
-               int operator()(NamedColor const & a, NamedColor const & b) const
-                       { return (a.getname() < b.getname()); }
-       };
-       ///
-       struct SortColorsByColor {
-               ///
-               SortColorsByColor(RGBColor c) : col(c) {}
-               ///
-               int operator()(RGBColor const &, RGBColor const &) const;
-               ///
-               RGBColor col;
-       };
 };
 
 #endif // FORMPREFERENCES_H
index 5bee29a118d165e766d0bb7a2fd61ca7ec684711..1283c687f2e5b8fb2f75bd10b2d411c5acd4964f 100644 (file)
@@ -176,12 +176,12 @@ WidthChanger::~WidthChanger()
 ColorChanger::ColorChanger(LyXFont & font, string const & color)
        : Changer<LyXFont, string>(font)
 {
-       save_ = lcolor.getFromGUIName(color);
-       font.setColor(lcolor.getFromGUIName(color));
+       save_ = lcolor.getFromLyXName(color);
+       font.setColor(lcolor.getFromLyXName(color));
 }
 
 
 ColorChanger::~ColorChanger()
 {
-       orig_.setColor(lcolor.getFromGUIName(save_));
+       orig_.setColor(lcolor.getFromLyXName(save_));
 }