New LColor::setColor

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8529 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Martin Vermeer 2004-03-25 15:51:21 +00:00
parent 7c70a8ee0f
commit 31c24b4002
5 changed files with 34 additions and 4 deletions

View File

@ -1,3 +1,12 @@
2004-03-25 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
Martin Vermeer <martin.vermeer@hut.fi>
* lyxfunc.C (dispatch):
* bufferparams.C (readToken): use the new LColor::setColor
* LColor.[Ch] (setColor): new version that takes two strings as
argument and creates a new color entry if necessary
2003-02-12 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* buffer.C (makeLaTeXFile): if the main latex file that is

View File

@ -229,6 +229,21 @@ bool LColor::setColor(LColor::color col, string const & x11name)
}
bool LColor::setColor(string const & lyxname, string const &x11name)
{
string const lcname = ascii_lowercase(lyxname);
if (pimpl_->transform.find(lcname) == pimpl_->transform.end()) {
lyxerr[Debug::GUI]
<< "LColor::setColor: Unknown color \""
<< lyxname << '"' << endl;
addColor(static_cast<color>(pimpl_->infotab.size()), lcname);
}
return setColor(static_cast<LColor::color>(pimpl_->transform[lcname]),
x11name);
}
LColor::color LColor::getFromGUIName(string const & guiname) const
{
Pimpl::InfoTab::const_iterator it = pimpl_->infotab.begin();
@ -254,7 +269,7 @@ LColor::color LColor::getFromLyXName(string const & lyxname) const
if (pimpl_->transform.find(lcname) == pimpl_->transform.end()) {
lyxerr << "LColor::getFromLyXName: Unknown color \""
<< lyxname << '"' << endl;
addColor(static_cast<color>(pimpl_->infotab.size()), lcname);
return none;
}
return static_cast<LColor::color>(pimpl_->transform[lcname]);

View File

@ -198,6 +198,12 @@ public:
*/
bool setColor(LColor::color col, std::string const & x11name);
/** set the given LyX color to the color defined by the X11
* name given \returns true if successful. A new color entry
* is created if the color is unknown
*/
bool setColor(std::string const & lyxname, std::string const & x11name);
/// Get the GUI name of \c color.
std::string const getGUIName(LColor::color c) const;

View File

@ -352,7 +352,8 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
// Update also the LColor table:
if (color == "none")
color = lcolor.getX11Name(LColor::background);
lcolor.setColor(lcolor.getFromLyXName(branch), color);
lcolor.setColor(branch, color);
}
}
} else if (token == "\\author") {

View File

@ -1073,8 +1073,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
(lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
x11_name != lcolor.getX11Name(LColor::graphicsbg));
LColor::color col = lcolor.getFromLyXName(lyx_name);
if (!lcolor.setColor(col, x11_name)) {
if (!lcolor.setColor(lyx_name, x11_name)) {
setErrorMessage(
bformat(_("Set-color \"%1$s\" failed "
"- color is undefined or "