]> git.lyx.org Git - lyx.git/blob - src/LColor.h
more cleanup:
[lyx.git] / src / LColor.h
1 // -*- C++ -*-
2 /**
3  * \file LColor.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
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
15  *
16  * Full author contact details are available in file CREDITS.
17  */
18
19 #ifndef LCOLOR_H
20 #define LCOLOR_H
21
22 #include <boost/scoped_ptr.hpp>
23 #include <string>
24
25
26 namespace lyx {
27
28 /**
29  * This is a stateless class.
30  *
31  * It has one basic purposes:
32  * To serve as a color-namespace container (the Color enum).
33  */
34 /**
35  * \class LColor
36  *
37  * A class holding color definitions and associated names for
38  * LaTeX, X11, the GUI, and LyX internally.
39  *
40  * A color can be one of the following kinds:
41  *
42  * - A real, predefined color, such as black, white, red or green.
43  * - A logical color, such as no color, inherit, math
44  */
45
46 class LColor
47 // made copyable for same reasons as LyXRC was made copyable. See there for
48 // explanation.
49 {
50 public:
51         /// Names of colors, including all logical colors
52         enum color {
53                 /// No particular color---clear or default
54                 none,
55                 /// The different text colors
56                 black,
57                 ///
58                 white,
59                 ///
60                 red,
61                 ///
62                 green,
63                 ///
64                 blue,
65                 ///
66                 cyan,
67                 ///
68                 magenta,
69                 ///
70                 yellow,
71
72                 // Needed interface colors
73
74                 /// Cursor color
75                 cursor,
76                 /// Background color
77                 background,
78                 /// Foreground color
79                 foreground,
80                 /// Background color of selected text
81                 selection,
82                 /// Text color in LaTeX mode
83                 latex,
84                 /// The color used for previews
85                 preview,
86
87                 /// Text color for notes
88                 note,
89                 /// Background color of notes
90                 notebg,
91                 /// Text color for comments
92                 comment,
93                 /// Background color of comments
94                 commentbg,
95                 /// Text color for greyedout inset
96                 greyedout,
97                 /// Background color of greyedout inset
98                 greyedoutbg,
99                 /// Shaded box background
100                 shadedbg,
101
102                 /// Color for the depth bars in the margin
103                 depthbar,
104                 /// Color for marking foreign language words
105                 language,
106
107                 /// Text color for command insets
108                 command,
109                 /// Background color for command insets
110                 commandbg,
111                 /// Frame color for command insets
112                 commandframe,
113
114                 /// Special chars text color
115                 special,
116
117                 /// Graphics inset background color
118                 graphicsbg,
119                 /// Math inset text color
120                 math,
121                 /// Math inset background color
122                 mathbg,
123                 /// Macro math inset background color
124                 mathmacrobg,
125                 /// Math inset frame color
126                 mathframe,
127                 /// Math line color
128                 mathline,
129
130                 /// caption frame color
131                 captionframe,
132
133                 /// collapsable insets text
134                 collapsable,
135                 /// collapsable insets frame
136                 collapsableframe,
137
138                 /// Inset marker background color
139                 insetbg,
140                 /// Inset marker frame color
141                 insetframe,
142
143                 /// Error box text color
144                 error,
145                 /// EOL marker color
146                 eolmarker,
147                 /// Added space colour
148                 added_space,
149                 /// Appendix marker color
150                 appendix,
151                 /// changebar color
152                 changebar,
153                 /// strike-out color
154                 strikeout,
155                 /// added text color
156                 newtext,
157                 /// Top and bottom line color
158                 topline,
159                 /// Table line color
160                 tabularline,
161                 /// Table line color
162                 tabularonoffline,
163                 /// Bottom area color
164                 bottomarea,
165                 /// Page break color
166                 pagebreak,
167
168                 // FIXME: why are the next four separate ??
169                 /// Color used for button frame
170                 buttonframe,
171                 /// Color used for bottom background
172                 buttonbg,
173                 /// Color used for buttom under focus
174                 buttonhoverbg,
175
176                 // Logical attributes
177
178                 /// Color is inherited
179                 inherit,
180                 /// For ignoring updates of a color
181                 ignore
182         };
183
184
185         ///
186         LColor();
187         ///
188         LColor(LColor const &);
189         ///
190         ~LColor();
191         ///
192         LColor & operator=(LColor);
193
194         /** set the given LyX color to the color defined by the X11 name given
195          *  \returns true if successful.
196          */
197         bool setColor(LColor::color col, std::string const & x11name);
198
199         /** set the given LyX color to the color defined by the X11
200          *  name given \returns true if successful. A new color entry
201          *  is created if the color is unknown
202          */
203         bool setColor(std::string const & lyxname, std::string const & x11name);
204
205         /// Get the GUI name of \c color.
206         std::string const getGUIName(LColor::color c) const;
207
208         /// Get the X11 name of \c color.
209         std::string const getX11Name(LColor::color c) const;
210
211         /// Get the LaTeX name of \c color.
212         std::string const getLaTeXName(LColor::color c) const;
213
214         /// Get the LyX name of \c color.
215         std::string const getLyXName(LColor::color c) const;
216
217         /// \returns the LColor::color associated with the GUI name.
218         LColor::color getFromGUIName(std::string const & guiname) const;
219         /// \returns the LColor::color associated with the LyX name.
220         LColor::color getFromLyXName(std::string const & lyxname) const;
221         /// \returns the LColor::color associated with the LaTeX name.
222         LColor::color getFromLaTeXName(std::string const & latexname) const;
223 private:
224         ///
225         void addColor(LColor::color c, std::string const & lyxname) const;
226         ///
227         class Pimpl;
228         ///
229         boost::scoped_ptr<Pimpl> pimpl_;
230 };
231
232
233 /** \c LColor_color is a wrapper for LColor::color. It can be forward-declared and
234  *  passed as a function argument without having to expose LColor.h.
235  */
236 class LColor_color {
237         LColor::color val_;
238 public:
239         /** The default constructor is nasty,
240          *  but allows us to use LColor_color in STL containers.
241          */
242         LColor_color() : val_(static_cast<LColor::color>(-1)) {}
243
244         LColor_color(LColor::color val) : val_(val) {}
245         operator LColor::color() const{ return val_; }
246 };
247
248
249 /// the current color definitions
250 extern LColor lcolor;
251 /// the system color definitions
252 extern LColor system_lcolor;
253
254
255 } // namespace lyx
256
257 #endif