]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/Color.h
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / Color.h
index 50ca142571c72a73f26cc0a88f220fe360b935eb..a297ae0765c3cf97f640ec7df7182e9cbc561701 100644 (file)
@@ -1,66 +1,78 @@
 // -*- C++ -*-
-/* This file is part of
- * ======================================================
- * 
- *           LyX, The Document Processor
- *      
- *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-2000 The LyX Team.
+/**
+ * \file Color.h
+ * 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.
+ */
+
+/* structs RGBColor and HSVColor to enable simple conversion between
+ * color spaces.
+ */
 
 #ifndef COLOR_H
 #define COLOR_H
 
-#include<utility> // for pair
+#include <string>
 
-#ifdef __GNUG_
-#pragma interface
-#endif
 
-#include "LString.h"
+class LColor_color;
 
-class HSV;
-class RGB;
 
-struct HSV {
+/** Given col, fills r, g, b in the range 0-255.
+    The function returns true if successful.
+    It returns false on failure and sets r, g, b to 0. */
+bool getRGBColor(LColor_color col,
+                unsigned int & r, unsigned int & g, unsigned int & b);
+
+struct RGBColor;
+/// returns a string of form #rrggbb, given an RGBColor struct
+std::string const X11hexname(RGBColor const & col);
+
+struct HSVColor {
        double h;
        double s;
        double v;
-       HSV() : h(0.0), s(0.0), v(0.0) {}
-       HSV(double hue, double sat, double val) : h(hue), s(sat), v(val) {}
-       HSV( RGB const & );
+       HSVColor() : h(0.0), s(0.0), v(0.0) {}
+       HSVColor(double hue, double sat, double val)
+               : h(hue), s(sat), v(val) {}
+       HSVColor(RGBColor const &);
 };
 
-struct RGB {
-       int r;
-       int g;
-       int b;
-       RGB() : r(0), g(0), b(0) {}
-       RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
-       RGB( HSV const & );
+struct RGBColor {
+       unsigned int r;
+       unsigned int g;
+       unsigned int b;
+       RGBColor() : r(0), g(0), b(0) {}
+       RGBColor(unsigned int red, unsigned int green, unsigned int blue)
+               : r(red), g(green), b(blue) {}
+       RGBColor(HSVColor const &);
+       /// \param x11hexname is of the form "#ffa071"
+       RGBColor(std::string const & x11hexname);
 };
 
-typedef std::pair<string, RGB> X11Color;
-
-/// struct holding xform-specific colors
-struct XFormColor {
-       string name;
-       int colorID;
-       RGB col;
-       XFormColor() : colorID(0) {}
-       string const getname() { return name; }
+struct NamedColor : public RGBColor {
+       std::string lyxname;
+       std::string guiname;
+       NamedColor() : RGBColor() {}
+       NamedColor(std::string const & lyx, std::string const & gui,
+                  RGBColor const & c)
+               : RGBColor(c), lyxname(lyx), guiname(gui) {}
+       RGBColor const & color() const { return *this; }
 };
 
 inline
-bool operator==(RGB const & c1, RGB const & c2)
+bool operator==(RGBColor const & c1, RGBColor const & c2)
 {
        return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
 }
 
 
 inline
-bool operator!=(RGB const & c1, RGB const & c2)
+bool operator!=(RGBColor const & c1, RGBColor const & c2)
 {
        return !(c1 == c2);
 }