1 #ifndef WM_COLORS_H
2 #define WM_COLORS_H
3 
4 #define SLICE(_int, _bit) (((_int) >> (_bit)) & 0xff)
5 
6 class Color {
7   unsigned char _R, _G, _B;
8 
9  public:
10   Color(unsigned long int li = 0)
11     : _R(SLICE(li, 16)), _G(SLICE(li, 8)), _B(SLICE(li, 0)) { }
Color(int R,int G,int B)12   Color(int R, int G, int B) : _R(R), _G(G), _B(B) { }
13 
14   bool operator ==   (const Color & c) const
15     { return _R == c._R && _G == c._G && _B == c._B; }
16   bool operator !=   (const Color & c) const
17     { return ! operator==(c); }
18 
r()19   unsigned char r() const { return _R; }
g()20   unsigned char g() const { return _G; }
b()21   unsigned char b() const { return _B; }
22 
alpha_blend(const Color & c1,const Color & c2,double weight1)23   static Color alpha_blend(const Color & c1, const Color & c2, double weight1)
24   {
25     double weight2 = 1.0 - weight1;
26     int r = static_cast<int>(c1.r() * weight1 + c2.r() * weight2 + 0.5);
27     int g = static_cast<int>(c1.g() * weight1 + c2.g() * weight2 + 0.5);
28     int b = static_cast<int>(c1.b() * weight1 + c2.b() * weight2 + 0.5);
29     return Color(r, g, b);
30   }
31 };
32 
33 #undef SLICE
34 
35 #define WMColor(x) (WMApp::colormap[static_cast<int>(WMColor:: x)])
36 
37 namespace WMColor {
38   enum WMColor {
39     Background, // Background of WMFrames and WMImages
40     Dim,	// Dark drawing color
41     Medium,	// Medium drawing color
42     Bright,	// Light drawing color
43     ButtonFace,	// Color of face of buttons
44     ButtonBorderDim,	// Colors of borders of WMButtons
45     ButtonBorderMedium,
46     ButtonBorderBright,
47     FrameBorderDim,	// Colors of borders of WMFrames
48     FrameBorderMedium,
49     FrameBorderBright
50   };
51   const int numcolors = 11;
52 }
53 
54 #endif
55