]> git.lyx.org Git - lyx.git/blob - src/LColor.C
9d64bf612256d2a032f64d9b18f874000c2d1a00
[lyx.git] / src / LColor.C
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 1998-2000 The LyX Team
8  *
9  *======================================================*/
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include <X11/Xlib.h>
18
19 #include "debug.h"
20 #include "LColor.h"
21 #include "support/LAssert.h"
22 #include "gettext.h"
23 #include "support/lstrings.h"
24
25
26 void LColor::fill(LColor::color col, string const & gui,
27                   string const & latex, string const & x11,
28                   string const & lyx) {
29         information in;
30         in.guiname = gui;
31         in.latexname = latex;
32         in.x11name = x11;
33         in.lyxname = lyx;
34
35         infotab[col] = in;
36 }
37
38
39 LColor::LColor()
40 {
41         //  LColor::color, gui, latex, x11, lyx
42         fill(none, _("none"), "none", "black", "none");
43         fill(black, _("black"), "black", "black", "black");
44         fill(white, _("white"), "white", "white", "white");
45         fill(red, _("red"), "red", "red", "red");
46         fill(green, _("green"), "green", "green", "green");
47         fill(blue, _("blue"), "blue", "blue", "blue");
48         fill(cyan, _("cyan"), "cyan", "cyan", "cyan");
49         fill(magenta, _("magenta"), "magenta", "magenta", "magenta");
50         fill(yellow, _("yellow"), "yellow", "yellow", "yellow");
51         fill(background, _("background"), "background", "linen", "background");
52         fill(foreground, _("foreground"), "foreground", "black", "foreground");
53         fill(selection, _("selection"), "selection", "LightBlue", "selection");
54         fill(latex, _("latex"), "latex", "DarkRed", "latex");
55         fill(floats, _("floats"), "floats", "red", "floats");
56         fill(note, _("note"), "note", "black", "note");
57         fill(notebg, _("note background"), "notebg", "yellow", "notebg");
58         fill(noteframe, _("note frame"), "noteframe", "black", "noteframe");
59         fill(command, _("command-inset"), "command", "black", "command");
60         fill(commandbg, _("command-inset background"), "commandbg", "grey80", "commandbg");
61         fill(commandframe, _("inset frame"), "commandframe", "black", "commandframe");
62         fill(accent, _("accent"), "accent", "black", "accent");
63         fill(accentbg, _("accent background"), "accentbg", "offwhite", "accentbg");
64         fill(accentframe, _("accent frame"), "accentframe", "linen", "accentframe");
65         fill(minipageline, _("minipage line"), "minipageline", "violet", "minipageline");
66         fill(special, _("special char"), "special", "RoyalBlue", "special");
67         fill(math, _("math"), "math", "DarkBlue", "math");
68         fill(mathbg, _("math background"), "mathbg", "AntiqueWhite", "mathbg");
69         fill(mathframe, _("math frame"), "mathframe", "Magenta", "mathframe");
70         fill(mathcursor, _("math cursor"), "mathcursor", "black", "mathcursor");
71         fill(mathline, _("math line"), "mathline", "Blue", "mathline");
72         fill(footnote, _("footnote"), "footnote", "DarkRed", "footnote");
73         fill(footnotebg, _("footnote background"), "footnotebg", "grey40", "footnotebg");
74         fill(footnoteframe, _("footnote frame"), "footnoteframe", "IndianRed", "footnoteframe");
75         fill(ert, _("ert"), "ert", "DarkRed", "ert");
76         fill(inset, _("inset"), "inset", "black", "inset");
77         fill(insetbg, _("inset background"), "insetbg", "grey40", "insetbg");
78         fill(insetframe, _("inset frame"), "insetframe", "IndianRed", "insetframe");
79         fill(error, _("error"), "error", "Red", "error");
80         fill(eolmarker, _("end-of-line marker"), "eolmarker", "Brown", "eolmarker");
81         fill(appendixline, _("appendix line"), "appendixline", "Brown", "appendixline");
82         fill(vfillline, _("vfill line"), "vfillline", "Brown", "vfillline");
83         fill(topline, _("top/bottom line"), "topline", "Brown", "topline");
84         fill(tableline, _("table line"), "tableline", "black", "tableline");
85         fill(bottomarea, _("bottom area"), "bottomarea", "grey40", "bottomarea");
86         fill(pagebreak, _("page break"), "pagebreak", "RoyalBlue", "pagebreak");
87         fill(top, _("top of button"), "top", "grey80", "top");
88         fill(bottom, _("bottom of button"), "bottom", "grey40", "bottom");
89         fill(left, _("left of button"), "left", "grey80", "left");
90         fill(right, _("right of button"), "right", "grey40", "right");
91         fill(buttonbg, _("button background"), "buttonbg", "grey60", "buttonbg");
92         fill(inherit, _("inherit"), "inherit", "black", "inherit");
93         fill(ignore, _("ignore"), "ignore", "black", "ignore");
94 }
95
96
97 string LColor::getGUIName(LColor::color c) const
98 {
99         InfoTab::const_iterator ici = infotab.find(c);
100         if (ici != infotab.end())
101                 return (*ici).second.guiname;
102
103         return "none";
104 }
105
106
107 string LColor::getX11Name(LColor::color c) const
108 {
109         InfoTab::const_iterator ici = infotab.find(c);
110         if (ici != infotab.end()) 
111                 return (*ici).second.x11name;
112
113         lyxerr << "LyX internal error: Missing color"
114                 " entry in LColor.C for " << int(c) << '\n';
115         lyxerr << "Using black.\n";
116         return "black";
117 }
118
119
120 string LColor::getLaTeXName(LColor::color c) const
121 {
122         InfoTab::const_iterator ici = infotab.find(c);
123         if (ici != infotab.end())
124                 return (*ici).second.latexname;
125         return "black";
126 }
127
128
129 string LColor::getLyXName(LColor::color c) const
130 {
131         InfoTab::const_iterator ici = infotab.find(c);
132         if (ici != infotab.end())
133                 return (*ici).second.lyxname;
134         return "black";
135 }
136
137
138 void LColor::setColor(LColor::color col, string const & x11name)
139 {
140         InfoTab::iterator iti = infotab.find(col);
141         if (iti != infotab.end()) {
142                 (*iti).second.x11name = x11name;
143                 return;
144         }
145         lyxerr << "LyX internal error: color and such.\n";
146         Assert(false);
147 }
148
149
150 LColor::color LColor::getFromGUIName(string const & guiname) const
151 {
152         InfoTab::const_iterator ici = infotab.begin();
153         for (; ici != infotab.end(); ++ici) {
154                 if (!compare_no_case((*ici).second.guiname, guiname))
155                         return (*ici).first;
156         }
157         return LColor::ignore;
158 }
159
160
161 LColor::color LColor::getFromLyXName(string const & lyxname) const
162 {
163         InfoTab::const_iterator ici = infotab.begin();
164         for (; ici != infotab.end(); ++ici) {
165                 if (!compare_no_case((*ici).second.lyxname, lyxname))
166                         return (*ici).first;
167         }
168         return LColor::ignore;
169 }
170
171 // The evil global LColor instance
172 LColor lcolor;