2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1998-2000 The LyX Team
9 *======================================================*/
14 #pragma implementation
21 #include "support/LAssert.h"
23 #include "support/lstrings.h"
26 void LColor::fill(LColor::color col, string const & gui,
27 string const & latex, string const & x11,
41 char const * latexname;
49 // LColor::color, gui, latex, x11, lyx
50 ColorEntry items[] = {
51 { none, N_("none"), "none", "black", "none" },
52 { black, N_("black"), "black", "black", "black" },
53 { white, N_("white"), "white", "white", "white" },
54 { red, N_("red"), "red", "red", "red" },
55 { green, N_("green"), "green", "green", "green" },
56 { blue, N_("blue"), "blue", "blue", "blue" },
57 { cyan, N_("cyan"), "cyan", "cyan", "cyan" },
58 { magenta, N_("magenta"), "magenta", "magenta", "magenta" },
59 { yellow, N_("yellow"), "yellow", "yellow", "yellow" },
60 { background, N_("background"), "background", "linen", "background" },
61 { foreground, N_("foreground"), "foreground", "black", "foreground" },
62 { selection, N_("selection"), "selection", "LightBlue", "selection" },
63 { latex, N_("latex"), "latex", "DarkRed", "latex" },
64 { floats, N_("floats"), "floats", "red", "floats" },
65 { note, N_("note"), "note", "black", "note" },
66 { notebg, N_("note background"), "notebg", "yellow", "notebg" },
67 { noteframe, N_("note frame"), "noteframe", "black", "noteframe" },
68 { depthbar, N_("depth bar"), "depthbar", "IndianRed", "depthbar" },
69 { command, N_("command-inset"), "command", "black", "command" },
70 { commandbg, N_("command-inset background"), "commandbg", "grey80", "commandbg" },
71 { commandframe, N_("inset frame"), "commandframe", "black", "commandframe" },
72 { accent, N_("accent"), "accent", "black", "accent" },
73 { accentbg, N_("accent background"), "accentbg", "offwhite", "accentbg" },
74 { accentframe, N_("accent frame"), "accentframe", "linen", "accentframe" },
75 { minipageline, N_("minipage line"), "minipageline", "violet", "minipageline" },
76 { special, N_("special char"), "special", "RoyalBlue", "special" },
77 { math, N_("math"), "math", "DarkBlue", "math" },
78 { mathbg, N_("math background"), "mathbg", "AntiqueWhite", "mathbg" },
79 { mathframe, N_("math frame"), "mathframe", "Magenta", "mathframe" },
80 { mathcursor, N_("math cursor"), "mathcursor", "black", "mathcursor" },
81 { mathline, N_("math line"), "mathline", "Blue", "mathline" },
82 { footnote, N_("footnote"), "footnote", "DarkRed", "footnote" },
83 { footnotebg, N_("footnote background"), "footnotebg", "grey60", "footnotebg" },
84 { footnoteframe, N_("footnote frame"), "footnoteframe", "IndianRed", "footnoteframe" },
85 { ert, N_("ert"), "ert", "DarkRed", "ert" },
86 { inset, N_("inset"), "inset", "black", "inset" },
87 { insetbg, N_("inset background"), "insetbg", "grey60", "insetbg" },
88 { insetframe, N_("inset frame"), "insetframe", "IndianRed", "insetframe" },
89 { error, N_("error"), "error", "Red", "error" },
90 { eolmarker, N_("end-of-line marker"), "eolmarker", "Brown", "eolmarker" },
91 { appendixline, N_("appendix line"), "appendixline", "Brown", "appendixline" },
92 { vfillline, N_("vfill line"), "vfillline", "Brown", "vfillline" },
93 { topline, N_("top/bottom line"), "topline", "Brown", "topline" },
94 { tableline, N_("table line"), "tableline", "black", "tableline" },
95 { tabularline, N_("tabular line"), "tabularline", "black",
97 { tabularonoffline, N_("tabularonoff line"), "tabularonoffline",
98 "LightSteelBlue", "tabularonoffline" },
99 { bottomarea, N_("bottom area"), "bottomarea", "grey40", "bottomarea" },
100 { pagebreak, N_("page break"), "pagebreak", "RoyalBlue", "pagebreak" },
101 { top, N_("top of button"), "top", "grey80", "top" },
102 { bottom, N_("bottom of button"), "bottom", "grey40", "bottom" },
103 { left, N_("left of button"), "left", "grey80", "left" },
104 { right, N_("right of button"), "right", "grey40", "right" },
105 { buttonbg, N_("button background"), "buttonbg", "grey60", "buttonbg" },
106 { inherit, N_("inherit"), "inherit", "black", "inherit" },
107 { ignore, N_("ignore"), "ignore", "black", "ignore" },
108 { ignore, 0, 0, 0, 0 }
112 while (items[i].guiname) {
113 fill(items[i].lcolor, items[i].guiname, items[i].latexname,
114 items[i].x11name, items[i].lyxname);
120 string LColor::getGUIName(LColor::color c) const
122 InfoTab::const_iterator ici = infotab.find(c);
123 if (ici != infotab.end())
124 return _((*ici).second.guiname.c_str());
130 string LColor::getX11Name(LColor::color c) const
132 InfoTab::const_iterator ici = infotab.find(c);
133 if (ici != infotab.end())
134 return (*ici).second.x11name;
136 lyxerr << "LyX internal error: Missing color"
137 " entry in LColor.C for " << int(c) << '\n';
138 lyxerr << "Using black.\n";
143 string LColor::getLaTeXName(LColor::color c) const
145 InfoTab::const_iterator ici = infotab.find(c);
146 if (ici != infotab.end())
147 return (*ici).second.latexname;
152 string LColor::getLyXName(LColor::color c) const
154 InfoTab::const_iterator ici = infotab.find(c);
155 if (ici != infotab.end())
156 return (*ici).second.lyxname;
161 void LColor::setColor(LColor::color col, string const & x11name)
163 InfoTab::iterator iti = infotab.find(col);
164 if (iti != infotab.end()) {
165 (*iti).second.x11name = x11name;
168 lyxerr << "LyX internal error: color and such.\n";
173 LColor::color LColor::getFromGUIName(string const & guiname) const
175 InfoTab::const_iterator ici = infotab.begin();
176 for (; ici != infotab.end(); ++ici) {
177 if (!compare_no_case((*ici).second.guiname, guiname))
180 return LColor::ignore;
184 LColor::color LColor::getFromLyXName(string const & lyxname) const
187 InfoTab::const_iterator ici = infotab.begin();
188 for (; ici != infotab.end(); ++ici) {
189 if (!compare_no_case((*ici).second.lyxname, lyxname))
192 return LColor::inherit;
195 // The evil global LColor instance