]> git.lyx.org Git - lyx.git/blobdiff - src/Color.cpp
SCons: msvc does not need this /TP option any more after we rename .C => .cpp. Also...
[lyx.git] / src / Color.cpp
index 125321c1de1ca6937a2c8dabf61c9a67dd7f3613..daaa0aacd69c5b45036ac19fe7702650c27ed98f 100644 (file)
 #include "support/lstrings.h"
 
 #include <map>
+#include <cmath>
+#include <sstream>
+#include <iomanip>
 
 
-namespace lyx {
+#ifndef CXX_GLOBAL_CSTD
+using std::floor;
+#endif
 
-using support::compare_ascii_no_case;
-using support::ascii_lowercase;
+using std::max;
+using std::min;
+using std::setw;
 
-using std::endl;
+using std::istringstream;
+using std::ostringstream;
 using std::string;
+using std::endl;
+
+using lyx::support::compare_ascii_no_case;
+using lyx::support::ascii_lowercase;
 
 
 namespace {
 
 struct ColorEntry {
-       Color::color lcolor;
+       lyx::Color::color lcolor;
        char const * guiname;
        char const * latexname;
        char const * x11name;
        char const * lyxname;
 };
 
+int const nohue = -1;
+
+int hexstrToInt(string const & str)
+{
+       int val = 0;
+       istringstream is(str);
+       is >> std::setbase(16) >> val;
+       return val;
 }
 
+} // namespace anon
+
+
+
+namespace lyx {
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// RGBColor
+//
+/////////////////////////////////////////////////////////////////////
+
+
+string const X11hexname(RGBColor const & col)
+{
+       ostringstream ostr;
+
+       ostr << '#' << std::setbase(16) << std::setfill('0')
+            << setw(2) << col.r
+            << setw(2) << col.g
+            << setw(2) << col.b;
+
+       return ostr.str();
+}
+
+
+RGBColor::RGBColor(string const & x11hexname)
+       : r(0), g(0), b(0)
+{
+       BOOST_ASSERT(x11hexname.size() == 7 && x11hexname[0] == '#');
+       r = hexstrToInt(x11hexname.substr(1,2));
+       g = hexstrToInt(x11hexname.substr(3,2));
+       b = hexstrToInt(x11hexname.substr(5,2));
+}
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// Color::Pimpl
+//
+/////////////////////////////////////////////////////////////////////
+
 class Color::Pimpl {
 public:
        ///
@@ -125,6 +187,7 @@ Color::Color()
        { graphicsbg, N_("graphics background"), "graphicsbg", "linen", "graphicsbg" },
        { mathmacrobg, N_("Math macro background"), "mathmacrobg", "linen", "mathmacrobg" },
        { mathframe, N_("math frame"), "mathframe", "Magenta", "mathframe" },
+       { mathcorners, N_("math corners"), "mathcorners", "linen", "mathcorners" },
        { mathline, N_("math line"), "mathline", "Blue", "mathline" },
        { captionframe, N_("caption frame"), "captionframe", "DarkRed", "captionframe" },
        { collapsable, N_("collapsable inset text"), "collapsable", "DarkRed", "collapsable" },
@@ -135,12 +198,11 @@ Color::Color()
        { eolmarker, N_("end-of-line marker"), "eolmarker", "Brown", "eolmarker" },
        { appendix, N_("appendix marker"), "appendix", "Brown", "appendix" },
        { changebar, N_("change bar"), "changebar", "Blue", "changebar" },
-       { strikeout, N_("Deleted text"), "strikeout", "Red", "strikeout" },
-       { newtext, N_("Added text"), "newtext", "Blue", "newtext" },
+       { deletedtext, N_("Deleted text"), "deletedtext", "#ff0000", "deletedtext" },
+       { addedtext, N_("Added text"), "addedtext", "#0000ff", "addedtext" },
        { added_space, N_("added space markers"), "added_space", "Brown", "added_space" },
        { topline, N_("top/bottom line"), "topline", "Brown", "topline" },
-       { tabularline, N_("table line"), "tabularline", "black",
-            "tabularline" },
+       { tabularline, N_("table line"), "tabularline", "black", "tabularline" },
        { tabularonoffline, N_("table on/off line"), "tabularonoffline",
             "LightSteelBlue", "tabularonoffline" },
        { bottomarea, N_("bottom area"), "bottomarea", "grey40", "bottomarea" },