* qt_helpers.cpp:
[lyx.git] / src / ColorSet.h
blob6ee8f401055d3b243ee705531055dead1a4b513b
1 // -*- C++ -*-
2 /**
3 * \file ColorSet.h
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
12 * \author John Levon
13 * \author André Pönitz
14 * \author Martin Vermeer
16 * Full author contact details are available in file CREDITS.
19 #ifndef COLORSET_H
20 #define COLORSET_H
22 #include "Color.h"
24 #include <map>
25 #include <string>
27 namespace lyx {
29 /**
30 * \class ColorSet
32 * A class holding color definitions and associated names for
33 * LaTeX, X11, the GUI, and LyX internally.
35 * A color can be one of the following kinds:
37 * - A real, predefined color, such as black, white, red or green.
38 * - A logical color, such as no color, inherit, math
42 // made copyable for same reasons as LyXRC was made copyable. See there for
43 // explanation.
45 class ColorSet
47 public:
48 ///
49 ColorSet();
51 /** set the given LyX color to the color defined by the X11 name given
52 * \returns true if successful.
54 bool setColor(ColorCode col, std::string const & x11name);
56 /** set the given LyX color to the color defined by the X11
57 * name given \returns true if successful. A new color entry
58 * is created if the color is unknown
60 bool setColor(std::string const & lyxname, std::string const & x11name);
62 /// Get the GUI name of \c color.
63 docstring const getGUIName(ColorCode c) const;
65 /// Get the X11 name of \c color.
66 std::string const getX11Name(ColorCode c) const;
68 /// Get the LaTeX name of \c color.
69 std::string const getLaTeXName(ColorCode c) const;
71 /// Get the LyX name of \c color.
72 std::string const getLyXName(ColorCode c) const;
74 /// \returns the ColorCode associated with the LyX name.
75 ColorCode getFromLyXName(std::string const & lyxname) const;
76 /// \returns the ColorCode associated with the LaTeX name.
77 ColorCode getFromLaTeXName(std::string const & latexname) const;
79 private:
80 ///
81 void addColor(ColorCode c, std::string const & lyxname);
82 ///
83 class Information {
84 public:
85 /// the name as it appears in the GUI
86 std::string guiname;
87 /// the name used in LaTeX
88 std::string latexname;
89 /// the name for X11
90 std::string x11name;
91 /// the name for LyX
92 std::string lyxname;
95 /// initialise a color entry
96 struct ColorEntry;
97 void fill(ColorEntry const & entry);
99 ///
100 typedef std::map<ColorCode, Information> InfoTab;
101 /// the table of color Information
102 InfoTab infotab;
104 typedef std::map<std::string, ColorCode> Transform;
105 /// the transform between LyX color name string and integer code.
106 Transform lyxcolors;
107 /// the transform between LaTeX color name string and integer code.
108 Transform latexcolors;
112 /// the current color definitions
113 extern ColorSet lcolor;
114 /// the system color definitions
115 extern ColorSet system_lcolor;
117 } // namespace lyx
119 #endif // COLORSET_H