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