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 "support/docstring.h"
24 #include <boost/scoped_ptr.hpp>
30 * This is a stateless class.
32 * It has one basic purposes:
33 * To serve as a color-namespace container (the Color enum).
38 * A class holding color definitions and associated names for
39 * LaTeX, X11, the GUI, and LyX internally.
41 * A color can be one of the following kinds:
43 * - A real, predefined color, such as black, white, red or green.
44 * - A logical color, such as no color, inherit, math
48 // made copyable for same reasons as LyXRC was made copyable. See there for
52 /// Names of colors, including all logical colors
54 /// No particular color---clear or default
56 /// The different text colors
73 // Needed interface colors
81 /// Background color of selected text
83 /// Text color in LaTeX mode
85 /// The color used for previews
88 /// Text color for notes
90 /// Background color of notes
92 /// Text color for comments
94 /// Background color of comments
96 /// Text color for greyedout inset
98 /// Background color of greyedout inset
100 /// Shaded box background
103 /// Color for the depth bars in the margin
105 /// Color for marking foreign language words
108 /// Text color for command insets
110 /// Background color for command insets
112 /// Frame color for command insets
115 /// Special chars text color
118 /// Graphics inset background color
120 /// Math inset text color
122 /// Math inset background color
124 /// Macro math inset background color
126 /// Math inset frame color
131 /// caption frame color
134 /// collapsable insets text
136 /// collapsable insets frame
139 /// Inset marker background color
141 /// Inset marker frame color
144 /// Error box text color
148 /// Added space colour
150 /// Appendix marker color
158 /// Top and bottom line color
164 /// Bottom area color
169 // FIXME: why are the next four separate ??
170 /// Color used for button frame
172 /// Color used for bottom background
174 /// Color used for buttom under focus
177 // Logical attributes
179 /// Color is inherited
181 /// For ignoring updates of a color
189 Color(Color const &);
193 Color & operator=(Color);
195 /** set the given LyX color to the color defined by the X11 name given
196 * \returns true if successful.
198 bool setColor(Color::color col, std::string const & x11name);
200 /** set the given LyX color to the color defined by the X11
201 * name given \returns true if successful. A new color entry
202 * is created if the color is unknown
204 bool setColor(std::string const & lyxname, std::string const & x11name);
206 /// Get the GUI name of \c color.
207 docstring const getGUIName(Color::color c) const;
209 /// Get the X11 name of \c color.
210 std::string const getX11Name(Color::color c) const;
212 /// Get the LaTeX name of \c color.
213 std::string const getLaTeXName(Color::color c) const;
215 /// Get the LyX name of \c color.
216 std::string const getLyXName(Color::color c) const;
218 /// \returns the Color::color associated with the LyX name.
219 Color::color getFromLyXName(std::string const & lyxname) const;
220 /// \returns the Color::color associated with the LaTeX name.
221 Color::color getFromLaTeXName(std::string const & latexname) const;
224 void addColor(Color::color c, std::string const & lyxname) const;
228 boost::scoped_ptr<Pimpl> pimpl_;
232 /** \c Color_color is a wrapper for Color::color. It can be forward-declared and
233 * passed as a function argument without having to expose Color.h.
238 /** The default constructor is nasty,
239 * but allows us to use Color_color in STL containers.
241 Color_color() : val_(static_cast<Color::color>(-1)) {}
243 Color_color(Color::color val) : val_(val) {}
244 operator Color::color() const{ return val_; }
248 /// the current color definitions
250 /// the system color definitions
251 extern Color system_lcolor;
255 /// returns a string of form #rrggbb, given an RGBColor struct
256 std::string const X11hexname(RGBColor const & col);
262 HSVColor() : h(0.0), s(0.0), v(0.0) {}
263 HSVColor(double hue, double sat, double val)
264 : h(hue), s(sat), v(val) {}
265 HSVColor(RGBColor const &);
272 RGBColor() : r(0), g(0), b(0) {}
273 RGBColor(unsigned int red, unsigned int green, unsigned int blue)
274 : r(red), g(green), b(blue) {}
275 RGBColor(HSVColor const &);
276 /// \param x11hexname is of the form "#ffa071"
277 RGBColor(std::string const & x11hexname);
280 struct NamedColor : public RGBColor {
283 NamedColor() : RGBColor() {}
284 NamedColor(std::string const & lyx, std::string const & gui,
286 : RGBColor(c), lyxname(lyx), guiname(gui) {}
287 RGBColor const & color() const { return *this; }
291 bool operator==(RGBColor const & c1, RGBColor const & c2)
293 return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
298 bool operator!=(RGBColor const & c1, RGBColor const & c2)