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
|
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
|
/**
|
2004-10-05 10:11:42 +00:00
|
|
|
|
* This is a stateless class.
|
|
|
|
|
*
|
|
|
|
|
* It has one basic purposes:
|
|
|
|
|
* To serve as a color-namespace container (the Color enum).
|
|
|
|
|
*/
|
2001-05-23 13:12:58 +00:00
|
|
|
|
/**
|
2007-04-26 17:34:20 +00:00
|
|
|
|
* \class Color
|
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-04-26 17:34:20 +00:00
|
|
|
|
class Color
|
2000-11-15 18:02:45 +00:00
|
|
|
|
// made copyable for same reasons as LyXRC was made copyable. See there for
|
|
|
|
|
// explanation.
|
|
|
|
|
{
|
2000-02-10 17:53:36 +00:00
|
|
|
|
public:
|
|
|
|
|
///
|
2007-04-26 17:34:20 +00:00
|
|
|
|
Color();
|
2003-05-09 09:43:39 +00:00
|
|
|
|
///
|
2007-04-26 17:34:20 +00:00
|
|
|
|
Color(Color const &);
|
2003-05-09 09:43:39 +00:00
|
|
|
|
///
|
2007-04-26 17:34:20 +00:00
|
|
|
|
~Color();
|
2003-05-09 09:43:39 +00:00
|
|
|
|
///
|
2007-04-26 17:34:20 +00:00
|
|
|
|
Color & operator=(Color);
|
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;
|
2000-02-10 17:53:36 +00:00
|
|
|
|
private:
|
2003-12-14 16:33:56 +00:00
|
|
|
|
///
|
2007-10-25 12:41:02 +00:00
|
|
|
|
void addColor(ColorCode c, std::string const & lyxname) const;
|
2000-02-10 17:53:36 +00:00
|
|
|
|
///
|
2005-01-19 15:03:31 +00:00
|
|
|
|
class Pimpl;
|
2000-02-10 17:53:36 +00:00
|
|
|
|
///
|
2003-08-17 11:28:23 +00:00
|
|
|
|
boost::scoped_ptr<Pimpl> pimpl_;
|
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-04-26 17:34:20 +00:00
|
|
|
|
extern Color lcolor;
|
2001-05-23 13:12:58 +00:00
|
|
|
|
/// the system color definitions
|
2007-04-26 17:34:20 +00:00
|
|
|
|
extern Color system_lcolor;
|
2000-02-10 17:53:36 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
2007-04-26 19:21:38 +00:00
|
|
|
|
struct RGBColor {
|
|
|
|
|
unsigned int r;
|
|
|
|
|
unsigned int g;
|
|
|
|
|
unsigned int b;
|
|
|
|
|
RGBColor() : r(0), g(0), b(0) {}
|
|
|
|
|
RGBColor(unsigned int red, unsigned int green, unsigned int blue)
|
|
|
|
|
: r(red), g(green), b(blue) {}
|
|
|
|
|
/// \param x11hexname is of the form "#ffa071"
|
|
|
|
|
RGBColor(std::string const & x11hexname);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
bool operator==(RGBColor const & c1, RGBColor const & c2)
|
|
|
|
|
{
|
|
|
|
|
return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
bool operator!=(RGBColor const & c1, RGBColor const & c2)
|
|
|
|
|
{
|
|
|
|
|
return !(c1 == c2);
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-12 11:08:51 +00:00
|
|
|
|
/// returns a string of form #rrggbb, given an RGBColor struct
|
|
|
|
|
std::string const X11hexname(RGBColor const & col);
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
|
#endif
|