]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/Color.h
Change glob() API to accept a dir parameter.
[lyx.git] / src / frontends / xforms / Color.h
index 768b6ef3c060288e9a61d65c5f3c5bc9342e0396..498f3e9e9ba3c5aa0c2b4a47598461b8471f93b6 100644 (file)
@@ -1,57 +1,68 @@
 // -*- 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
+class LColor_color;
 
-#include "LString.h"
+namespace lyx {
+namespace frontend {
 
-class HSVColor;
-class RGBColor;
+/** 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;
        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 & );
+       HSVColor(double hue, double sat, double val)
+               : h(hue), s(sat), v(val) {}
+       HSVColor(RGBColor const &);
 };
 
 struct RGBColor {
-       int r;
-       int g;
-       int b;
+       unsigned int r;
+       unsigned int g;
+       unsigned int b;
        RGBColor() : r(0), g(0), b(0) {}
-       RGBColor(int red, int green, int blue) : r(red), g(green), b(blue) {}
-       RGBColor( HSVColor const & );
+       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, RGBColor> X11Color;
-
-/// struct holding xform-specific colors
-struct XformColor {
-       string name;
-       int colorID;
-       RGBColor col;
-       XformColor() : colorID(0) {}
-       string const getname() { return name; }
-       static bool read( string const & );
-       static bool write( string const & );
+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
@@ -67,4 +78,7 @@ bool operator!=(RGBColor const & c1, RGBColor const & c2)
        return !(c1 == c2);
 }
 
+} // namespace frontend
+} // namespace lyx
+
 #endif