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