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