]> git.lyx.org Git - lyx.git/blob - src/LColor.h
hopefully fix tex2lyx linking.
[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 top of boxes
170                 top,
171                 /// Color used for bottom of boxes
172                 bottom,
173                 /// Color used for left side of boxes
174                 left,
175                 /// Color used for right side of boxes
176                 right,
177                 /// Color used for bottom background
178                 buttonbg,
179
180                 // Logical attributes
181
182                 /// Color is inherited
183                 inherit,
184                 /// For ignoring updates of a color
185                 ignore
186         };
187
188
189         ///
190         LColor();
191         ///
192         LColor(LColor const &);
193         ///
194         ~LColor();
195         ///
196         LColor & operator=(LColor);
197
198         /** set the given LyX color to the color defined by the X11 name given
199          *  \returns true if successful.
200          */
201         bool setColor(LColor::color col, std::string const & x11name);
202
203         /** set the given LyX color to the color defined by the X11
204          *  name given \returns true if successful. A new color entry
205          *  is created if the color is unknown
206          */
207         bool setColor(std::string const & lyxname, std::string const & x11name);
208
209         /// Get the GUI name of \c color.
210         std::string const getGUIName(LColor::color c) const;
211
212         /// Get the X11 name of \c color.
213         std::string const getX11Name(LColor::color c) const;
214
215         /// Get the LaTeX name of \c color.
216         std::string const getLaTeXName(LColor::color c) const;
217
218         /// Get the LyX name of \c color.
219         std::string const getLyXName(LColor::color c) const;
220
221         /// \returns the LColor::color associated with the GUI name.
222         LColor::color getFromGUIName(std::string const & guiname) const;
223         /// \returns the LColor::color associated with the LyX name.
224         LColor::color getFromLyXName(std::string const & lyxname) const;
225         /// \returns the LColor::color associated with the LaTeX name.
226         LColor::color getFromLaTeXName(std::string const & latexname) const;
227 private:
228         ///
229         void addColor(LColor::color c, std::string const & lyxname) const;
230         ///
231         class Pimpl;
232         ///
233         boost::scoped_ptr<Pimpl> pimpl_;
234 };
235
236
237 /** \c LColor_color is a wrapper for LColor::color. It can be forward-declared and
238  *  passed as a function argument without having to expose LColor.h.
239  */
240 class LColor_color {
241         LColor::color val_;
242 public:
243         /** The default constructor is nasty,
244          *  but allows us to use LColor_color in STL containers.
245          */
246         LColor_color() : val_(static_cast<LColor::color>(-1)) {}
247
248         LColor_color(LColor::color val) : val_(val) {}
249         operator LColor::color() const{ return val_; }
250 };
251
252
253 /// the current color definitions
254 extern LColor lcolor;
255 /// the system color definitions
256 extern LColor system_lcolor;
257
258
259 } // namespace lyx
260
261 #endif