From d7aad4e8067c86f997c0e762bc5cd8ca132c77bd Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Mon, 15 Dec 2003 09:17:04 +0000 Subject: [PATCH] Try and minimize the use of LColor::getFromGUIName. In fact, the only 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 | 5 +++++ src/frontends/xforms/ChangeLog | 13 +++++++++++++ src/frontends/xforms/Color.h | 9 +++++---- src/frontends/xforms/Dialogs2.C | 1 + src/frontends/xforms/FormPreferences.C | 25 +++++++++++++++---------- src/frontends/xforms/FormPreferences.h | 22 ++-------------------- src/metricsinfo.C | 6 +++--- 7 files changed, 44 insertions(+), 37 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 9052b6a238..e18e98afec 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-12-15 Angus Leeming + + * metricsinfo.C (ColorChanger): use LColor::getFromLyXName rather + than getFromGUIName to manipulate the color. + 2003-12-14 Angus Leeming BranchList.[Ch]: minimize the API. diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 919ebf601e..8475f9eb13 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,16 @@ +2003-12-15 Angus Leeming + + * 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 * FormBranch.C: use the List interface to BranchList, simplifying the diff --git a/src/frontends/xforms/Color.h b/src/frontends/xforms/Color.h index 79458b33bb..a297ae0765 100644 --- a/src/frontends/xforms/Color.h +++ b/src/frontends/xforms/Color.h @@ -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 diff --git a/src/frontends/xforms/Dialogs2.C b/src/frontends/xforms/Dialogs2.C index 24d301f3bb..11ad084aca 100644 --- a/src/frontends/xforms/Dialogs2.C +++ b/src/frontends/xforms/Dialogs2.C @@ -16,6 +16,7 @@ #include "ButtonController.h" #include "xformsBC.h" +#include "xforms_helpers.h" #include "ControlDocument.h" #include "FormDocument.h" diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 42965a99a5..3833d512e4 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -11,16 +11,17 @@ #include #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::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::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::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... diff --git a/src/frontends/xforms/FormPreferences.h b/src/frontends/xforms/FormPreferences.h index d9d76dfd4d..689ac758a6 100644 --- a/src/frontends/xforms/FormPreferences.h +++ b/src/frontends/xforms/FormPreferences.h @@ -14,7 +14,6 @@ #define FORMPREFERENCES_H #include "FormBase.h" -#include "xforms_helpers.h" // XformColor #include "lyx_forms.h" @@ -23,11 +22,12 @@ 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 diff --git a/src/metricsinfo.C b/src/metricsinfo.C index 5bee29a118..1283c687f2 100644 --- a/src/metricsinfo.C +++ b/src/metricsinfo.C @@ -176,12 +176,12 @@ WidthChanger::~WidthChanger() ColorChanger::ColorChanger(LyXFont & font, string const & color) : Changer(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_)); } -- 2.39.2