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