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
This commit is contained in:
Angus Leeming 2003-12-15 09:17:04 +00:00
parent 8ce47d882c
commit d7aad4e806
7 changed files with 44 additions and 37 deletions

View 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.

View 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

View 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

View File

@ -16,6 +16,7 @@
#include "ButtonController.h"
#include "xformsBC.h"
#include "xforms_helpers.h"
#include "ControlDocument.h"
#include "FormDocument.h"

View File

@ -11,16 +11,17 @@
#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...

View File

@ -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

View 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_));
}