Many thanks, Ducan and Jean-Marc, about the X11 name info.
Using the following in FormPreferences::Colors::apply() to apply changes to
the LColors works like a dream. This leaves the way clear to ditch the
problematic X11 namebase browser in the colors tab and allow users to choose
any color they wish.
Lars, shall I do this before 1.1.6. It would simplify the code here
enormously (ie, I can strip out most of it) and would have no effect
elsewhere. Judging from the number of comments we've had from confused users
it would be a good thing to do.
Angus
In the future, it also means that an LColor class can be derived from
RGBColor. The X11-specific ColorHandler would do this ostringstream stuff
itself.
A.
// 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());
if (lc == LColor::inherit) continue;
// Create a valid X11 name of the form "#rrggbb"
RGBColor const & col = (*cit).color();
ostringstream ostr;
ostr << "#" << std::setbase(16) << std::setfill('0')
<< std::setw(2) << col.r
<< std::setw(2) << col.g
<< std::setw(2) << col.b;
string const hexname = ostr.str().c_str();
lyxerr[Debug::GUI]
<< "FormPreferences::Colors::apply: "
<< "resetting LColor " << lcolor.getGUIName(lc)
<< " from \"" << lcolor.getX11Name(lc)
<< "\" to \"" << hexname << "\"."
<< endl;
string const s = lcolor.getLyXName(lc) + string(" ") + hexname;
parent_.lv_->getLyXFunc()->Dispatch(LFUN_SET_COLOR, s);
// // Ascertain the X11 name
// RGBColor const & col = (*cit).color();
// vector<NamedColor>::const_iterator cit2 =
// find(colorDB.begin(), colorDB.end(), col);
// if (cit2 == colorDB.end()) continue;
// if (lcolor.getX11Name(lc) != (*cit2).getname()) {
// lyxerr[Debug::GUI]
// << "FormPreferences::Colors::apply: "
// << "resetting LColor " << lcolor.getGUIName(lc)
// << " from \"" << lcolor.getX11Name(lc)
// << "\" to \"" << (*cit2).getname() << "\"."
// << endl;
// string const arg =
// lcolor.getLyXName(lc) + string(" ") +
// (*cit2).getname();
// parent_.lv_->getLyXFunc()->
// Dispatch(LFUN_SET_COLOR, arg);
// }
}