]> git.lyx.org Git - lyx.git/blobdiff - src/Color.cpp
Rename BufferView::updateScrollbar to show what does
[lyx.git] / src / Color.cpp
index 6f4135030e55ddda538f2ae5076b746a2966c2f2..cf297e909b5a3629d39ca8de0d3beb2c8c5a72b4 100644 (file)
@@ -153,6 +153,16 @@ RGBColor const RGBColorFromLaTeX(string const & color)
 }
 
 
+RGBColor const inverseRGBColor(RGBColor color)
+{
+       color.r = 255 - color.r;
+       color.g = 255 - color.g;
+       color.b = 255 - color.b;
+
+       return color;
+}
+
+
 Color::Color(ColorCode base_color) : baseColor(base_color),
        mergeColor(Color_ignore)
 {}
@@ -254,7 +264,7 @@ ColorSet::ColorSet()
        { Color_foreground, N_("text"), "foreground", black, Linen, "foreground" },
        { Color_selection, N_("selection"), "selection", "#add8e6", "#add8e6", "selection" },
        { Color_selectiontext, N_("selected text"), "selectiontext", black, black, "selectiontext" },
-       { Color_latex, N_("LaTeX text"), "latex", DarkRed, "#f2af7d", "latex" },
+       { Color_latex, N_("LaTeX text"), "latex", DarkRed, "#D66613", "latex" },
        { Color_textlabel1, N_("Text label 1"), "textlabel1", blue, "#86a4ff", "textlabel1" },
        { Color_textlabel2, N_("Text label 2"), "textlabel2", Green, green, "textlabel2" },
        { Color_textlabel3, N_("Text label 3"), "textlabel3", magenta, magenta, "textlabel3" },
@@ -331,8 +341,9 @@ ColorSet::ColorSet()
        { Color_buttonhoverbg, N_("button background under focus"), "buttonhoverbg", "#C7C7CA", "#C7C7CA", "buttonhoverbg" },
        { Color_paragraphmarker, N_("paragraph marker"), "paragraphmarker", grey80, grey40, "paragraphmarker"},
        { Color_previewframe, N_("preview frame"), "previewframe", black, Linen, "previewframe"},
-       { Color_inherit, N_("inherit"), "inherit", black, Linen, "inherit" },
        { Color_regexpframe, N_("regexp frame"), "regexpframe", Green, green, "regexpframe" },
+       { Color_bookmark, N_("bookmark"), "bookmark", RoyalBlue, RoyalBlue, "bookmark" },
+       { Color_inherit, N_("inherit"), "inherit", black, Linen, "inherit" },
        { Color_ignore, N_("ignore"), "ignore", black, Linen, "ignore" },
        { Color_ignore, nullptr, nullptr, nullptr, nullptr, nullptr }
        };
@@ -447,6 +458,64 @@ bool ColorSet::setColor(string const & lyxname, string const & x11hexname,
 }
 
 
+bool ColorSet::setLaTeXName(string const & lyxname, string const & latexname)
+{
+       string const lcname = ascii_lowercase(lyxname);
+       if (lyxcolors.find(lcname) == lyxcolors.end()) {
+               LYXERR(Debug::GUI, "ColorSet::setLaTeXName: Unknown color \""
+                      << lyxname << '"');
+               addColor(static_cast<ColorCode>(infotab.size()), lcname);
+       }
+
+       ColorCode col = lyxcolors[lcname];
+       InfoTab::iterator it = infotab.find(col);
+       if (it == infotab.end()) {
+               LYXERR0("Color " << col << " not found in database.");
+               return false;
+       }
+
+       // "inherit" is returned for colors not in the database
+       // (and anyway should not be redefined)
+       if (col == Color_none || col == Color_inherit || col == Color_ignore) {
+               LYXERR0("Color " << getLyXName(col) << " may not be redefined.");
+               return false;
+       }
+
+       if (!latexname.empty())
+               it->second.latexname = latexname;
+       return true;
+}
+
+
+bool ColorSet::setGUIName(string const & lyxname, string const & guiname)
+{
+       string const lcname = ascii_lowercase(lyxname);
+       if (lyxcolors.find(lcname) == lyxcolors.end()) {
+               LYXERR(Debug::GUI, "ColorSet::setGUIName: Unknown color \""
+                      << lyxname << '"');
+               return false;
+       }
+
+       ColorCode col = lyxcolors[lcname];
+       InfoTab::iterator it = infotab.find(col);
+       if (it == infotab.end()) {
+               LYXERR0("Color " << col << " not found in database.");
+               return false;
+       }
+
+       // "inherit" is returned for colors not in the database
+       // (and anyway should not be redefined)
+       if (col == Color_none || col == Color_inherit || col == Color_ignore) {
+               LYXERR0("Color " << getLyXName(col) << " may not be redefined.");
+               return false;
+       }
+
+       if (!guiname.empty())
+               it->second.guiname = guiname;
+       return true;
+}
+
+
 void ColorSet::addColor(ColorCode c, string const & lyxname)
 {
        ColorEntry ce = { c, "", "", "", "", lyxname.c_str() };