]> git.lyx.org Git - lyx.git/blob - src/LColor.h
fix math color inset UI and parsing
[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  * \class LColor
33  *
34  * A class holding color definitions and associated names for
35  * LaTeX, X11, the GUI, and LyX internally.
36  *
37  * A color can be one of the following kinds:
38  *
39  * - A real, predefined color, such as black, white, red or green.
40  * - A logical color, such as no color, inherit, math
41  */
42
43 class LColor
44 // made copyable for same reasons as LyXRC was made copyable. See there for
45 // explanation.
46 {
47 public:
48         /// Names of colors, including all logical colors
49         enum color {
50                 /// No particular color---clear or default
51                 none,
52                 /// The different text colors
53                 black,
54                 ///
55                 white,
56                 ///
57                 red,
58                 ///
59                 green,
60                 ///
61                 blue,
62                 ///
63                 cyan,
64                 ///
65                 magenta,
66                 ///
67                 yellow,
68
69                 // Needed interface colors
70
71                 /// Cursor color
72                 cursor,
73                 /// Background color
74                 background,
75                 /// Foreground color
76                 foreground,
77                 /// Background color of selected text
78                 selection,
79                 /// Text color in LaTeX mode
80                 latex,
81                 /// The color used for previews
82                 preview,
83
84                 /// Text color for notes
85                 note,
86                 /// Background color of notes
87                 notebg,
88                 /// Text color for comments
89                 comment,
90                 /// Background color of comments
91                 commentbg,
92                 /// Text color for greyedout inset
93                 greyedout,
94                 /// Background color of greyedout inset
95                 greyedoutbg,
96
97
98                 /// Color for the depth bars in the margin
99                 depthbar,
100                 /// Color for marking foreign language words
101                 language,
102
103                 /// Text color for command insets
104                 command,
105                 /// Background color for command insets
106                 commandbg,
107                 /// Frame color for command insets
108                 commandframe,
109
110                 /// Special chars text color
111                 special,
112
113                 /// Graphics inset background color
114                 graphicsbg,
115                 /// Math inset text color
116                 math,
117                 /// Math inset background color
118                 mathbg,
119                 /// Macro math inset background color
120                 mathmacrobg,
121                 /// Math inset frame color
122                 mathframe,
123                 /// Math line color
124                 mathline,
125
126                 /// caption frame color
127                 captionframe,
128
129                 /// collapsable insets text
130                 collapsable,
131                 /// collapsable insets frame
132                 collapsableframe,
133
134                 /// Inset marker background color
135                 insetbg,
136                 /// Inset marker frame color
137                 insetframe,
138
139                 /// Error box text color
140                 error,
141                 /// EOL marker color
142                 eolmarker,
143                 /// Added space colour
144                 added_space,
145                 /// Appendix marker color
146                 appendix,
147                 /// changebar color
148                 changebar,
149                 /// strike-out color
150                 strikeout,
151                 /// added text color
152                 newtext,
153                 /// Top and bottom line color
154                 topline,
155                 /// Table line color
156                 tabularline,
157                 /// Table line color
158                 tabularonoffline,
159                 /// Bottom area color
160                 bottomarea,
161                 /// Page break color
162                 pagebreak,
163
164                 // FIXME: why are the next four separate ??
165                 /// Color used for top of boxes
166                 top,
167                 /// Color used for bottom of boxes
168                 bottom,
169                 /// Color used for left side of boxes
170                 left,
171                 /// Color used for right side of boxes
172                 right,
173                 /// Color used for bottom background
174                 buttonbg,
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 #endif