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/strfwd.h"
34 * A class holding a definition of a certain color.
36 * A color can be one of the following kinds:
38 * - a single color, then mergeColor = Color_ignore
39 * - a merged color, i.e. the average of the base and merge colors.
46 Color(ColorCode base_color = Color_none);
48 /// comparison operators.
50 bool operator==(Color const & color) const;
51 bool operator!=(Color const & color) const;
52 bool operator<(Color const & color) const;
53 bool operator<=(Color const & color) const;
58 /// The color that is merged with the base color. Set
59 /// mergeColor to Color_ignore if no merging is wanted.
63 std::ostream & operator<<(std::ostream & os, Color color);
69 * A class holding color definitions and associated names for
70 * LaTeX, X11, the GUI, and LyX internally.
72 * A color can be one of the following kinds:
74 * - A real, predefined color, such as black, white, red or green.
75 * - A logical color, such as no color, inherit, math
79 // made copyable for same reasons as LyXRC was made copyable. See there for
88 /** set the given LyX color to the color defined by the X11 name given
89 * \returns true if successful.
91 bool setColor(ColorCode col, std::string const & x11name);
93 /** set the given LyX color to the color defined by the X11
94 * name given \returns true if successful. A new color entry
95 * is created if the color is unknown
97 bool setColor(std::string const & lyxname, std::string const & x11name);
99 /// Get the GUI name of \c color.
100 docstring const getGUIName(ColorCode c) const;
102 /// Get the X11 name of \c color.
103 std::string const getX11Name(ColorCode c) const;
105 /// Get the LaTeX name of \c color.
106 std::string const getLaTeXName(ColorCode c) const;
108 /// Get the LyX name of \c color.
109 std::string const getLyXName(ColorCode c) const;
111 /// \returns the ColorCode associated with the LyX name.
112 ColorCode getFromLyXName(std::string const & lyxname) const;
113 /// \returns the ColorCode associated with the LaTeX name.
114 ColorCode getFromLaTeXName(std::string const & latexname) const;
118 void addColor(ColorCode c, std::string const & lyxname);
122 /// the name as it appears in the GUI
124 /// the name used in LaTeX
125 std::string latexname;
132 /// initialise a color entry
134 void fill(ColorEntry const & entry);
137 typedef std::map<ColorCode, Information> InfoTab;
138 /// the table of color Information
141 typedef std::map<std::string, ColorCode> Transform;
142 /// the transform between LyX color name string and integer code.
144 /// the transform between LaTeX color name string and integer code.
145 Transform latexcolors;
149 /// the current color definitions
150 extern ColorSet lcolor;
151 /// the system color definitions
152 extern ColorSet system_lcolor;
154 std::string const X11hexname(RGBColor const & col);
155 RGBColor rgbFromHexName(std::string const & x11hexname);