]> git.lyx.org Git - lyx.git/blob - src/LColor.C
some sun compile fixes the need clipboard code patch from Dekel ans some other fixes
[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(depthbar, _("depth bar"), "depthbar", "IndianRed", "depthbar");
60         fill(command, _("command-inset"), "command", "black", "command");
61         fill(commandbg, _("command-inset background"), "commandbg", "grey80", "commandbg");
62         fill(commandframe, _("inset frame"), "commandframe", "black", "commandframe");
63         fill(accent, _("accent"), "accent", "black", "accent");
64         fill(accentbg, _("accent background"), "accentbg", "offwhite", "accentbg");
65         fill(accentframe, _("accent frame"), "accentframe", "linen", "accentframe");
66         fill(minipageline, _("minipage line"), "minipageline", "violet", "minipageline");
67         fill(special, _("special char"), "special", "RoyalBlue", "special");
68         fill(math, _("math"), "math", "DarkBlue", "math");
69         fill(mathbg, _("math background"), "mathbg", "AntiqueWhite", "mathbg");
70         fill(mathframe, _("math frame"), "mathframe", "Magenta", "mathframe");
71         fill(mathcursor, _("math cursor"), "mathcursor", "black", "mathcursor");
72         fill(mathline, _("math line"), "mathline", "Blue", "mathline");
73         fill(footnote, _("footnote"), "footnote", "DarkRed", "footnote");
74         fill(footnotebg, _("footnote background"), "footnotebg", "grey40", "footnotebg");
75         fill(footnoteframe, _("footnote frame"), "footnoteframe", "IndianRed", "footnoteframe");
76         fill(ert, _("ert"), "ert", "DarkRed", "ert");
77         fill(inset, _("inset"), "inset", "black", "inset");
78         fill(insetbg, _("inset background"), "insetbg", "grey40", "insetbg");
79         fill(insetframe, _("inset frame"), "insetframe", "IndianRed", "insetframe");
80         fill(error, _("error"), "error", "Red", "error");
81         fill(eolmarker, _("end-of-line marker"), "eolmarker", "Brown", "eolmarker");
82         fill(appendixline, _("appendix line"), "appendixline", "Brown", "appendixline");
83         fill(vfillline, _("vfill line"), "vfillline", "Brown", "vfillline");
84         fill(topline, _("top/bottom line"), "topline", "Brown", "topline");
85         fill(tableline, _("table line"), "tableline", "black", "tableline");
86         fill(tabularline, _("tabular line"), "tabularline", "black",
87              "tabularline");
88         fill(tabularonoffline, _("tabularonoff line"), "tabularonoffline",
89              "LightSteelBlue", "tabularonoffline");
90         fill(bottomarea, _("bottom area"), "bottomarea", "grey40", "bottomarea");
91         fill(pagebreak, _("page break"), "pagebreak", "RoyalBlue", "pagebreak");
92         fill(top, _("top of button"), "top", "grey80", "top");
93         fill(bottom, _("bottom of button"), "bottom", "grey40", "bottom");
94         fill(left, _("left of button"), "left", "grey80", "left");
95         fill(right, _("right of button"), "right", "grey40", "right");
96         fill(buttonbg, _("button background"), "buttonbg", "grey60", "buttonbg");
97         fill(inherit, _("inherit"), "inherit", "black", "inherit");
98         fill(ignore, _("ignore"), "ignore", "black", "ignore");
99 }
100
101
102 string LColor::getGUIName(LColor::color c) const
103 {
104         InfoTab::const_iterator ici = infotab.find(c);
105         if (ici != infotab.end())
106                 return (*ici).second.guiname;
107
108         return "none";
109 }
110
111
112 string LColor::getX11Name(LColor::color c) const
113 {
114         InfoTab::const_iterator ici = infotab.find(c);
115         if (ici != infotab.end()) 
116                 return (*ici).second.x11name;
117
118         lyxerr << "LyX internal error: Missing color"
119                 " entry in LColor.C for " << int(c) << '\n';
120         lyxerr << "Using black.\n";
121         return "black";
122 }
123
124
125 string LColor::getLaTeXName(LColor::color c) const
126 {
127         InfoTab::const_iterator ici = infotab.find(c);
128         if (ici != infotab.end())
129                 return (*ici).second.latexname;
130         return "black";
131 }
132
133
134 string LColor::getLyXName(LColor::color c) const
135 {
136         InfoTab::const_iterator ici = infotab.find(c);
137         if (ici != infotab.end())
138                 return (*ici).second.lyxname;
139         return "black";
140 }
141
142
143 void LColor::setColor(LColor::color col, string const & x11name)
144 {
145         InfoTab::iterator iti = infotab.find(col);
146         if (iti != infotab.end()) {
147                 (*iti).second.x11name = x11name;
148                 return;
149         }
150         lyxerr << "LyX internal error: color and such.\n";
151         Assert(false);
152 }
153
154
155 LColor::color LColor::getFromGUIName(string const & guiname) const
156 {
157         InfoTab::const_iterator ici = infotab.begin();
158         for (; ici != infotab.end(); ++ici) {
159                 if (!compare_no_case((*ici).second.guiname, guiname))
160                         return (*ici).first;
161         }
162         return LColor::ignore;
163 }
164
165
166 LColor::color LColor::getFromLyXName(string const & lyxname) const
167 {
168         
169         InfoTab::const_iterator ici = infotab.begin();
170         for (; ici != infotab.end(); ++ici) {
171                 if (!compare_no_case((*ici).second.lyxname, lyxname))
172                         return (*ici).first;
173         }
174         return LColor::inherit;
175 }
176
177 // The evil global LColor instance
178 LColor lcolor;