]> git.lyx.org Git - lyx.git/blobdiff - src/LColor.C
More fixes to insettabular/text (and some missing features added).
[lyx.git] / src / LColor.C
index 9fec78cbcaaccc399945072cb607ffced2b0b5b2..0d3b77b6981246ee56a9176e053320ba1373e702 100644 (file)
@@ -22,6 +22,7 @@
 #include "gettext.h"
 #include "support/lstrings.h"
 
+using std::endl;
 
 void LColor::fill(LColor::color col, string const & gui,
                  string const & latex, string const & x11,
@@ -57,8 +58,9 @@ LColor::LColor()
        { cyan, N_("cyan"), "cyan", "cyan", "cyan" },
        { magenta, N_("magenta"), "magenta", "magenta", "magenta" },
        { yellow, N_("yellow"), "yellow", "yellow", "yellow" },
+       { cursor, N_("cursor"), "cursor", "black", "cursor" },
        { background, N_("background"), "background", "linen", "background" },
-       { foreground, N_("foreground"), "foreground", "black", "foreground" },
+       { foreground, N_("text"), "foreground", "black", "foreground" },
        { selection, N_("selection"), "selection", "LightBlue", "selection" },
        { latex, N_("latex"), "latex", "DarkRed", "latex" },
        { floats, N_("floats"), "floats", "red", "floats" },
@@ -66,11 +68,12 @@ LColor::LColor()
        { notebg, N_("note background"), "notebg", "yellow", "notebg" },
        { noteframe, N_("note frame"), "noteframe", "black", "noteframe" },
        { depthbar, N_("depth bar"), "depthbar", "IndianRed", "depthbar" },
+       { language, N_("language"), "language", "Blue", "language" },
        { command, N_("command-inset"), "command", "black", "command" },
        { commandbg, N_("command-inset background"), "commandbg", "grey80", "commandbg" },
-       { commandframe, N_("inset frame"), "commandframe", "black", "commandframe" },
+       { commandframe, N_("command-inset frame"), "commandframe", "black", "commandframe" },
        { accent, N_("accent"), "accent", "black", "accent" },
-       { accentbg, N_("accent background"), "accentbg", "offwhite", "accentbg" },
+       { accentbg, N_("accent background"), "accentbg", "linen", "accentbg" },
        { accentframe, N_("accent frame"), "accentframe", "linen", "accentframe" },
        { minipageline, N_("minipage line"), "minipageline", "violet", "minipageline" },
        { special, N_("special char"), "special", "RoyalBlue", "special" },
@@ -82,7 +85,7 @@ LColor::LColor()
        { footnote, N_("footnote"), "footnote", "DarkRed", "footnote" },
        { footnotebg, N_("footnote background"), "footnotebg", "grey60", "footnotebg" },
        { footnoteframe, N_("footnote frame"), "footnoteframe", "IndianRed", "footnoteframe" },
-       { ert, N_("ert"), "ert", "DarkRed", "ert" },
+       { ert, N_("latex inset"), "ert", "DarkRed", "ert" },
        { inset, N_("inset"), "inset", "black", "inset" },
        { insetbg, N_("inset background"), "insetbg", "grey60", "insetbg" },
        { insetframe, N_("inset frame"), "insetframe", "IndianRed", "insetframe" },
@@ -117,17 +120,17 @@ LColor::LColor()
 }
 
 
-string LColor::getGUIName(LColor::color c) const
+string const LColor::getGUIName(LColor::color c) const
 {
        InfoTab::const_iterator ici = infotab.find(c);
        if (ici != infotab.end())
-               return _((*ici).second.guiname.c_str());
+               return _((*ici).second.guiname);
 
        return "none";
 }
 
 
-string LColor::getX11Name(LColor::color c) const
+string const LColor::getX11Name(LColor::color c) const
 {
        InfoTab::const_iterator ici = infotab.find(c);
        if (ici != infotab.end()) 
@@ -140,7 +143,7 @@ string LColor::getX11Name(LColor::color c) const
 }
 
 
-string LColor::getLaTeXName(LColor::color c) const
+string const LColor::getLaTeXName(LColor::color c) const
 {
        InfoTab::const_iterator ici = infotab.find(c);
        if (ici != infotab.end())
@@ -149,7 +152,7 @@ string LColor::getLaTeXName(LColor::color c) const
 }
 
 
-string LColor::getLyXName(LColor::color c) const
+string const LColor::getLyXName(LColor::color c) const
 {
        InfoTab::const_iterator ici = infotab.find(c);
        if (ici != infotab.end())
@@ -170,14 +173,31 @@ void LColor::setColor(LColor::color col, string const & x11name)
 }
 
 
+bool LColor::setColor(string const & lyxname, string const & x11name)
+{
+       color col = getFromLyXName (lyxname);
+
+       // "inherit" is returned for colors not in the database
+       // (and anyway should not be redefined)
+       if (col == inherit || col == ignore) {
+               lyxerr << "Color " << lyxname << " is undefined or may not be"
+                       " redefined" << endl;
+               return false;
+       }
+       setColor (col, x11name);
+       return true;
+}
+
+
 LColor::color LColor::getFromGUIName(string const & guiname) const
 {
        InfoTab::const_iterator ici = infotab.begin();
-       for (; ici != infotab.end(); ++ici) {
-               if (!compare_no_case((*ici).second.guiname, guiname))
+       InfoTab::const_iterator end = infotab.end();
+       for (; ici != end; ++ici) {
+               if (!compare_no_case(_((*ici).second.guiname), guiname))
                        return (*ici).first;
        }
-       return LColor::ignore;
+       return LColor::inherit;
 }
 
 
@@ -185,7 +205,8 @@ LColor::color LColor::getFromLyXName(string const & lyxname) const
 {
        
        InfoTab::const_iterator ici = infotab.begin();
-       for (; ici != infotab.end(); ++ici) {
+       InfoTab::const_iterator end = infotab.end();
+       for (; ici != end; ++ici) {
                if (!compare_no_case((*ici).second.lyxname, lyxname))
                        return (*ici).first;
        }
@@ -194,3 +215,5 @@ LColor::color LColor::getFromLyXName(string const & lyxname) const
 
 // The evil global LColor instance
 LColor lcolor;
+// An equally evil global system LColor instance
+LColor system_lcolor;