X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FColor.h;h=865f0ab8a8e6e25e61b7670e4301eebc6aca30b6;hb=22d52f5f08cba82c85019634420f4204da56ec6b;hp=ee3d88bf4292fcd215be8dc1525e2d7767f99cd3;hpb=399e6e788cee5fb7d4a916365a4ef60f30cfe654;p=lyx.git diff --git a/src/Color.h b/src/Color.h index ee3d88bf42..865f0ab8a8 100644 --- a/src/Color.h +++ b/src/Color.h @@ -4,71 +4,67 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * + * \author Asger Alstrup + * \author Lars Gullik Bjønnes + * \author Matthias Ettrich + * \author Jean-Marc Lasgouttes * \author Angus Leeming + * \author John Levon + * \author André Pönitz + * \author Martin Vermeer * * 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 +#include "ColorCode.h" + +#include "support/strfwd.h" namespace lyx { -struct RGBColor; -/// returns a string of form #rrggbb, given an RGBColor struct -std::string const X11hexname(RGBColor const & col); +/** + * \class Color + * + * A class holding a definition of a certain color. + * + * A color can be one of the following kinds: + * + * - a single color, then mergeColor = Color_ignore + * - a merged color, i.e. the average of the base and merge colors. + */ -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 &); -}; +class Color +{ +public: + /// + Color(ColorCode base_color = Color_none); -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); -}; + /// \name Comparison operators + //@{ + bool operator==(Color const & color) const; + bool operator!=(Color const & color) const; + bool operator<(Color const & color) const; + bool operator<=(Color const & color) 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; } + /// the base color + ColorCode baseColor; + /// The color that is merged with the base color. Set + /// mergeColor to Color_ignore if no merging is wanted. + ColorCode mergeColor; }; -inline -bool operator==(RGBColor const & c1, RGBColor const & c2) -{ - return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b); -} - +std::ostream & operator<<(std::ostream & os, Color color); -inline -bool operator!=(RGBColor const & c1, RGBColor const & c2) -{ - return !(c1 == c2); -} +std::string const X11hexname(RGBColor const & col); +RGBColor rgbFromHexName(std::string const & x11hexname); +std::string const outputLaTeXColor(RGBColor const & color); +/// Inverse of outputLaTeXColor +RGBColor const RGBColorFromLaTeX(std::string const & color); } // namespace lyx -#endif +#endif // COLOR_H