X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FColor.h;h=0f0a0934a356c633f0c754b4e3a4f1ca3ad07ebe;hb=d145c2dc9f27666ca0ed9f8589f99f502d7b2a4d;hp=05e670806ef6ea587d69b8b0aca33e542591aba1;hpb=eea79637c78bb9916031924eca7b305cfb8e83df;p=lyx.git diff --git a/src/Color.h b/src/Color.h index 05e670806e..0f0a0934a3 100644 --- a/src/Color.h +++ b/src/Color.h @@ -21,21 +21,15 @@ #include "ColorCode.h" -#include "support/docstring.h" - -#include +#include "support/strfwd.h" +#include +#include namespace lyx { /** - * This is a stateless class. - * - * It has one basic purposes: - * To serve as a color-namespace container (the Color enum). - */ -/** - * \class Color + * \class ColorSet * * A class holding color definitions and associated names for * LaTeX, X11, the GUI, and LyX internally. @@ -46,19 +40,15 @@ namespace lyx { * - A logical color, such as no color, inherit, math */ -class Color + // made copyable for same reasons as LyXRC was made copyable. See there for // explanation. + +class ColorSet { public: /// - Color(); - /// - Color(Color const &); - /// - ~Color(); - /// - Color & operator=(Color); + ColorSet(); /** set the given LyX color to the color defined by the X11 name given * \returns true if successful. @@ -87,48 +77,47 @@ public: 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) const; + void addColor(ColorCode c, std::string const & lyxname); /// - class Pimpl; + 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); + /// - boost::scoped_ptr pimpl_; + 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; }; /// the current color definitions -extern Color lcolor; +extern ColorSet lcolor; /// the system color definitions -extern Color system_lcolor; - - -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); -} +extern ColorSet system_lcolor; -/// returns a string of form #rrggbb, given an RGBColor struct std::string const X11hexname(RGBColor const & col); +RGBColor rgbFromHexName(std::string const & x11hexname); } // namespace lyx