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 // 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");
97 string LColor::getGUIName(LColor::color c) const
99 InfoTab::const_iterator ici = infotab.find(c);
100 if (ici != infotab.end())
101 return (*ici).second.guiname;
107 string LColor::getX11Name(LColor::color c) const
109 InfoTab::const_iterator ici = infotab.find(c);
110 if (ici != infotab.end())
111 return (*ici).second.x11name;
113 lyxerr << "LyX internal error: Missing color"
114 " entry in LColor.C for " << int(c) << '\n';
115 lyxerr << "Using black.\n";
120 string LColor::getLaTeXName(LColor::color c) const
122 InfoTab::const_iterator ici = infotab.find(c);
123 if (ici != infotab.end())
124 return (*ici).second.latexname;
129 string LColor::getLyXName(LColor::color c) const
131 InfoTab::const_iterator ici = infotab.find(c);
132 if (ici != infotab.end())
133 return (*ici).second.lyxname;
138 void LColor::setColor(LColor::color col, string const & x11name)
140 InfoTab::iterator iti = infotab.find(col);
141 if (iti != infotab.end()) {
142 (*iti).second.x11name = x11name;
145 lyxerr << "LyX internal error: color and such.\n";
150 LColor::color LColor::getFromGUIName(string const & guiname) const
152 InfoTab::const_iterator ici = infotab.begin();
153 for (; ici != infotab.end(); ++ici) {
154 if (!compare_no_case((*ici).second.guiname, guiname))
157 return LColor::ignore;
161 LColor::color LColor::getFromLyXName(string const & lyxname) const
163 InfoTab::const_iterator ici = infotab.begin();
164 for (; ici != infotab.end(); ++ici) {
165 if (!compare_no_case((*ici).second.lyxname, lyxname))
168 return LColor::ignore;
171 // The evil global LColor instance