]> git.lyx.org Git - features.git/blobdiff - src/Color.cpp
InsetIndex: hide printTree behind a LYX_INSET_INDEX_DEBUG flag
[features.git] / src / Color.cpp
index 627b62b4a76c10a6baabf53641c1fdb9729689f4..7cb520d27896db59ce04c52c2dae0066a1e736ee 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)
 {}
@@ -312,14 +322,14 @@ ColorSet::ColorSet()
        { Color_eolmarker, N_("end-of-line marker"), "eolmarker", Brown, Brown, "eolmarker" },
        { Color_appendix, N_("appendix marker"), "appendix", Brown, Brown, "appendix" },
        { Color_changebar, N_("change bar"), "changebar", blue, "#86a4ff", "changebar" },
-       { Color_deletedtext, N_("deleted text (output)"), "deletedtext", "#ff0000", "#ff0000", "deletedtext" },
-       { Color_addedtext, N_("added text (output)"), "addedtext", "#0000ff", "#0000ff", "addedtext" },
-       { Color_addedtextauthor1, N_("added text (workarea, 1st author)"), "changedtextauthor1", "#0000ff", "#86a4ff", "changedtextauthor1" },
-       { Color_addedtextauthor2, N_("added text (workarea, 2nd author)"), "changedtextauthor2", "#ff00ff", "#ee86ee", "changedtextauthor2" },
-       { Color_addedtextauthor3, N_("added text (workarea, 3rd author)"), "changedtextauthor3", "#ff0000", "#ea8989", "changedtextauthor3" },
-       { Color_addedtextauthor4, N_("added text (workarea, 4th author)"), "changedtextauthor4", "#aa00ff", "#c371ec", "changedtextauthor4" },
-       { Color_addedtextauthor5, N_("added text (workarea, 5th author)"), "changedtextauthor5", "#55aa00", "#acd780", "changedtextauthor5" },
-       { Color_deletedtextmodifier, N_("deleted text modifier (workarea)"), "deletedtextmodifier", white, white, "deletedtextmodifier" },
+       { Color_deletedtext_output, N_("deleted text (output)"), "deletedtext", "#ff0000", "#ff0000", "deletedtext" },
+       { Color_addedtext_output, N_("added text (output)"), "addedtext", "#0000ff", "#0000ff", "addedtext" },
+       { Color_changedtext_workarea_author1, N_("changed text (workarea, 1st author)"), "changedtextauthor1", "#0000ff", "#86a4ff", "changedtextauthor1" },
+       { Color_changedtext_workarea_author2, N_("changed text (workarea, 2nd author)"), "changedtextauthor2", "#ff00ff", "#ee86ee", "changedtextauthor2" },
+       { Color_changedtext_workarea_author3, N_("changed text (workarea, 3rd author)"), "changedtextauthor3", "#ff0000", "#ea8989", "changedtextauthor3" },
+       { Color_changedtext_workarea_author4, N_("changed text (workarea, 4th author)"), "changedtextauthor4", "#aa00ff", "#c371ec", "changedtextauthor4" },
+       { Color_changedtext_workarea_author5, N_("changed text (workarea, 5th author)"), "changedtextauthor5", "#55aa00", "#acd780", "changedtextauthor5" },
+       { Color_deletedtext_workarea_modifier, N_("deleted text modifier (workarea)"), "deletedtextmodifier", white, white, "deletedtextmodifier" },
        { Color_added_space, N_("added space markers"), "added_space", Brown, Brown, "added_space" },
        { Color_tabularline, N_("table line"), "tabularline", black, Linen, "tabularline" },
        { Color_tabularonoffline, N_("table on/off line"), "tabularonoffline", "#b0c4de", "#23497b", "tabularonoffline" },
@@ -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() };