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