4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Asger Alstrup
8 * \author Lars Gullik Bjønnes
9 * \author Matthias Ettrich
10 * \author Jean-Marc Lasgouttes
11 * \author Angus Leeming
13 * \author André Pönitz
14 * \author Martin Vermeer
16 * Full author contact details are available in file CREDITS.
22 #include "ColorCode.h"
24 #include "support/docstring.h"
26 #include <boost/scoped_ptr.hpp>
32 * This is a stateless class.
34 * It has one basic purposes:
35 * To serve as a color-namespace container (the Color enum).
40 * A class holding color definitions and associated names for
41 * LaTeX, X11, the GUI, and LyX internally.
43 * A color can be one of the following kinds:
45 * - A real, predefined color, such as black, white, red or green.
46 * - A logical color, such as no color, inherit, math
50 // made copyable for same reasons as LyXRC was made copyable. See there for
61 Color & operator=(Color);
63 /** set the given LyX color to the color defined by the X11 name given
64 * \returns true if successful.
66 bool setColor(ColorCode col, std::string const & x11name);
68 /** set the given LyX color to the color defined by the X11
69 * name given \returns true if successful. A new color entry
70 * is created if the color is unknown
72 bool setColor(std::string const & lyxname, std::string const & x11name);
74 /// Get the GUI name of \c color.
75 docstring const getGUIName(ColorCode c) const;
77 /// Get the X11 name of \c color.
78 std::string const getX11Name(ColorCode c) const;
80 /// Get the LaTeX name of \c color.
81 std::string const getLaTeXName(ColorCode c) const;
83 /// Get the LyX name of \c color.
84 std::string const getLyXName(ColorCode c) const;
86 /// \returns the ColorCode associated with the LyX name.
87 ColorCode getFromLyXName(std::string const & lyxname) const;
88 /// \returns the ColorCode associated with the LaTeX name.
89 ColorCode getFromLaTeXName(std::string const & latexname) const;
92 void addColor(ColorCode c, std::string const & lyxname) const;
96 boost::scoped_ptr<Pimpl> pimpl_;
100 /// the current color definitions
102 /// the system color definitions
103 extern Color system_lcolor;
110 RGBColor() : r(0), g(0), b(0) {}
111 RGBColor(unsigned int red, unsigned int green, unsigned int blue)
112 : r(red), g(green), b(blue) {}
113 /// \param x11hexname is of the form "#ffa071"
114 RGBColor(std::string const & x11hexname);
118 bool operator==(RGBColor const & c1, RGBColor const & c2)
120 return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
125 bool operator!=(RGBColor const & c1, RGBColor const & c2)
130 /// returns a string of form #rrggbb, given an RGBColor struct
131 std::string const X11hexname(RGBColor const & col);