2000-11-10 17:29:47 +00:00
|
|
|
// -*- C++ -*-
|
2002-03-11 17:00:41 +00:00
|
|
|
/**
|
|
|
|
* \file Color.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2000-11-10 17:29:47 +00:00
|
|
|
*
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author Angus Leeming
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-03-11 17:00:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* structs RGBColor and HSVColor to enable simple conversion between
|
|
|
|
* color spaces.
|
|
|
|
*/
|
2000-11-10 17:29:47 +00:00
|
|
|
|
|
|
|
#ifndef COLOR_H
|
|
|
|
#define COLOR_H
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
#include <string>
|
2003-09-15 15:20:22 +00:00
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
2000-11-10 17:29:47 +00:00
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
struct RGBColor;
|
2003-08-06 18:42:58 +00:00
|
|
|
/// returns a string of form #rrggbb, given an RGBColor struct
|
2003-10-06 15:43:21 +00:00
|
|
|
std::string const X11hexname(RGBColor const & col);
|
2000-11-10 17:29:47 +00:00
|
|
|
|
2000-11-13 10:35:02 +00:00
|
|
|
struct HSVColor {
|
2000-11-10 17:29:47 +00:00
|
|
|
double h;
|
|
|
|
double s;
|
|
|
|
double v;
|
2000-11-13 10:35:02 +00:00
|
|
|
HSVColor() : h(0.0), s(0.0), v(0.0) {}
|
2000-11-14 02:01:57 +00:00
|
|
|
HSVColor(double hue, double sat, double val)
|
|
|
|
: h(hue), s(sat), v(val) {}
|
|
|
|
HSVColor(RGBColor const &);
|
2000-11-10 17:29:47 +00:00
|
|
|
};
|
|
|
|
|
2000-11-13 10:35:02 +00:00
|
|
|
struct RGBColor {
|
2003-02-11 17:53:38 +00:00
|
|
|
unsigned int r;
|
|
|
|
unsigned int g;
|
|
|
|
unsigned int b;
|
2000-11-13 10:35:02 +00:00
|
|
|
RGBColor() : r(0), g(0), b(0) {}
|
2003-02-11 17:53:38 +00:00
|
|
|
RGBColor(unsigned int red, unsigned int green, unsigned int blue)
|
2000-11-14 02:01:57 +00:00
|
|
|
: r(red), g(green), b(blue) {}
|
|
|
|
RGBColor(HSVColor const &);
|
2003-08-06 18:42:58 +00:00
|
|
|
/// \param x11hexname is of the form "#ffa071"
|
2003-10-06 15:43:21 +00:00
|
|
|
RGBColor(std::string const & x11hexname);
|
2000-11-10 17:29:47 +00:00
|
|
|
};
|
|
|
|
|
2000-11-15 18:02:45 +00:00
|
|
|
struct NamedColor : public RGBColor {
|
2003-12-15 09:17:04 +00:00
|
|
|
std::string lyxname;
|
|
|
|
std::string guiname;
|
2000-11-15 18:02:45 +00:00
|
|
|
NamedColor() : RGBColor() {}
|
2003-12-15 09:17:04 +00:00
|
|
|
NamedColor(std::string const & lyx, std::string const & gui,
|
|
|
|
RGBColor const & c)
|
|
|
|
: RGBColor(c), lyxname(lyx), guiname(gui) {}
|
2000-11-15 18:02:45 +00:00
|
|
|
RGBColor const & color() const { return *this; }
|
2000-11-10 17:29:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline
|
2000-11-13 10:35:02 +00:00
|
|
|
bool operator==(RGBColor const & c1, RGBColor const & c2)
|
2000-11-10 17:29:47 +00:00
|
|
|
{
|
|
|
|
return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
2000-11-13 10:35:02 +00:00
|
|
|
bool operator!=(RGBColor const & c1, RGBColor const & c2)
|
2000-11-10 17:29:47 +00:00
|
|
|
{
|
|
|
|
return !(c1 == c2);
|
|
|
|
}
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2000-11-10 17:29:47 +00:00
|
|
|
#endif
|