]> Dogcows Code - chaz/openbox/blob - otk/rendercolor.hh
6000646acd94c3bf6f703bf7f255f819109bcc4f
[chaz/openbox] / otk / rendercolor.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __rendercolor_hh
3 #define __rendercolor_hh
4
5 extern "C" {
6 #include <X11/Xlib.h>
7 }
8
9 #include <map>
10
11 namespace otk {
12
13 class RenderColor {
14 struct RGB {
15 int r;
16 int g;
17 int b;
18 RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
19 // color is in ARGB format
20 RGB(unsigned long color)
21 : r((color >> 16) & 0xff),
22 g((color >> 8) & 0xff),
23 b((color) & 0xff) {}
24 };
25
26 struct CacheItem {
27 GC gc;
28 int count;
29 CacheItem(GC g) : gc(g), count(0) {}
30 };
31 static std::map<unsigned long, CacheItem*> *_cache;
32
33 int _screen;
34 unsigned char _red;
35 unsigned char _green;
36 unsigned char _blue;
37
38 GC _gc;
39
40 void create();
41
42 public:
43 static void initialize();
44 static void destroy();
45
46 RenderColor(int screen, unsigned char red,
47 unsigned char green, unsigned char blue);
48 RenderColor(int screen, RGB rgb);
49 virtual ~RenderColor();
50
51 inline int screen() const { return _screen; }
52 inline unsigned char red() const { return _red; }
53 inline unsigned char green() const { return _green; }
54 inline unsigned char blue() const { return _blue; }
55 inline GC gc() const { return _gc; }
56 };
57
58 }
59
60 #endif // __rendercolor_hh
This page took 0.035181 seconds and 4 git commands to generate.