X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FColor.h;h=865f0ab8a8e6e25e61b7670e4301eebc6aca30b6;hb=28be7d552f62cc02fa86d7f79201d089bfb2d7b5;hp=2841dc5ba64864388d4c6f06b090f832d4538889;hpb=f1cba8ff64b369792fd49f5ddf90e8126ab476ac;p=lyx.git diff --git a/src/Color.h b/src/Color.h index 2841dc5ba6..865f0ab8a8 100644 --- a/src/Color.h +++ b/src/Color.h @@ -16,109 +16,55 @@ * Full author contact details are available in file CREDITS. */ -#ifndef LCOLOR_H -#define LCOLOR_H +#ifndef COLOR_H +#define COLOR_H #include "ColorCode.h" #include "support/strfwd.h" -#include -#include - namespace lyx { /** - * \class ColorSet + * \class Color * - * A class holding color definitions and associated names for - * LaTeX, X11, the GUI, and LyX internally. + * A class holding a definition of a certain color. * * 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 + * - a single color, then mergeColor = Color_ignore + * - a merged color, i.e. the average of the base and merge colors. */ - -// made copyable for same reasons as LyXRC was made copyable. See there for -// explanation. - -class ColorSet +class Color { public: /// - ColorSet(); - - /** set the given LyX color to the color defined by the X11 name given - * \returns true if successful. - */ - bool setColor(ColorCode col, std::string const & x11name); - - /** 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); - - /// Get the GUI name of \c color. - docstring const getGUIName(ColorCode c) const; - - /// Get the X11 name of \c color. - std::string const getX11Name(ColorCode c) const; - - /// 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: - /// - void addColor(ColorCode c, std::string const & lyxname); - /// - 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); - - /// - typedef std::map InfoTab; - /// the table of color Information - InfoTab infotab; - - typedef std::map 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; + Color(ColorCode base_color = Color_none); + + /// \name Comparison operators + //@{ + bool operator==(Color const & color) const; + bool operator!=(Color const & color) const; + bool operator<(Color const & color) const; + bool operator<=(Color const & color) const; + //@} + + /// the base color + ColorCode baseColor; + /// The color that is merged with the base color. Set + /// mergeColor to Color_ignore if no merging is wanted. + ColorCode mergeColor; }; - -/// the current color definitions -extern ColorSet lcolor; -/// the system color definitions -extern ColorSet system_lcolor; +std::ostream & operator<<(std::ostream & os, Color color); std::string const X11hexname(RGBColor const & col); RGBColor rgbFromHexName(std::string const & x11hexname); +std::string const outputLaTeXColor(RGBColor const & color); +/// Inverse of outputLaTeXColor +RGBColor const RGBColorFromLaTeX(std::string const & color); } // namespace lyx -#endif +#endif // COLOR_H