]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/Color.C
remove defaults stuff, let Qt handle no toolbar
[lyx.git] / src / frontends / xforms / Color.C
index 82706e055ea04c05a4eb0552ef3c2f6ca8a4877b..25c9d3dcd84cca7425100aa9de13fdc2c3722879 100644 (file)
@@ -1,26 +1,25 @@
-/* This file is part of
- * ======================================================
- * 
- *           LyX, The Document Processor
- *      
- *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-2001 The LyX Team.
+/**
+ * \file Color.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *======================================================*/
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
+ */
 
 #include <config.h>
 
+
+#include "Color.h"
 #include <algorithm> // max
 #include <cmath> // floor
-
 #include FORMS_H_LOCATION
 
-#ifdef __GNUG_
-#pragma implementation
+#ifndef CXX_GLOBAL_CSTD
+using std::floor;
 #endif
 
-#include "Color.h"
-
 using std::max;
 using std::min;
 
@@ -30,14 +29,37 @@ int const nohue = -1;
 
 } // namespace anon
 
+
+bool getRGBColor(LColor::color col,
+                unsigned int & r, unsigned int & g, unsigned int & b)
+{
+       string const name = lcolor.getX11Name(col);
+       Display * const display = fl_get_display();
+       Colormap const cmap = fl_state[fl_get_vclass()].colormap;
+       XColor xcol, ccol;
+
+       if (XLookupColor(display, cmap, name.c_str(), &xcol, &ccol) == 0) {
+               r = 0;
+               g = 0;
+               b = 0;
+               return false;
+       }
+
+       r = xcol.red   / 256;
+       g = xcol.green / 256;
+       b = xcol.blue  / 256;
+       return true;
+}
+
+
 RGBColor::RGBColor(HSVColor const & hsv)
 {
        double h = hsv.h;
        double const s = hsv.s;
        double const v = hsv.v;
-       
+
        double rd, gd, bd;
-       
+
        if (h == nohue || s == 0.0) {
                rd = gd = bd = v;
        } else {
@@ -103,8 +125,8 @@ HSVColor::HSVColor(RGBColor const & rgb)
        double const g = rgb.g / 255.0;
        double const b = rgb.b / 255.0;
 
-       double const maxval = max( max( r, g), b);
-       double const minval = min( min( r, g), b);
+       double const maxval = max(max(r, g), b);
+       double const minval = min(min(r, g), b);
 
        v = maxval;