2009-02-09 23:30:24 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file ColorSet.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Asger Alstrup
|
|
|
|
* \author Lars Gullik Bjønnes
|
|
|
|
* \author Matthias Ettrich
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
* \author Angus Leeming
|
|
|
|
* \author John Levon
|
|
|
|
* \author André Pönitz
|
|
|
|
* \author Martin Vermeer
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef COLORSET_H
|
|
|
|
#define COLORSET_H
|
|
|
|
|
|
|
|
#include "Color.h"
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \class ColorSet
|
|
|
|
*
|
|
|
|
* A class holding color definitions and associated names for
|
|
|
|
* LaTeX, X11, the GUI, and LyX internally.
|
|
|
|
*
|
|
|
|
* A color can be one of the following kinds:
|
|
|
|
*
|
|
|
|
* - A real, predefined color, such as black, white, red or green.
|
|
|
|
* - A logical color, such as no color, inherit, math
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// made copyable for same reasons as LyXRC was made copyable. See there for
|
|
|
|
// explanation.
|
|
|
|
|
|
|
|
class ColorSet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
ColorSet();
|
|
|
|
|
2020-08-03 12:10:46 +00:00
|
|
|
/** set the given LyX color to the color defined by the X11 hex name given
|
2009-02-09 23:30:24 +00:00
|
|
|
* \returns true if successful.
|
|
|
|
*/
|
2020-08-03 12:10:46 +00:00
|
|
|
bool setColor(ColorCode col, std::string const & x11hexname);
|
2009-02-09 23:30:24 +00:00
|
|
|
|
|
|
|
/** set the given LyX color to the color defined by the X11
|
2020-08-03 12:10:46 +00:00
|
|
|
* hex name given \returns true if successful. A new color entry
|
2009-02-09 23:30:24 +00:00
|
|
|
* is created if the color is unknown
|
|
|
|
*/
|
2020-08-03 12:10:46 +00:00
|
|
|
bool setColor(std::string const & lyxname, std::string const & x11hexname);
|
2009-02-09 23:30:24 +00:00
|
|
|
|
|
|
|
/// Get the GUI name of \c color.
|
|
|
|
docstring const getGUIName(ColorCode c) const;
|
|
|
|
|
2020-08-03 12:10:46 +00:00
|
|
|
/// Get the X11 hexname of \c color.
|
|
|
|
std::string const getX11HexName(ColorCode c) const;
|
2009-02-09 23:30:24 +00:00
|
|
|
|
|
|
|
/// Get the LaTeX name of \c color.
|
|
|
|
std::string const getLaTeXName(ColorCode c) const;
|
|
|
|
|
|
|
|
/// Get the LyX name of \c color.
|
|
|
|
std::string const getLyXName(ColorCode c) const;
|
|
|
|
|
|
|
|
/// \returns the ColorCode associated with the LyX name.
|
|
|
|
ColorCode getFromLyXName(std::string const & lyxname) const;
|
|
|
|
/// \returns the ColorCode associated with the LaTeX name.
|
|
|
|
ColorCode getFromLaTeXName(std::string const & latexname) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
2017-07-03 17:45:58 +00:00
|
|
|
void addColor(ColorCode c, std::string const & lyxname);
|
2009-02-09 23:30:24 +00:00
|
|
|
///
|
|
|
|
class Information {
|
|
|
|
public:
|
|
|
|
/// the name as it appears in the GUI
|
|
|
|
std::string guiname;
|
|
|
|
/// the name used in LaTeX
|
|
|
|
std::string latexname;
|
|
|
|
/// the name for X11
|
2020-08-03 12:10:46 +00:00
|
|
|
std::string x11hexname;
|
2009-02-09 23:30:24 +00:00
|
|
|
/// the name for LyX
|
|
|
|
std::string lyxname;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// initialise a color entry
|
|
|
|
struct ColorEntry;
|
|
|
|
void fill(ColorEntry const & entry);
|
|
|
|
|
|
|
|
///
|
|
|
|
typedef std::map<ColorCode, Information> InfoTab;
|
|
|
|
/// the table of color Information
|
|
|
|
InfoTab infotab;
|
|
|
|
|
|
|
|
typedef std::map<std::string, ColorCode> Transform;
|
|
|
|
/// the transform between LyX color name string and integer code.
|
|
|
|
Transform lyxcolors;
|
|
|
|
/// the transform between LaTeX color name string and integer code.
|
|
|
|
Transform latexcolors;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// the current color definitions
|
|
|
|
extern ColorSet lcolor;
|
|
|
|
/// the system color definitions
|
|
|
|
extern ColorSet system_lcolor;
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
|
|
#endif // COLORSET_H
|