2000-02-10 17:53:36 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1998-2000 The LyX Team
|
|
|
|
*
|
|
|
|
*======================================================*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
#include "LColor.h"
|
|
|
|
#include "support/LAssert.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
|
|
|
|
|
|
void LColor::fill(LColor::color col, string const & gui,
|
|
|
|
string const & latex, string const & x11,
|
|
|
|
string const & lyx) {
|
|
|
|
information in;
|
|
|
|
in.guiname = gui;
|
|
|
|
in.latexname = latex;
|
|
|
|
in.x11name = x11;
|
|
|
|
in.lyxname = lyx;
|
|
|
|
|
|
|
|
infotab[col] = in;
|
|
|
|
}
|
|
|
|
|
2000-05-25 03:37:32 +00:00
|
|
|
struct ColorEntry {
|
|
|
|
LColor::color lcolor;
|
|
|
|
char const * guiname;
|
|
|
|
char const * latexname;
|
|
|
|
char const * x11name;
|
|
|
|
char const * lyxname;
|
|
|
|
};
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
|
|
LColor::LColor()
|
|
|
|
{
|
|
|
|
// LColor::color, gui, latex, x11, lyx
|
2000-05-25 03:37:32 +00:00
|
|
|
ColorEntry items[] = {
|
|
|
|
{ none, N_("none"), "none", "black", "none" },
|
|
|
|
{ black, N_("black"), "black", "black", "black" },
|
|
|
|
{ white, N_("white"), "white", "white", "white" },
|
|
|
|
{ red, N_("red"), "red", "red", "red" },
|
|
|
|
{ green, N_("green"), "green", "green", "green" },
|
|
|
|
{ blue, N_("blue"), "blue", "blue", "blue" },
|
|
|
|
{ cyan, N_("cyan"), "cyan", "cyan", "cyan" },
|
|
|
|
{ magenta, N_("magenta"), "magenta", "magenta", "magenta" },
|
|
|
|
{ yellow, N_("yellow"), "yellow", "yellow", "yellow" },
|
|
|
|
{ background, N_("background"), "background", "linen", "background" },
|
|
|
|
{ foreground, N_("foreground"), "foreground", "black", "foreground" },
|
|
|
|
{ selection, N_("selection"), "selection", "LightBlue", "selection" },
|
|
|
|
{ latex, N_("latex"), "latex", "DarkRed", "latex" },
|
|
|
|
{ floats, N_("floats"), "floats", "red", "floats" },
|
|
|
|
{ note, N_("note"), "note", "black", "note" },
|
|
|
|
{ notebg, N_("note background"), "notebg", "yellow", "notebg" },
|
|
|
|
{ noteframe, N_("note frame"), "noteframe", "black", "noteframe" },
|
|
|
|
{ depthbar, N_("depth bar"), "depthbar", "IndianRed", "depthbar" },
|
2000-05-30 19:31:11 +00:00
|
|
|
{ language, N_("language"), "language", "Blue", "language" },
|
2000-05-25 03:37:32 +00:00
|
|
|
{ command, N_("command-inset"), "command", "black", "command" },
|
|
|
|
{ commandbg, N_("command-inset background"), "commandbg", "grey80", "commandbg" },
|
|
|
|
{ commandframe, N_("inset frame"), "commandframe", "black", "commandframe" },
|
|
|
|
{ accent, N_("accent"), "accent", "black", "accent" },
|
|
|
|
{ accentbg, N_("accent background"), "accentbg", "offwhite", "accentbg" },
|
|
|
|
{ accentframe, N_("accent frame"), "accentframe", "linen", "accentframe" },
|
|
|
|
{ minipageline, N_("minipage line"), "minipageline", "violet", "minipageline" },
|
|
|
|
{ special, N_("special char"), "special", "RoyalBlue", "special" },
|
|
|
|
{ math, N_("math"), "math", "DarkBlue", "math" },
|
|
|
|
{ mathbg, N_("math background"), "mathbg", "AntiqueWhite", "mathbg" },
|
|
|
|
{ mathframe, N_("math frame"), "mathframe", "Magenta", "mathframe" },
|
|
|
|
{ mathcursor, N_("math cursor"), "mathcursor", "black", "mathcursor" },
|
|
|
|
{ mathline, N_("math line"), "mathline", "Blue", "mathline" },
|
|
|
|
{ footnote, N_("footnote"), "footnote", "DarkRed", "footnote" },
|
|
|
|
{ footnotebg, N_("footnote background"), "footnotebg", "grey60", "footnotebg" },
|
|
|
|
{ footnoteframe, N_("footnote frame"), "footnoteframe", "IndianRed", "footnoteframe" },
|
|
|
|
{ ert, N_("ert"), "ert", "DarkRed", "ert" },
|
|
|
|
{ inset, N_("inset"), "inset", "black", "inset" },
|
|
|
|
{ insetbg, N_("inset background"), "insetbg", "grey60", "insetbg" },
|
|
|
|
{ insetframe, N_("inset frame"), "insetframe", "IndianRed", "insetframe" },
|
|
|
|
{ error, N_("error"), "error", "Red", "error" },
|
|
|
|
{ eolmarker, N_("end-of-line marker"), "eolmarker", "Brown", "eolmarker" },
|
|
|
|
{ appendixline, N_("appendix line"), "appendixline", "Brown", "appendixline" },
|
|
|
|
{ vfillline, N_("vfill line"), "vfillline", "Brown", "vfillline" },
|
|
|
|
{ topline, N_("top/bottom line"), "topline", "Brown", "topline" },
|
|
|
|
{ tableline, N_("table line"), "tableline", "black", "tableline" },
|
|
|
|
{ tabularline, N_("tabular line"), "tabularline", "black",
|
|
|
|
"tabularline" },
|
|
|
|
{ tabularonoffline, N_("tabularonoff line"), "tabularonoffline",
|
|
|
|
"LightSteelBlue", "tabularonoffline" },
|
|
|
|
{ bottomarea, N_("bottom area"), "bottomarea", "grey40", "bottomarea" },
|
|
|
|
{ pagebreak, N_("page break"), "pagebreak", "RoyalBlue", "pagebreak" },
|
|
|
|
{ top, N_("top of button"), "top", "grey80", "top" },
|
|
|
|
{ bottom, N_("bottom of button"), "bottom", "grey40", "bottom" },
|
|
|
|
{ left, N_("left of button"), "left", "grey80", "left" },
|
|
|
|
{ right, N_("right of button"), "right", "grey40", "right" },
|
|
|
|
{ buttonbg, N_("button background"), "buttonbg", "grey60", "buttonbg" },
|
|
|
|
{ inherit, N_("inherit"), "inherit", "black", "inherit" },
|
|
|
|
{ ignore, N_("ignore"), "ignore", "black", "ignore" },
|
|
|
|
{ ignore, 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
while (items[i].guiname) {
|
|
|
|
fill(items[i].lcolor, items[i].guiname, items[i].latexname,
|
|
|
|
items[i].x11name, items[i].lyxname);
|
|
|
|
++i;
|
|
|
|
}
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string LColor::getGUIName(LColor::color c) const
|
|
|
|
{
|
|
|
|
InfoTab::const_iterator ici = infotab.find(c);
|
|
|
|
if (ici != infotab.end())
|
2000-05-25 03:37:32 +00:00
|
|
|
return _((*ici).second.guiname.c_str());
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
|
|
return "none";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string LColor::getX11Name(LColor::color c) const
|
|
|
|
{
|
|
|
|
InfoTab::const_iterator ici = infotab.find(c);
|
|
|
|
if (ici != infotab.end())
|
|
|
|
return (*ici).second.x11name;
|
|
|
|
|
|
|
|
lyxerr << "LyX internal error: Missing color"
|
|
|
|
" entry in LColor.C for " << int(c) << '\n';
|
|
|
|
lyxerr << "Using black.\n";
|
|
|
|
return "black";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string LColor::getLaTeXName(LColor::color c) const
|
|
|
|
{
|
|
|
|
InfoTab::const_iterator ici = infotab.find(c);
|
|
|
|
if (ici != infotab.end())
|
|
|
|
return (*ici).second.latexname;
|
|
|
|
return "black";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string LColor::getLyXName(LColor::color c) const
|
|
|
|
{
|
|
|
|
InfoTab::const_iterator ici = infotab.find(c);
|
|
|
|
if (ici != infotab.end())
|
|
|
|
return (*ici).second.lyxname;
|
|
|
|
return "black";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LColor::setColor(LColor::color col, string const & x11name)
|
|
|
|
{
|
|
|
|
InfoTab::iterator iti = infotab.find(col);
|
|
|
|
if (iti != infotab.end()) {
|
|
|
|
(*iti).second.x11name = x11name;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
lyxerr << "LyX internal error: color and such.\n";
|
|
|
|
Assert(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LColor::color LColor::getFromGUIName(string const & guiname) const
|
|
|
|
{
|
|
|
|
InfoTab::const_iterator ici = infotab.begin();
|
|
|
|
for (; ici != infotab.end(); ++ici) {
|
|
|
|
if (!compare_no_case((*ici).second.guiname, guiname))
|
|
|
|
return (*ici).first;
|
|
|
|
}
|
|
|
|
return LColor::ignore;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LColor::color LColor::getFromLyXName(string const & lyxname) const
|
|
|
|
{
|
2000-05-20 21:37:05 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
InfoTab::const_iterator ici = infotab.begin();
|
|
|
|
for (; ici != infotab.end(); ++ici) {
|
|
|
|
if (!compare_no_case((*ici).second.lyxname, lyxname))
|
|
|
|
return (*ici).first;
|
|
|
|
}
|
2000-05-20 21:37:05 +00:00
|
|
|
return LColor::inherit;
|
2000-02-10 17:53:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The evil global LColor instance
|
|
|
|
LColor lcolor;
|