diff options
Diffstat (limited to 'src/FbTk/Color.hh')
-rw-r--r-- | src/FbTk/Color.hh | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/FbTk/Color.hh b/src/FbTk/Color.hh new file mode 100644 index 0000000..f9c1600 --- /dev/null +++ b/src/FbTk/Color.hh | |||
@@ -0,0 +1,75 @@ | |||
1 | // Color.hh for Fluxbox Window Manager | ||
2 | // Copyright (c) 2002 Henrik Kinnunen (fluxgen@users.sourceforge.net) | ||
3 | // | ||
4 | // from Image.hh for Blackbox - an X11 Window manager | ||
5 | // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) | ||
6 | // | ||
7 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
8 | // copy of this software and associated documentation files (the "Software"), | ||
9 | // to deal in the Software without restriction, including without limitation | ||
10 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
11 | // and/or sell copies of the Software, and to permit persons to whom the | ||
12 | // Software is furnished to do so, subject to the following conditions: | ||
13 | // | ||
14 | // The above copyright notice and this permission notice shall be included in | ||
15 | // all copies or substantial portions of the Software. | ||
16 | // | ||
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
20 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
23 | // DEALINGS IN THE SOFTWARE. | ||
24 | |||
25 | // $Id: Color.hh,v 1.4 2003/05/10 13:29:13 fluxgen Exp $ | ||
26 | |||
27 | #ifndef FBTK_COLOR_HH | ||
28 | #define FBTK_COLOR_HH | ||
29 | |||
30 | #include "NotCopyable.hh" | ||
31 | |||
32 | namespace FbTk { | ||
33 | |||
34 | /// Allocates rgb color and pixel value | ||
35 | class Color { | ||
36 | public: | ||
37 | Color(); | ||
38 | explicit Color(unsigned long pixel); | ||
39 | Color(const Color &col_copy); | ||
40 | Color(unsigned short red, unsigned short green, unsigned short blue, int screen); | ||
41 | /// parses and sets rgb and pixel value from a string | ||
42 | Color(const char *color_string, int screen); | ||
43 | ~Color(); | ||
44 | |||
45 | /// parses and sets rgb and pixel value from a string | ||
46 | bool setFromString(const char *color_string, int screen); | ||
47 | /// TODO don't like this | ||
48 | void setPixel(unsigned long pixel) { m_pixel = pixel; } | ||
49 | // TODO | ||
50 | //Color &operator = (const Color &col_copy); | ||
51 | |||
52 | bool isAllocated() const { return m_allocated; } | ||
53 | unsigned short red() const { return m_red; } | ||
54 | unsigned short green() const { return m_green; } | ||
55 | unsigned short blue() const { return m_blue; } | ||
56 | unsigned long pixel() const { return m_pixel; } | ||
57 | |||
58 | private: | ||
59 | void free(); | ||
60 | void copy(const Color &col); | ||
61 | void allocate(unsigned short red, unsigned short green, | ||
62 | unsigned short blue, int screen); | ||
63 | inline void setAllocated(bool a) { m_allocated = a; } | ||
64 | void setRGB(unsigned short red, unsigned short green, unsigned short blue); | ||
65 | |||
66 | |||
67 | unsigned short m_red, m_green, m_blue; | ||
68 | unsigned long m_pixel; | ||
69 | bool m_allocated; | ||
70 | int m_screen; | ||
71 | }; | ||
72 | |||
73 | }; // end namespace FbTk | ||
74 | |||
75 | #endif // FBTK_COLOR_HH | ||