25#include <koffice_export.h>
26class KOPAINTER_EXPORT KoColor
29 enum cSpace{ csIndexed, csRGB, csHSV, csCMYK, csLab };
32 KoColor( int a, int b, int c, cSpace m = csRGB);
33 KoColor( int c, int m, int y, int k);
34 KoColor( const TQString &name);
35 KoColor( const TQColor &c);
37 cSpace native() const { return mNative; }
53 void rgb( int *R, int *G, int *B) const;
54 void hsv( int *H, int *S, int *V) const;
55 void lab( int *L, int *a, int *b) const;
56 void cmyk( int *C, int *M, int *Y, int *K) const;
57 TQString name() const;
58 TQColor color() const;
60 void setRGB( int R, int G, int B);
61 void setHSV( int H, int S, int V);
62 void setLab( int L, int a, int b);
63 void setCMYK( int C, int M, int Y, int K);
64 void setNamedColor( const TQString &name);
65 void setColor( const TQColor &c);
67 static void RGBtoHSV( int R, int G, int B, int *H, int *S, int *V);
68 static void RGBtoLAB( int R, int G, int B, int *L, int *a, int *b);
69 static void RGBtoCMYK( int R, int G, int B, int *C, int *M, int *Y, int *K);
71 static void HSVtoRGB( int H, int S, int V, int *R, int *G, int *B);
72 static void HSVtoLAB( int H, int S, int V, int *L, int *a, int *b);
73 static void HSVtoCMYK( int H, int S, int V, int *C, int *M, int *Y, int*K);
75 static void LABtoRGB( int L, int a, int b, int *R, int *G, int *B);
76 static void LABtoHSV( int L, int a, int b, int *H, int *S, int *V);
77 static void LABtoCMYK( int L, int a, int b, int *C, int *M, int *Y, int*K);
79 static void CMYKtoRGB( int C, int M, int Y, int K, int *R, int *G, int *B);
80 static void CMYKtoHSV( int C, int M, int Y, int K, int *H, int *S, int *V);
81 static void CMYKtoLAB( int C, int M, int Y, int K, int *L, int *a, int *b);
83 static const KoColor black();
84 static const KoColor white();
85 static const KoColor gray();
86 static const KoColor lightGray();
87 static const KoColor darkGray();
88 static const KoColor red();
89 static const KoColor darkRed();
90 static const KoColor green();
91 static const KoColor darkGreen();
92 static const KoColor blue();
93 static const KoColor darkBlue();
94 static const KoColor cyan();
95 static const KoColor darkCyan();
96 static const KoColor magenta();
97 static const KoColor darkMagenta();
98 static const KoColor yellow();
99 static const KoColor darkYellow();
102 int hex2int(TQChar c);
104 void calcRGB() const;
105 void calcHSV() const;
106 void calcCMYK() const;
107 void calcLAB() const;
109 void rgbChanged() const;
110 void hsvChanged() const;
111 void cmykChanged() const;
112 void labChanged() const;
119 mutable int mR, mG, mB;
120 mutable int mC, mM, mY, mK;
121 mutable int mH, mS, mV;
122 mutable int mL, ma, mb;
124 mutable bool mRGBvalid;
125 mutable bool mHSVvalid;
126 mutable bool mCMYKvalid;
127 mutable bool mLABvalid;
132inline const KoColor KoColor::white()
134 return KoColor(255, 255, 255, csRGB);
137inline const KoColor KoColor::black()
139 return KoColor(0, 0, 0, csRGB);
142inline const KoColor KoColor::gray()
144 return KoColor(160, 160, 164, csRGB);
147inline const KoColor KoColor::lightGray()
149 return KoColor(192, 192, 192, csRGB);
152inline const KoColor KoColor::darkGray()
154 return KoColor(128, 128, 128, csRGB);
157inline const KoColor KoColor::red()
159 return KoColor(255, 0, 0, csRGB);
162inline const KoColor KoColor::darkRed()
164 return KoColor(128, 0, 0, csRGB);
167inline const KoColor KoColor::green()
169 return KoColor(0, 255, 0, csRGB);
172inline const KoColor KoColor::darkGreen()
174 return KoColor(0, 128, 0, csRGB);
177inline const KoColor KoColor::blue()
179 return KoColor(0, 0, 255, csRGB);
182inline const KoColor KoColor::darkBlue()
184 return KoColor(0, 0, 128, csRGB);
187inline const KoColor KoColor::cyan()
189 return KoColor(0, 255, 255, csRGB);
192inline const KoColor KoColor::darkCyan()
194 return KoColor(0, 128, 128, csRGB);
197inline const KoColor KoColor::magenta()
199 return KoColor(255, 0, 255, csRGB);
202inline const KoColor KoColor::darkMagenta()
204 return KoColor(128, 0, 128, csRGB);
207inline const KoColor KoColor::yellow()
209 return KoColor(255, 255, 0, csRGB);
212inline const KoColor KoColor::darkYellow()
214 return KoColor(128, 128, 0, csRGB);
const char * name(StdAction id)
|