]> git.lyx.org Git - lyx.git/blob - src/LColor.h
Qt2 compilation + LColor cleanup from John
[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 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include <map>
19
20 #include "LString.h"
21 #include <boost/utility.hpp>
22
23 /**
24   This is a stateless class. 
25
26   It has one basic purposes:
27   To serve as a color-namespace container (the Color enum).
28   
29
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 // : public boost::noncopyable {
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
82                 /// Text color for notes
83                 note,
84                 /// Background color of notes
85                 notebg,
86                 /// Frame color for notes
87                 noteframe,
88
89
90                 /// Color for the depth bars in the margin
91                 depthbar,
92                 /// Color for marking foreign language words
93                 language,
94
95                 /// Text color for command insets
96                 command,
97                 /// Background color for command insets
98                 commandbg,
99                 /// Frame color for command insets
100                 commandframe,
101
102                 /// Special chars text color
103                 special,
104
105                 /// Math inset text color
106                 math,
107                 /// Math inset background color
108                 mathbg,
109                 /// Math inset frame color
110                 mathframe,
111                 /// Math cursor color
112                 mathcursor,
113                 /// Math line color
114                 mathline,
115
116                 /// caption frame color
117                 captionframe,
118  
119                 /// collapsable insets text
120                 collapsable,
121                 /// collapsable insets frame
122                 collapsableframe,
123
124                 /// Inset marker background color
125                 insetbg,
126                 /// Inset marker frame color
127                 insetframe,
128
129                 /// Error box text color
130                 error,
131                 /// EOL marker color
132                 eolmarker,
133                 /// Appendix line color
134                 appendixline,
135                 /// VFill line color
136                 vfillline,
137                 /// Top and bottom line color
138                 topline,
139                 /// Table line color
140                 tabularline,
141                 /// Table line color
142                 tabularonoffline,
143                 /// Bottom area color
144                 bottomarea,
145                 /// Page break color
146                 pagebreak,
147
148                 // FIXME: why are the next four separate ??
149                 /// Color used for top of boxes
150                 top,
151                 /// Color used for bottom of boxes
152                 bottom,
153                 /// Color used for left side of boxes
154                 left,
155                 /// Color used for right side of boxes
156                 right,
157                 /// Color used for bottom background
158                 buttonbg,
159
160                 // Logical attributes
161
162                 /// Color is inherited
163                 inherit,
164                 /// For ignoring updates of a color
165                 ignore
166         };
167
168         ///
169         LColor();
170         /// set the given LyX color to the color defined by the X11 name given
171         void setColor(LColor::color col, string const & x11name);
172         /// set the given LyX color to the color defined by the X11 name given
173         bool setColor(string const & lyxname, string const & x11name);
174  
175         /// Get GUI name of color
176         string const getGUIName(LColor::color c) const;
177  
178         /// Get X11 name of color
179         string const getX11Name(LColor::color c) const;
180  
181         /// Get LaTeX name of color
182         string const getLaTeXName(LColor::color c) const;
183  
184         /// Get LyX name of color
185         string const getLyXName(LColor::color c) const;
186  
187         /// get the color from the GUI name
188         LColor::color getFromGUIName(string const & guiname) const;
189         /// get the color from the LyX name
190         LColor::color getFromLyXName(string const & lyxname) const;
191 private:
192         ///
193         struct information {
194                 /// the name as it appears in the GUI
195                 string guiname;
196                 /// the name used in LaTeX
197                 string latexname;
198                 /// the name for X11
199                 string x11name;
200                 /// the name for LyX
201                 string lyxname;
202         };
203
204         /// initialise a color entry
205         void fill(LColor::color col, string const & gui,
206                   string const & latex, string const & x11,
207                   string const & lyx);
208
209         ///
210         typedef std::map<LColor::color, information> InfoTab;
211         /// the table of color information
212         InfoTab infotab;
213 };
214
215 /// the current color definitions
216 extern LColor lcolor;
217 /// the system color definitions
218 extern LColor system_lcolor;
219
220 #endif