2000-02-10 17:53:36 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
2007-04-26 17:34:20 +00:00
|
|
|
|
* \file Color.h
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Asger Alstrup
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Matthias Ettrich
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \author Martin Vermeer
|
2000-02-10 17:53:36 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
|
|
|
|
#ifndef LCOLOR_H
|
|
|
|
|
#define LCOLOR_H
|
|
|
|
|
|
2007-10-25 12:41:02 +00:00
|
|
|
|
#include "ColorCode.h"
|
|
|
|
|
|
2007-10-31 22:40:34 +00:00
|
|
|
|
#include "support/strfwd.h"
|
2006-12-21 14:31:19 +00:00
|
|
|
|
|
2007-11-02 23:42:27 +00:00
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
|
/**
|
2007-11-02 23:42:27 +00:00
|
|
|
|
* \class ColorSet
|
2001-05-23 13:12:58 +00:00
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2007-11-02 23:42:27 +00:00
|
|
|
|
|
2000-11-15 18:02:45 +00:00
|
|
|
|
// made copyable for same reasons as LyXRC was made copyable. See there for
|
|
|
|
|
// explanation.
|
2007-11-02 23:42:27 +00:00
|
|
|
|
|
|
|
|
|
class ColorSet
|
2000-11-15 18:02:45 +00:00
|
|
|
|
{
|
2000-02-10 17:53:36 +00:00
|
|
|
|
public:
|
|
|
|
|
///
|
2007-11-02 23:42:27 +00:00
|
|
|
|
ColorSet();
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
2003-12-14 16:33:56 +00:00
|
|
|
|
/** set the given LyX color to the color defined by the X11 name given
|
|
|
|
|
* \returns true if successful.
|
|
|
|
|
*/
|
2007-10-25 12:41:02 +00:00
|
|
|
|
bool setColor(ColorCode col, std::string const & x11name);
|
2003-12-14 16:33:56 +00:00
|
|
|
|
|
2004-03-25 15:51:21 +00:00
|
|
|
|
/** set the given LyX color to the color defined by the X11
|
|
|
|
|
* name given \returns true if successful. A new color entry
|
|
|
|
|
* is created if the color is unknown
|
|
|
|
|
*/
|
|
|
|
|
bool setColor(std::string const & lyxname, std::string const & x11name);
|
|
|
|
|
|
2003-12-14 16:33:56 +00:00
|
|
|
|
/// Get the GUI name of \c color.
|
2007-10-25 12:41:02 +00:00
|
|
|
|
docstring const getGUIName(ColorCode c) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-12-14 16:33:56 +00:00
|
|
|
|
/// Get the X11 name of \c color.
|
2007-10-25 12:41:02 +00:00
|
|
|
|
std::string const getX11Name(ColorCode c) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-12-14 16:33:56 +00:00
|
|
|
|
/// Get the LaTeX name of \c color.
|
2007-10-25 12:41:02 +00:00
|
|
|
|
std::string const getLaTeXName(ColorCode c) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-12-14 16:33:56 +00:00
|
|
|
|
/// Get the LyX name of \c color.
|
2007-10-25 12:41:02 +00:00
|
|
|
|
std::string const getLyXName(ColorCode c) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2007-10-25 12:41:02 +00:00
|
|
|
|
/// \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;
|
2007-11-02 23:42:27 +00:00
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
|
private:
|
2003-12-14 16:33:56 +00:00
|
|
|
|
///
|
2007-11-02 23:42:27 +00:00
|
|
|
|
void addColor(ColorCode c, std::string const & lyxname);
|
2000-02-10 17:53:36 +00:00
|
|
|
|
///
|
2007-11-02 23:42:27 +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
|
|
|
|
|
std::string x11name;
|
|
|
|
|
/// the name for LyX
|
|
|
|
|
std::string lyxname;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// initialise a color entry
|
|
|
|
|
struct ColorEntry;
|
|
|
|
|
void fill(ColorEntry const & entry);
|
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
|
///
|
2007-11-02 23:42:27 +00:00
|
|
|
|
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;
|
2000-02-10 17:53:36 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-09-15 15:20:22 +00:00
|
|
|
|
|
2001-05-23 13:12:58 +00:00
|
|
|
|
/// the current color definitions
|
2007-11-02 23:42:27 +00:00
|
|
|
|
extern ColorSet lcolor;
|
2001-05-23 13:12:58 +00:00
|
|
|
|
/// the system color definitions
|
2007-11-02 23:42:27 +00:00
|
|
|
|
extern ColorSet system_lcolor;
|
2007-04-26 19:21:38 +00:00
|
|
|
|
|
2007-08-12 11:08:51 +00:00
|
|
|
|
std::string const X11hexname(RGBColor const & col);
|
2007-11-02 23:42:27 +00:00
|
|
|
|
RGBColor rgbFromHexName(std::string const & x11hexname);
|
2007-08-12 11:08:51 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
|
#endif
|